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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.2.4
    • Component/s: Internal Code
    • None
    • ALL
    • Hide


      Run code above

      Show
      Run code above
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      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
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            daniel.farrell Daniel Farrell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: