edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

edgedb.Set as query's argument

Open Pentusha opened this issue 3 years ago • 1 comments

Hello. I could not find an any way to use edgedb.Set as query's parameter. How it supposed to annotate set of int64 ($inp)?

client.query('select <int64>1 in $inp', inp=edgedb.Set({1,2,3})) 
edgedb.errors.QueryError: missing a type cast before the parameter
client.query('select <int64>1 in <int64>$inp', inp=edgedb.Set({1,2,3})) 
edgedb.errors.InvalidArgumentError: invalid input for query argument $imp: Set{1, 2, 3} (expected an int)

I'm not sure that it is a bug, because I'm also couldn't run this parameterized query through EdgeDB UI. In the meantime, non-parameterized queries work as expected: select <int64>1 in <int64>{1, 2, 3}

Pentusha avatar Sep 27 '22 17:09 Pentusha

Right, I think set cannot be used as a query parameter yet, you can use an array though:

c.query_single("select contains(<array<int64>>$0, 1)", [1, 2, 3])

Or convert the array into a set:

c.query_single("select 1 in array_unpack(<array<int64>>$0)", [1, 2, 3])

fantix avatar Nov 18 '22 14:11 fantix