-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
How to solve projection combined with populated projection data forwards on MongoDB 4.4? #9973
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
Bump |
vkarpov15
added
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Mar 8, 2021
vkarpov15
added a commit
that referenced
this issue
Mar 10, 2021
This was referenced Mar 11, 2021
Closed
This was referenced Mar 13, 2021
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, started on updating from version 4.2 to 4.4 and ran into some issues with projection and populations.
I've added some simple node.js code test that works in 4.2 but not in 4.4.
4.4 gives me this error message
MongoError: Path collision at items.ref remaining portion ref
Appreciate any help and how have you solved this?
Original request
Test code localy
Solutions
Populate
Simple fix, but should not be necessary.
I see this is probably the way mongoose does this today under the hood. Looking at debug logs I can see that it has its own request after it has found data with help of { _id: { $in: [...] } } for items
Filter after
Fetching data from DB that's not used. Slower requests.
Aggregate
Good solution with 1 DB call and only gets necessary data. But adds 10x more code.
Added the steps I think is needed to do this, wont waste time on writing it down here
Solve in mongoose
I dont like any of those solutions. It will add more code and complexity that shouldn't be necessary. Its so much cleaner on how it was solved in 4.2.
Could there be a change in mongoose that matches some strings so it wont send projections that don't match when user uses
Now
find(query, { 'items.$': 1 ).populate('items.ref')
={ projection: { 'items.$': 1, 'items.ref': 1 }
Change
find(query, { 'items.$': 1 ).populate('items.ref')
={ projection: { 'items.$': 1 }
I also see this fails when user select that specific field. This seems like a strange error when its more expressive on what you really are doing.
The text was updated successfully, but these errors were encountered: