[SERVER-30251] JSON Schema parser for type keyword should permit missing properties Created: 20/Jul/17  Updated: 30/Oct/23  Resolved: 25/Jul/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.5.11

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: David Storch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2017-07-31
Participants:

 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.



 Comments   
Comment by Githook User [ 25/Jul/17 ]

Author:

{'email': 'david.storch@10gen.com', 'username': 'dstorch', 'name': 'David Storch'}

Message: SERVER-30251 Fix handling of JSON Schema type keyword for missing fields.
Branch: master
https://github.com/mongodb/mongo/commit/79d20fad099532ffb48b688c41acf73dbca91a57

Generated at Thu Feb 08 04:23:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.