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

pre query middelwares have no effect on QueryCursor projection #13417

Closed
2 tasks done
dbellavista opened this issue May 18, 2023 · 1 comment · Fixed by #13435
Closed
2 tasks done

pre query middelwares have no effect on QueryCursor projection #13417

dbellavista opened this issue May 18, 2023 · 1 comment · Fixed by #13435
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@dbellavista
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

7.0.3

Node.js version

18.12

MongoDB server version

6.0

Typescript version (if applicable)

No response

Description

If a pre-query middelware (e.g. 'find') tries to modify the query projection, it has effect ONLY if the query is not a cursor. Otherwise the select/projection modified the projection of the original Query object and not the projection of the QueryCursor object.

Steps to Reproduce

Here's the script:

https://gist.github.com/dbellavista/c22bfe3fbffac4be1de4cd3d9483d442

Expected Behavior

The script should not fail with an assertion error.

@dbellavista
Copy link
Author

If you have any workaround I'd gladly accept anything... This is causing some problems.. Also if I can find anything of value I'll let you know.

@IslandRhythms IslandRhythms added the confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. label May 19, 2023
@vkarpov15 vkarpov15 added this to the 7.2.1 milestone May 23, 2023
vkarpov15 added a commit that referenced this issue May 24, 2023
fix query cursor and middleware interaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants