Preserve integer types when serializing BSON without original parent

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • ALL
    • Hide

      Insert the following document into an empty collection:

      > db.coll.insert({     _id: 14310, "obj": { "array": [ {"nested_array": [NumberInt(57474)],}], },  })

      Then run this update statement, where we expect there would be no modifications:

      > db.coll.update({}, [{$addFields: {"obj.array": { $function: { body: 'function(arg1){ return arg1; }', args: [{ $max: [  ["$obj.obj.obj.num"],"$obj.array" ] } ], lang: 'js' } }, } } ], {multi: true, upsert: true})

      Instead, you'll get a modification count of 1. 

      Show
      Insert the following document into an empty collection: > db.coll.insert({     _id: 14310, "obj" : { "array" : [ { "nested_array" : [NumberInt(57474)],}], },  }) Then run this update statement, where we expect there would be no modifications: > db.coll.update({}, [{$addFields: { "obj.array" : { $function: { body: 'function(arg1){ return arg1; }' , args: [{ $max: [  [ "$obj.obj.obj.num" ], "$obj.array" ] } ], lang: 'js' } }, } } ], {multi: true , upsert: true }) Instead, you'll get a modification count of 1. 
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When serializing BSON Arrays with integer types, we are currently unable to preserve the Integer type information because we don't have an original bson parent which would allow us to confirm the type information. This resulted in a BF where update statements which are expected to be NoOps ended up making modifications to the documents, where the numeric values are equivalent, but the updated values have been coerced to double.

      We should be able to preserve the type information by checking the type bits on the underlying spidermonkey value type instead. 

            Assignee:
            Santiago Roche
            Reporter:
            Santiago Roche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: