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

7.0 driver cleanup #12839

Merged
merged 4 commits into from
Jan 17, 2023
Merged

7.0 driver cleanup #12839

merged 4 commits into from
Jan 17, 2023

Conversation

vkarpov15
Copy link
Collaborator

Summary

Make drivers easier to implement, and minimize how hard-coded the MongoDB driver is in our code. Also remove the require('../driver').get() calls that tend to confuse bundlers and cause hard-to-debug issues when implementing custom drivers. Drivers are now fully scoped to a single Mongoose instance, minus the driver.js file which we still need to remove.

Examples

@@ -904,7 +893,7 @@
continue;
}
if (typeof to[key] === 'undefined') {
to[key] = exports.clone(fromObj[key], {
to[key] = clone(fromObj[key], {

Check warning

Code scanning / CodeQL

Prototype-polluting function

Properties are copied from [fromObj](1) to [to](2) without guarding against prototype pollution.
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think this alert can be dismissed, ~5 lines above in the loop specialProperties are already skipped

@hasezoey
Copy link
Collaborator

if i understand correctly, this means a custom driver cannot provide types like ObjectId (etc) anymore and mongoose is now always using directly from bson? (from what it seems like, it was not consistent to begin with)

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.

overall looks good to me, though some small notes

lib/query.js Show resolved Hide resolved
@@ -904,7 +893,7 @@
continue;
}
if (typeof to[key] === 'undefined') {
to[key] = exports.clone(fromObj[key], {
to[key] = clone(fromObj[key], {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think this alert can be dismissed, ~5 lines above in the loop specialProperties are already skipped

@vkarpov15 vkarpov15 merged commit 060dfb3 into 7.0 Jan 17, 2023
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-12638 branch January 17, 2023 16:16
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.

2 participants