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

Ignore field order when using JSON Schema to compare object literals

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.0-rc0
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Fully Compatible
    • Query 2017-10-02

      Though an uncommon case, it's possible for a user to compare object literals directly using JSON Schema's enum keyword:

      {enum: [{a: 1, b: 1}]}
      

      This will currently use MongoDB's object comparison semantics, which takes field order into account. However, RFC 7159 ยง1 states that:

      An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array.

      This implies that $jsonSchema object-to-object comparisons should be done without regard to field order, as JSON Schema adheres to the JSON spec.

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            kyle.suarez@mongodb.com Kyle Suarez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: