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

document validation, $exists:1 works, $exists:0 not so much

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 3.2.4
    • Internal Code
    • None
    • ALL
    • Hide


      Run code above

      Show
      Run code above

    Description

      3.2.4 on Centos 7, mongo

      ---- this first code works as expected -------------------

      db.my_coll.drop()
       
      vc = { "$and" : 
         [ 
         { "k1" : { "$exists" : "true" } }
         ] } 
            
      db.createCollection( "my_coll",
         validator = vc, validationAction = "error" )
       
      db.my_coll.insert( { "k1" : 17 } )      #  works
      db.my_coll.insert( { "k2" : 17 } )      # fails
      

      ---- this code does not work, allows insert -------------

      db.my_coll.drop()
       
      vc = { "$and" : 
         [ 
         { "k1" : { "$exists" : "false" } }
         ] } 
            
      db.createCollection( "my_coll",
         validator = vc, validationAction = "error" )
       
      db.my_coll.insert( { "k1" : 17 } )      #  works
      db.my_coll.insert( { "k2" : 17 } )      #  works
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniel.farrell Daniel Farrell
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: