-
Notifications
You must be signed in to change notification settings - Fork 2.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
Join field cannot query more than 1 doc with [in]
operator using mongodb
#8901
Labels
Comments
PR is here #8910! Thanks! |
DanRibbens
pushed a commit
that referenced
this issue
Oct 28, 2024
### What? Fixes the issue with `in` querying when the collection has a join field. ### Why? When using `.aggregate`, MongoDB doesn't cast a comma delimited value for the `$in` operator to an array automatically as it's not handled by Mongoose. ### How? Sanitizes the incoming value to an array if it should. Fixes #8901
🚀 This is included in version v3.0.0-beta.120 |
This issue has been automatically locked. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the Bug
This is the underlying issue for bug #8836.
The following request fails when there is more than one id.
Fails (returns 0 docs):
Works (returns 1 doc):
The error can be tracked down to the result on line 117
packages/db-mongodb/src/find.ts
.This result is generated with
packages/db-mongodb/src/utilities/buildJoinAggregation.ts
and within here I believe we are querying incorrectly. Unsure of the fix, it might be version compatibility or needing to append the query with$expr
.Link to the code that reproduces this issue
branch
issue/join-query
(https://github.com/payloadcms/payload/tree/issue/join-query)Reproduction Steps
pnpm dev joins
untitled
untitled
Which area(s) are affected? (Select all that apply)
db-mongodb
Environment Info
Payload: beta@latest
Node.js: v20.9.0
Next.js: v15.0.0
The text was updated successfully, but these errors were encountered: