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

$jsonSchema operator doesn't seem to work with empty keys

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 5.0.3
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide

      Insert a document with an empty key and then use the $jsonSchema operator to find documents that don't match the expected schema.

      Show
      Insert a document with an empty key and then use the $jsonSchema operator to find documents that don't match the expected schema.
    • QE 2024-07-22, QE 2024-08-05, QE 2024-08-19, QE 2024-09-02

      Using the $jsonSchema operator to find documents that don't match a schema doesn't appear to work correctly when dealing with documents with potentially empty keys.

       

      db.foo.aggregate([{ "$match": { "$nor": [ { "$jsonSchema": { "bsonType": "object", "properties": { "a": { "bsonType": "int" }, "b": { "bsonType": "string" }, "c": { "bsonType": "object", "properties": { "": { "bsonType": "int" }, "d": { "bsonType": "int" } }, "required": ["", "d"], "additionalProperties": false }, "_id": { "bsonType": "objectId" } }, "required": ["_id", "a", "b", "c"], "additionalProperties": false } }] } }])
      
      [
        {
          _id: ObjectId('66958a96ac4c566990c31464'),
          a: 1,
          b: '2',
          c: { '': 3, d: 4 }
        }
      ] 

            Assignee:
            Unassigned Unassigned
            Reporter:
            nathan.leniz@mongodb.com Nathan Leniz
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: