tursodatabase / libsql-client-go

Go client API for libSQL
MIT License
159 stars 23 forks source link

Unsupported Positional Parameters #106

Closed juliuslipp closed 2 weeks ago

juliuslipp commented 4 months ago

Hey guys,

I'm getting the following error when trying to query something with positional parameters:

error: unsuppoted positional parameter. This driver does not accept positional parameters with indexes (like ?<number>)"

With the (libsql-cgo)[https://github.com/libsql/go-libsql] client the query works without any problems (but the client has other problems lol)

Example query:

SELECT * FROM example
WHERE example_id = coalesce(?1,  example_id) or swag_id = coalesce(?2, swag_id)
haaawk commented 3 months ago

Note that normal positional parameters are supported. Only the ones with indexes are not supported. See https://github.com/tursodatabase/libsql-client-go/blob/main/examples/sql/counter/main.go#L80

esnunes commented 3 months ago

Is there any plan to add support to it? I have a query that I want to repeat the parameter in a subquery.

insert into
    products (list_id, name, cycle)
values
   (?1, ?2, coalesce((select min(cycle) from products where list_id = ?1), 0))
returning id;
guergabo commented 1 month ago

I opened a PR to add support for it.