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

ensureIndex does not enforce constraints until collection exists

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.3.2, 2.4.0-rc0
    • Component/s: Index Maintenance
    • None
    • Environment:
      OS X
    • Query
    • ALL
    • Hide
      > use qa
      switched to db qa
      > db.test.ensureIndex({ts:"hashed"}, {hashVersion:1})
      > db.test.insert({ts:ISODate()})
      Only HashVersion 0 has been defined
      > db.dropDatabase()
      { "dropped" : "qa", "ok" : 1 }
      

      Expected behavior:

      > use qa
      switched to db qa
      > db.test.insert({ts:ISODate()})
      > db.test.ensureIndex({ts:"hashed"}, {hashVersion:1})
      {
      	"err" : "Only HashVersion 0 has been defined",
      	"code" : 16245,
      	"n" : 0,
      	"connectionId" : 5,
      	"ok" : 1
      }
      
      Show
      > use qa switched to db qa > db.test.ensureIndex({ts: "hashed" }, {hashVersion:1}) > db.test.insert({ts:ISODate()}) Only HashVersion 0 has been defined > db.dropDatabase() { "dropped" : "qa" , "ok" : 1 } Expected behavior: > use qa switched to db qa > db.test.insert({ts:ISODate()}) > db.test.ensureIndex({ts: "hashed" }, {hashVersion:1}) { "err" : "Only HashVersion 0 has been defined" , "code" : 16245, "n" : 0, "connectionId" : 5, "ok" : 1 }

      ensureIndex does not enforce constraints such as hashVersion can only be 0 until data exists in collection.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            epc Ed Costello
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: