Skip to content

Conversation

juliusgeo
Copy link
Contributor

No description provided.

@juliusgeo juliusgeo linked an issue Dec 17, 2021 that may be closed by this pull request
Copy link
Collaborator

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

Looking much better!

@@ -291,6 +291,25 @@ def test_load_throws_no_read_attribute(self):
not_file = {}
self.assertRaises(AttributeError, bsonjs.load, not_file)

def test_extended(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can rename this to test_mode now. Can you also add a test case for dump (not dumps) and also add a test for passing the mode as a non-keyword (ie positional) argument?:

bsonjs.dumps(bson_bytes, bsonjs.CANONICAL)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you add the test for dump()?

src/bsonjs.c Outdated
}
else if(mode == 0){
json = bson_as_json(b, json_len);
}else{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting of this if/else if/else block is still inconsistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that, done.

Copy link
Collaborator

@ShaneHarvey ShaneHarvey Dec 20, 2021

Choose a reason for hiding this comment

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

This is still not resolved. Following the existing if/else statements in this file it should be:

    if (mode == 1) {
        json = bson_as_relaxed_extended_json(b, json_len);
    } else if (mode == 2) {
        json = bson_as_canonical_extended_json(b, json_len);
    } else if (mode == 0) {
        json = bson_as_json(b, json_len);
    } else {
        ...
    }

src/bsonjs.c Outdated
}
else if(mode == 0){
json = bson_as_json(b, json_len);
}else{
Copy link
Collaborator

@ShaneHarvey ShaneHarvey Dec 20, 2021

Choose a reason for hiding this comment

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

This is still not resolved. Following the existing if/else statements in this file it should be:

    if (mode == 1) {
        json = bson_as_relaxed_extended_json(b, json_len);
    } else if (mode == 2) {
        json = bson_as_canonical_extended_json(b, json_len);
    } else if (mode == 0) {
        json = bson_as_json(b, json_len);
    } else {
        ...
    }

src/bsonjs.c Outdated
}else if(mode == 0){
json = bson_as_json(b, json_len);
}else{
PyErr_SetString(PyExc_ValueError, "The value of extended must be one "
Copy link
Collaborator

Choose a reason for hiding this comment

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

extended -> mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

Please add the dump() test requested here: #33 (comment)

@juliusgeo juliusgeo merged commit f936304 into mongodb-labs:master Dec 20, 2021
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.

Add support for MongoDB Extended JSON 2.0
2 participants