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(ejson): legacy mode now matches all compass test cases #347

Closed
wants to merge 13 commits into from

Conversation

imlucas
Copy link
Contributor

@imlucas imlucas commented Jan 13, 2020

This PR updates the legacy extended JSON compatibility introduced by #339 to pass the existing Compass EJSON legacy test suite mongodb-js/extended-json#91

Once this is merged, mongodb-js/extended-json#91 can proceed and mongodb-extended-json can be officially deprecated and archived.

@imlucas imlucas changed the title fix: dbref ejson legacy is a namespace string fix(ejson): legacy mode now matches all compass test cases Jan 13, 2020
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

Just a note for other reviewers the changes to:
test/node/bson_test.js
test/node/map_tests.js
are just prettier formatting that didn't make it to master
I was concerned at first that the ability to override Object.prototype.toString would be an issue here:

if (Object.prototype.toString.call(value) === '[object Object]') {
return serializeDocument(value, options);
}

but following the logic, objects that define their own Symbol.toStringTag will just fall through serializeValue's checks and be passed into serializeDocument.

Just wanted to make notes of my findings LGTM! 🚀

@@ -290,7 +290,7 @@ class Binary {
if (options.legacy) {
return {
$binary: base64String,
$type: subType.length === 1 ? '0' + subType : subType
$type: subType
Copy link
Member

Choose a reason for hiding this comment

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

What's motivating this change? Or rather, why was the padding needed in Durran's original implementation?

@@ -150,6 +155,29 @@ const BSON_INT32_MAX = 0x7fffffff,
BSON_INT64_MAX = 0x7fffffffffffffff,
BSON_INT64_MIN = -0x8000000000000000;

/**
* Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.
Copy link
Member

Choose a reason for hiding this comment

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

Does this same docstring apply with the new implementation?

return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options));
} else {
expr = new BSONRegExp(
doc.$regularExpression.pattern,
Copy link
Member

Choose a reason for hiding this comment

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

this seems to assume the existence of a $regularExpression property

@pooooodles pooooodles added the tracked-in-jira There is a ticket in Mongo's Jira instance tracking this issue/PR label Apr 8, 2021
@bajanam
Copy link

bajanam commented Mar 7, 2022

Thank you for submitting this PR! While our current development plan is at capacity, we will track this in Jira for future prioritization.

@bajanam bajanam closed this Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracked-in-jira There is a ticket in Mongo's Jira instance tracking this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants