Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-351

Documents with a key "result" that's an array get clobbered

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 2.0.14, 1.4.29
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Code:

      var mongodb = require('mongodb');
      
      mongodb.MongoClient.connect('mongodb://localhost:27017', function(error, db) {
        db.dropDatabase(function() {
          db.collection('test').insert({ name: 'Val', result: [{ x: 1 }] }, function() {
            db.collection('test').findOne({ name: 'Val' }, function(error, doc) {
              console.log(JSON.stringify(doc));
            });
          });
        });
      });
      

      Output:

      {"x":1}
      

      As a result of the following code in mongodb-core: https://github.com/christkv/mongodb-core/blob/d57b52f8efffaa6c16e598a119fe65737a00c7c6/lib/cursor.js#L193-196

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            valeri.karpov@mongodb.com Valeri Karpov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: