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

Caution to pass argument QueryOptions by reference #12176

Closed
2 tasks done
ecalcutin opened this issue Jul 29, 2022 · 0 comments
Closed
2 tasks done

Caution to pass argument QueryOptions by reference #12176

ecalcutin opened this issue Jul 29, 2022 · 0 comments
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@ecalcutin
Copy link

ecalcutin commented Jul 29, 2022

Prerequisites

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

Mongoose version

6.4.6

Node.js version

17.7.1

MongoDB server version

5x

Description

find method implicitly overrides arguments passed by reference
Bug has been raised originally on nestjs/nest#10045 but once I found the root case, it looks like it is related to mongoose.

Steps to Reproduce

Given object

const queryOptions = {
  populate: ['whatever']
};

const entities = await model.find({}, {}, options).lean();

Once query is execuded, the queryOptions became {}.

Expected Behavior

queryOptions variable should not be overriden or should be properly documented here: https://mongoosejs.com/docs/api.html#query_Query-setOptions

@vkarpov15 vkarpov15 added this to the 6.5.2 milestone Aug 3, 2022
@vkarpov15 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 Aug 3, 2022
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

No branches or pull requests

2 participants