Handle negative array offsets consistently

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      update, find, and $slice don't agree about what negative integers mean: $slice treats negatives as offsets from the right end of the array, find doesn't (seem to) support them at all, and update does something weird:

      db.a.insert({ x : [] });
      db.a.update({}, { $set : { "x.-1" : 1 } } );
      db.a.update({}, { $set : { "x.-1" : 2 } } );
      db.a.update({}, { $set : { "x.-1" : 3 } } );
      db.a.find()
      { "_id" : ObjectId("4f849706fdbf7f54d34ba15b"), "x" : [ 3, 2, 1 ] }
      db.a.find({}, { x: { $slice : -1 } })
      { "_id" : ObjectId("4f849706fdbf7f54d34ba15b"), "x" : [ 1 ] }
      db.a.find({ "x.-1" : 1 });
      

      I didn't check what aggregation framework operators do...

              Assignee:
              Unassigned
              Reporter:
              Richard Kreuter (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: