Skip to content
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

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

Open
fidan-mkdir opened this issue Dec 26, 2022 · 0 comments

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant