-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[8.x] Protect against ambiguous columns #43278
Conversation
Updating tests.
@BenWalters please add a thorough explanation to your main PR description (see the PR template) so Taylor knows what this is about. Thanks. |
@driesvints updated! Let me know if anything else is needed. |
@BenWalters maybe also share an example of the global scope |
@driesvints it's a WIP but I've added an example. |
This looks like a breaking change so we're reverting this: #43353 |
This reverts commit a6d9307.
@driesvints no problem, I would however say that this is 'breaking' because of a 3rd party packages bad implementation. The Mongo DB package does not prefix fields with table names. They have only overridden some of the qualify column methods that are implemented on the abstract Model class that Laravel Framework provides. |
@driesvints sorry, I'd not seen the octane issue also. I cannot comment on that one. |
Having just looked at it though it's also because MongoDB is being used. |
Resolving #43274
When applying a global scope to a User model that joins a secondary table, which also has an ID field, the
retrieveById
andretrieveByToken
functions of Illuminate\Auth\EloquentUserProvider do not qualify the identifier field name in the where clause which. This subsequently causes a "Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous" error.Wrapping
$model->getAuthIdentifierName()
in$model->qualifyColumn()
on both methods protects against this.This is a non-breaking change and is in-line with other abstract queries/builders. Tests updated accordingly.
Example global scope: