Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edgedb.Set as query's argument #368

Open
Pentusha opened this issue Sep 27, 2022 · 1 comment
Open

edgedb.Set as query's argument #368

Pentusha opened this issue Sep 27, 2022 · 1 comment

Comments

@Pentusha
Copy link

Pentusha commented Sep 27, 2022

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}

@fantix
Copy link
Member

fantix commented Nov 18, 2022

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])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants