-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DOCS-8794: Document sort order for Object #3160
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few suggestions on wording. Note also that lines should be wrapped at 80 chars.
Cheers,
Brian
Objects | ||
------- | ||
|
||
A comparison of two BSON objects using operators is performed using the following order : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better with the active voice:
The comparison of BSON objects uses the following order:
|
||
A comparison of two BSON objects using operators is performed using the following order : | ||
|
||
#. The key/value pairs are recursively compared in the order of appearance within the BSON object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Active voice:
Recursively compare key/value pairs in the order they appear within the BSON object.
|
||
#. The key/value pairs are recursively compared in the order of appearance within the BSON object. | ||
#. Compare the :ref:`key field names <document-field-names>`. | ||
#. If the key field name is equal, compare the value of the field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pluralize:
If the key field names are equal, compare the field values.
#. The key/value pairs are recursively compared in the order of appearance within the BSON object. | ||
#. Compare the :ref:`key field names <document-field-names>`. | ||
#. If the key field name is equal, compare the value of the field. | ||
#. If the value of the field is equal, compare the next key/value pair (back to step 1). This is where the length of the object matters, the object with the next non-null element is greater. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the field values are equal, compare the next key/value pair (return to step 1). An object without further pairs is lesser than an object with further pairs.
@@ -55,6 +55,17 @@ when comparing a field whose value is a single-element array (e.g. ``[ | |||
``1`` and ``2``. A comparison of an empty array (e.g. ``[ ]``) treats | |||
the empty array as less than ``null`` or a missing field. | |||
|
|||
Objects | |||
------- | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. versionadded:: 3.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behaviour wasn't changed at 3.4. Not sure what was the first version the behaviour introduced, but just never documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense.
@@ -55,6 +55,17 @@ when comparing a field whose value is a single-element array (e.g. ``[ | |||
``1`` and ``2``. A comparison of an empty array (e.g. ``[ ]``) treats | |||
the empty array as less than ``null`` or a missing field. | |||
|
|||
Objects | |||
------- | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense.
Merged to master - thanks! |
Oh, and back-ported to 3.4 as well. |
* DOCSP-29495 Add Security Bug Form * *
Based on
https://github.com/mongodb/mongo/blob/r3.4.10/src/mongo/bson/bsonobj.cpp#L105
applies to MongoDB v3.4 and v3.6
This change is