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

Ignore field order when using JSON Schema to compare object literals

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.6.0-rc0
    • Querying
    • None
    • Fully Compatible
    • Query 2017-10-02

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: