Queries that include the count of a relation that has multiple foreign keys translates to incorrect SQL #7299
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: postgresql
topic: previewFeatures
Issue touches on an preview feature flag
topic: selectRelationCount
Milestone
Bug description
Running a query to retrieve the count of a relation that has multiple foreign keys results in the following error:
This appears to happen because the
ON
clause for theJOIN
uses comma-separated boolean expressions instead ofAND
-seperated boolean expressions.For example, this doesn't work:
But this does:
I'd suggest that such queries use
AND
instead of commas during the transformation into raw SQL.How to reproduce
Given the Prisma models included, running the following:
Gives the following error:
Expected behavior
It should successfully return an array of objects that include the vote count.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: