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

fix(base): allow global option mongoose.set('strictQuery', true); #9016

Merged
merged 13 commits into from May 18, 2020

Conversation

AbdelrahmanHafez
Copy link
Collaborator

fixes #6658 for strictQuery

let strictQueryOriginalValue;

this.beforeEach(() => strictQueryOriginalValue = mongoose.get('strictQuery'));
this.afterEach(() => mongoose.set('strictQuery', strictQueryOriginalValue));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vkarpov15 I'd like to know what you think of this approach.

I initially made the cleanup in each test, but if one of those tests had failed, the cleanup wouldn't have happened, causing more tests to fail, making it difficult to find the root cause of all the failing tests.

I think this mitigates this concern, but I still don't like it. How would you do that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is ok, but the better approach would be to create a new Mongoose instance using const _mongoose = new mongoose.Mongoose(); and use _mongoose.set(). Check out the test for #6578 for an example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this attempt to create a new connection with the same URI for the database? Making tests run significantly slower?

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a new feature, I'll merge this into the 5.10 branch. Since the mongodb driver looks like they're going to do a 3.6 release before their 4.0 release, we should do a 5.10 release before 6.0.

@vkarpov15 vkarpov15 changed the base branch from master to 5.10 May 18, 2020 20:59
@vkarpov15 vkarpov15 merged commit 63dbf7c into Automattic:5.10 May 18, 2020
@vkarpov15 vkarpov15 added this to the 5.10 milestone May 18, 2020
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

Successfully merging this pull request may close these issues.

Global strict mode configuration
3 participants