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

JSON Schema parser for type keyword should permit missing properties

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 3.5.11
    • None
    • Querying
    • None
    • Fully Compatible
    • ALL
    • Query 2017-07-31

    Description

      Currently $jsonSchema will treat a property as required if the schema specifies a type. The JSON Schema spec, however, says to permit the property to be missing in this case.

      > db.c.find()
      { "_id" : ObjectId("597111d528cdb6d02e838d05"), "a" : 3 }
      { "_id" : ObjectId("597111d728cdb6d02e838d06"), "a" : 5 }
      { "_id" : ObjectId("597111da28cdb6d02e838d07") }
      > db.c.find({$jsonSchema: {properties: {a: {type: "number", maximum: 4}}}})
      { "_id" : ObjectId("597111d528cdb6d02e838d05"), "a" : 3 }
      

      The second query above is missing results, since it should also return the document that does not have the a field.

      Attachments

        Activity

          People

            david.storch@mongodb.com David Storch
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: