-
-
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
Add testConditionOnQueriedField for WhereHasConditionsDirective #1472
base: master
Are you sure you want to change the base?
Conversation
https://github.com/nuwave/lighthouse/blob/master/CONTRIBUTING.md#how-to-contribute-to-lighthouse |
Ok well I seem to have identified where the issue comes from, also explaining why there's no issue right now in Lighthouse after adding the test. We are coupling players to teams with an linking table called player_team, the resulting query when using the whereCondition looks like: select count(*) as aggregate
from `teams`
where EXISTS (
select * from `players`
inner join `player_team`
on `player_team`.`player_id` = `players`.`id`
where `teams`.`id` = `player_team`.`team_id`
AND (`ID` = 120)
) Since it's literally just taking the enum value as the column for the condition we get an ambiguous error, because what it should be checking is |
@Jofairden so you are not using joins instead of plain Eloquent relations? Automatically prefixing column names when joins are used is a long standing issue within Laravel. I got my hands dirty and tried to fix this before, but found that the rabbit hole goes quite deep: https://github.com/spawnia/laravel-framework/tree/prefer-original-table-columns-on-join |
The relationship that's being queried here is a public function players()
{
return $this->hasManyThrough(
Player::class,
PlayerTeam::class,
"team_id",
"id",
"id",
"player_id");
} Anyways, so are you saying this is more or less an issue in Laravel and less so in Lighthouse / our app ? That'd be quite an issue for us |
@Jofairden you can try and replicate this issue without Lighthouse using the query builder yourself. I believe that this would produce a similar error: $team->players()->where('id', 123) |
Yup I can confirm this now:
|
Having the same for a polymorphic relation:
When I prefix the first one it works, but the filters aren't doing this: Any ideas on that? |
See #1470
Changes
Added a test for this issue
Breaking changes
None
Details
I cannot seem to run any tests at all, I just keep getting a bunch of errors. Care to tell me how the tests can be setup locally?