-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add full support for filtering by relations #17
Comments
@danielweil You need to wrap the relational field query with either In your case it should be: role = await client.role.find_first(
where={
'User': {
'email': email,
},
},
) Also it looks like you're using VSCode, if so you should definitely install the Pylance extension which will suggest the query arguments for you when you trigger auto-complete: https://github.com/RobertCraigie/prisma-client-py/blob/main/docs/showcase.gif |
Thanks! |
Do I have to apply any setting for the autocomplete to work? Here it still doesn't show up |
You have to manually trigger autocomplete: https://code.visualstudio.com/docs/editor/intellisense#_intellisense-features The |
Ah so that's your problem, you need to annotate your from prisma import Client
async def get_client() -> Client:
... May I ask what your use case is for writing your own Client factory? |
The issue might be with any part of |
I don't think so, I've used Python with WSL before without any issues
Ah I see, is this because you have to update the access token? |
@danielweil I'm so sorry I just realised I gave you the wrong query, it should be: role = await client.role.find_first(
where={
'User': {
'is': {
'email': email,
},
},
},
) |
That is bizarre, can you share how you're importing the client please? |
Might be something here! Failed to validate the query: |
Ah sorry I missed that it was a list relation, replace |
That worked out! |
@danielweil Glad I could help! About the Client type, does hovering over the import resolve correctly? |
If that does, are you overriding the Client name anywhere? |
It does not and I do not override it anywhere |
That sounds like VSCode is using the wrong python interpreter then. Are you using a venv? |
You need to add an model User {
//
email String @db.VarChar(255) @unique
//
} |
Thanks! |
Do you know what doesn't work? Is the |
The issue is that you've typed the |
Thanks! worked perfectly |
@danielweil how did you solve this ? we tried "is", and "every" according to the documents but we can't query based on relation fields? any suggestions? |
@farzad-salimijazi I'm sorry you're encountering difficulties, could you share your schema and the query you're trying to write so I can offer some help :) |
Problem
Currently only support nested filtering (through the include argument), this means that even if nothing matches the nested filter the base filter still passes, which could be confusing.
Suggested solution
Add relational fields to
WhereInput
, e.g.Additional context
Playground schema screenshot
The text was updated successfully, but these errors were encountered: