Skip to content

DOCS-1411: Clarifications on BSON field ordering #1202

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/core/document.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ Record documents have the following attributes:

- .. include:: /includes/fact-document-field-name-restrictions.rst

- Two BSON documents will *only* compare as equal if their fields have
the same order. The :program:`mongod` does not guarantee order, and may
reorder BSON fields when doing updates. MongoDB drivers may also reorder
BSON fields for processing. Therefore BSON document comparisons are
not guaranteed in MongoDB. You may reliably compare BSON documents for
equality only on a field-by-field basis.

.. note:: By contrast, two JSON documents are always considered equal
if the keys and values match, regardless of field order.

The ``_id`` Field
-----------------

Expand Down