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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sanitizes extra dollar signs for operators #584

Merged
merged 1 commit into from Jul 10, 2020
Merged

Conversation

agnes512
Copy link
Contributor

@agnes512 agnes512 commented Jul 7, 2020

fixes #532

Add a helper function that removes all extra dollar signs.
e.g $eq -> eq, $$eq -> eq ( don't consider the case as an error).

Screen Shot 2020-07-07 at 16 33 12

Checklist

馃憠 Read and sign the CLA (Contributor License Agreement) 馃憟

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • Commit messages are following our guidelines

lib/mongodb.js Outdated
while (spec.charAt(0) === '$') {
spec = spec.substr(1);
}
return spec;
Copy link
Contributor

Choose a reason for hiding this comment

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

The function can be simplified as follows:

function trimLeadingDollarSigns(spec) {
  return spec.replace(/^(\$)+/, '');
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed! Applied.

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

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

馃憤 LGTM in general, just a few suggestions.

test/mongodb.test.js Outdated Show resolved Hide resolved
test/mongodb.test.js Outdated Show resolved Hide resolved
test/mongodb.test.js Outdated Show resolved Hide resolved
@@ -765,7 +765,6 @@ MongoDB.prototype.parseUpdateData = function(modelName, data, options) {
'$pop',
'$pullAll',
'$pull',
'$pushAll',
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason deleting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@agnes512 agnes512 force-pushed the fix/filter branch 2 times, most recently from f696d89 to a978ae8 Compare July 10, 2020 17:00
@agnes512 agnes512 merged commit 319d5f0 into master Jul 10, 2020
@delete-merged-branch delete-merged-branch bot deleted the fix/filter branch July 10, 2020 18: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.

MongoError: unknown operator: $$eq
3 participants