edgedb-python
edgedb-python copied to clipboard
edgedb.Set as query's argument
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}
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])