-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
Query Execution
-
(copied to CRM)
Equality of documents should not depend on the order of the fields. The following documents should be considered equal:
{a: 1, b: 2} {b: 2, a: 1}The above documents would be considered the same document for purposes of unique indexes, and would be considered a match for searching.
This allows documents to map much more naturally to the native, built-in dictionary types in various languages. Most native dictionary types don't preserve order, and builtin dictionary types that support equality (Python, Ruby) don't compare insertion order. Ruby, which does explicitly preserve insertion order, also still does not consider insertion order for equality; {:a=>1, :b=>2} == {:b=>2, :a=>1} is true.
This would reduce the need to use inconvenient non-builtin dictionary types, and align documents to typical expectations of dictionary types.
Note: this is not a recommendation to stop preserving insertion order. Although I don't find that useful, it's not obviously harmful, and it should be possible to do both efficiently.
Additional discussion at http://groups.google.com/group/mongodb-user/browse_thread/thread/c908e572d6e89c49.
- is duplicated by
-
SERVER-22817 Duplicate _id in the same collection without sharding/replicaset configured
- Closed
-
SERVER-22529 search order for embedded documents, and only there
- Closed
-
SERVER-30392 Query does not return a document when the sub-document fields are not listed in the same order as they exist in the document
- Closed
- is related to
-
SERVER-30197 $eq-ordered and $eq-unordered
- Backlog
- related to
-
SERVER-30705 Concurrent updates and FCV change can cause dbhash mismatch between primary and secondary
- Closed