Creating a compound sparse index should uassert

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      It looks like there's a uassert in indexkey.cpp, but it isn't correct. I think it should be:

      uassert( 13529 , "sparse only works for single field keys" , ! _sparse || _nFields == 1 );

      Example:

      admin> db.foo.ensureIndex(

      {x:1,y:1}

      ,

      {sparse:true,unique:true}

      )
      admin> db.foo.getIndexes()
      [
      {
      "v" : 1,
      "key" :

      { "_id" : 1 }

      ,
      "ns" : "admin.foo",
      "name" : "id"
      },
      {
      "v" : 1,
      "key" :

      { "x" : 1, "y" : 1 }

      ,
      "unique" : true,
      "ns" : "admin.foo",
      "name" : "x_1_y_1",
      "sparse" : true
      }
      ]

              Assignee:
              Randolph Tan
              Reporter:
              Kristina Chodorow (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: