Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1055

Bad $set update of nested fields fails but throws no error

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.11.3
    • Error Handling
    • None
    • Windows and Linux, used through MATLAB

    Description

      Trying to update a nested field of an object that already exists as a value type, will result in an error when executed from the mongo shell:

      > doc =

      {t1:null} { "t1" : null }

      > db.test.insert(doc)
      > db.test.find()

      { "_id" : ObjectId("529c58a9642f618ff689a5eb"), "t1" : null }

      > db.test.update(

      { "_id" : ObjectId("529c58a9642f618ff689a5eb")}

      ,{"$set":{"t1.t2":1}})
      LEFT_SUBFIELD only supports Object: t1 not: 10

      Trying the same with the JAVA driver (which I access from MATLAB, but I suppose native JAVA would be similar):
      >> doc(1) = BasicDBObject('t1','');
      >> db.getCollection('test').insert(doc)
      >> db.getCollection('test').update(BasicDBObject('_id',doc(1).get('_id')),BasicDBObject('$set',BasicDBObject('t1.t2',1)))

      This fails but returns no error (also other valid fields in doc won't be updated)

      Attachments

        Activity

          People

            Unassigned Unassigned
            zoharby Zohar Bar-Yehuda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: