-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Nested ids remapped even if renameEmbeddedIdField is false #3351
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 surprised by your issue because there is a test that covers this scenario: laravel-mongodb/tests/Query/BuilderTest.php Lines 1602 to 1625 in bdae18d
Perhaps the problem only arises when the query is created from a Model. |
I believe that test only covers this: And not this: To make sure this wasn't an issue in my project I cloned this project and added a test that fails.
Output: |
Correct me if I'm wrong but I believe this can be fixed by updating this if statement in
To this:
Because if the key includes a |
Thank you @NickHuijgen for reporting and investigating this issue. The fix is merged and released in 5.3.1. |
Description:
I'm trying to query based on the
id
field of a nested array document. When attempting to query theid
field is remapped to_id
regardless of therenameEmbeddedIdField
setting.If I modify my query to include another
where()
clause, theid
field is not remapped to_id
Model::query()->where('id', 1)->where('nested.id', 1)->get()
-> does not remapnested.id
Model::query()->where('nested.id', 1)->get()
-> remapsnested.id
Steps to reproduce
'rename_embedded_id_field' => false
orDB::connection('mongodb')->setRenameEmbeddedIdField(false);
Model::query()->where('nested.id', 1)->get();
Expected behaviour
nested.id
should not be remapped tonested._id
in the query becauserenameEmbeddedIdField
is set tofalse
Actual behaviour
In the query that is executed
nested.id
is remapped tonested._id
in the queryThe text was updated successfully, but these errors were encountered: