-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Complex where queries: Integrity constraint violation: 1052 Column "XXX" in where clause is ambiguous #1470
Comments
Please add a PR with a failing test case in https://github.com/nuwave/lighthouse/blob/master/tests/Integration/WhereConditions/WhereHasConditionsDirectiveTest.php in order to investigate this further. By the way (not invalidating your issue), but have you considered using the following query instead: {
player(id: 120) {
teams {
players { ... }
}
}
} It is generally a good idea to take advantage of the fact that a GraphQL query does indeed form a graph of data and traverse it as such. |
I know you can reverse/change the queries, maybe my example was bad by just showing one ID, but this happens in many cases, for example filtering by a collection of IDs using the IN operator. I'll see if I can add a PR with a test. |
Come to think of it, I think this issue is relevant: #1356 |
Can you check #1253 for inspiration? |
I'm new to this project and not sure if I followed the rules correctly.. But I added a failing test ☝️ |
Another related issue: #1214 I feel like all of those could be solved upstream by Laravel itself. If not, we have to think long and hard about how we can produce a robust solution. |
Describe the bug
Querying a certain field on a relation of the resulting type of the query and applying a complex where query to filter the relation causes the SQL error:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'ID' in where clause is ambiguous
Expected behavior/Solution
I feel like selections in the query need to be prefixed, or
addSelect
should be used (if it isn't already)Steps to reproduce
hasX
complex where filter to filter the queried field, e.g. ID or name etc.Output/Logs
Example error: (see example code below)
Lighthouse Version
"nuwave/lighthouse": "^4.12",
Example code:
Query:
(Requesting teams of players, request players of the teams (paginated) and filter the players relation for an ID)
Example GraphQL query file:
Team type:
Player type:
Playercolumn example:
The text was updated successfully, but these errors were encountered: