Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Querying subdocuments using whereIn by "_id" field does not work, yet it does by "id" key #2489

Closed
fidan-mkdir opened this issue Dec 26, 2022 · 1 comment · Fixed by #3040
Labels
Milestone

Comments

@fidan-mkdir
Copy link

Description:

Querying using whereIn("subarray._id", [...]) does not work, when subarray has an array of items with '_id' field. If you had subarray of items with 'id' instead of '_id' and then queried for "subarray.id" it would work.
However querying using whereRaw(['subarray._id' => ['$in' => ['id_value'']]]) works as expected. I tried transforming the array of _id strings into an array of ObjectIds but it didn't help.

Steps to reproduce

  1. Create a document with a subarray of items where each item will have an _id field
  2. Try a query using whereIn("subarray._id", [...]) = will not return results
  3. Now do the same but create a document with a subarray of items where each item will have an id field
  4. Try a query using whereIn("subarray.id", [...]) = will return results

Expected behaviour

It should work as normal, as in step 4

Actual behaviour

It returned no results while there definitely were matches

@GromNaN
Copy link
Member

GromNaN commented Sep 3, 2024

Fixed by #3040

@GromNaN GromNaN closed this as completed Sep 3, 2024
@GromNaN GromNaN added the feature label Sep 3, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants