-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Unexpected behaviour when laravel 12 and passport 12 with mongodb 5.4 #3371
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
Comments
I'm experiencing a similar issue where the collection documents have both the _id and id \MongoDB\Laravel\Query\Builder::aliasIdForQuery |
Maybe \MongoDB\Laravel\Query\Builder::compileWheres :
should also be changed to:
|
This is something we can't support in this library while maintaining good compatibility with Eloquent SQL. But I understand that some existing databases are made that way; and you need to deal with them.
No, that would do the opposite of what the option name tell. That would convert
@faisaltkr If the application provides an identifier, why do you need to generate an ObjectId? What is the behavior with a SQL database?
@LNDev Could you open a pull-request with a failing test case, so we can work on a solution? |
@GromNaN from what I’ve observed, the issue arises when queries are performed using the "id" field on collections where the values of _"id" and "id" are different. In such cases, querying by "id" returns an empty result. For example:
returns an empty result. This happens due to three main reasons: First, the method getRenameEmbeddedIdField() returns true by default if the rename_embedded_id_field setting is not defined in the config/database.php file. Second, in the methods "aliasIdForQuery" and "aliasIdForResult", if rename_embedded_id_field is not defined or is explicitly set to true or explicitly set to false (in any way, then), the "id" field is always internally converted to "_id" (in root). As a result, any query targeting "id" actually ends up querying "_id". Third, during the compilation of the "where" clause by the "compileWheres" method, the "id" column is again transformed into "_id". This means that any condition written on "id" is effectively applied to "_id" instead. |
The previous version (4.8) was working as the expected result but the current version(5.4) is removed the ObjectId and replaced with a string. Now it is working fine |
@faisaltkr so people who used to use the _id and id as separate values must just stay in the past and never upgrade to 5.x ? |
I have opened a new issue : #3380 |
No - they should look at what value they primarily use (
We are trying to do away with an old design decision we inherited when taking over this library. This decision led to several issues, including having two "identifiers" with different values. The primary key in MongoDB is always |
Description: When we installing passport with mongodb, the _id is storing as string
Steps to reproduce
Expected behaviour
Actual behaviour
The text was updated successfully, but these errors were encountered: