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(model+query): make findOne(null), find(null), etc. throw an error instead of returning first doc #15019

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

vkarpov15
Copy link
Collaborator

Re: #14948

Summary

As we found out in #14948, findOne(null) throws an error with the MongoDB Node driver, but Mongoose treats it as findOne({}). I do think that making findOne(null) and findOne(undefined) throw an error is more correct (while still allowing findOne({}) and findOne() to return the first doc), and I think this change is a step in the right direction, but I'm wondering if we should put this in a minor release 8.10, or hold off until 9.0?

Examples

@vkarpov15 vkarpov15 added this to the 8.9 milestone Nov 5, 2024
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM, i dont know how much impact this gonna have, so maybe move it to 9.0 as a breaking change?

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

LGTM, this looks like a breaking change to me, would ship at v9.0.

@vkarpov15 vkarpov15 changed the base branch from master to 9.0 November 8, 2024 18:22
@vkarpov15 vkarpov15 modified the milestones: 8.9, 9.0 Nov 8, 2024
@vkarpov15 vkarpov15 merged commit d36ac59 into 9.0 Nov 8, 2024
58 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14948 branch November 9, 2024 11:52
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.

3 participants