Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5030

Document equality should be independent of field insertion order



    • Type: Improvement
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Case:


      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.


          Issue Links



              • Votes:
                10 Vote for this issue
                25 Start watching this issue


                • Created: