-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
_relevance
error when utilizing orderBy
relations
#17428
Comments
_relevance
error when utilizing order by relations
_relevance
error when utilizing order by relations_relevance
error when utilizing orderBy
relations
Any updates on this? Im having the same issue in the same scenario. |
Can one of you please enable query logging and share the SQL queries that are created for this under the hood? What happens when you run them manually against the database? |
Hi @janpio, i'm seeing the same result - here are the generated sql queries for a prisma statement with a regular orderBy _relevance clause vs one with child orderBy _relevance clauses. ...working
... not working, throws
|
Ran the SQL direct against the database and got the following err
Direct from ChatGPT when plugging the error in in context with the SQL:
I went back to the regular orderBy syntax that references child relation's fields to get the SQL for how its maintaining the reference to the joined column in the orderby clause. See below:
It looks like the key difference is the regular orderBy makes those additional table aliases then references those in the orderby clause. Edited the original SQL to use that pattern and successfully ran that against the database, so it looks like that's the fix here.
Hope this helps 👍 i love prisma |
Bug description
Using
_relevance
fails when used with fields within a relation table.If
orderBy: { ... }
is removed, the query works without the table '{not available}' error.How to reproduce
Setup a parent & child table relation. Preform the query.
Expected behavior
I would expect this to order results according to their relevance to the search query and the fields specified in the relation table.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: