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

Querying properties with values Code() is incorrect

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      When creating properties with value of Code() (plus context), querying documents with this properties does not return correct result.

      The following code inserts a document, but when querying it with a non-matching query, it is returned (see the context: the context in the query is different from the context in the document, and it is still being returned).

      var Db = require('mongodb').Db,
      Server = require('mongodb').Server,
      ObjectID = require('mongodb').ObjectID,
      Binary = require('mongodb').Binary,
      GridStore = require('mongodb').GridStore,
      Code = require('mongodb').Code,
      BSON = require('mongodb').pure().BSON,
      assert = require('assert');

      var db = new Db('jiras', new Server("127.0.0.1", 27017,

      {auto_reconnect: false, poolSize: 4}

      ),

      {w: 0, native_parser: false}

      );

      db.open(function (err, db) {
      db.dropCollection("code", function (err, result) {

      db.createCollection('code', function (err, collection) {
      if (err)

      { console.log(err); }

      var codeDocument = {"x": new Code("function () {}",

      {a: 55}

      ), "comment": "Code w/scope a:55"};
      console.log("original document:");
      console.log(codeDocument);

      collection.insert(codeDocument,

      {w: 1}

      , function (err, result) {
      var codeQuery = {"x": new Code("function () {}",

      {b: 77}

      )};
      var cursor;
      var cursorStream;

      assert.equal(null, err);

      cursor = collection.find(codeQuery);
      cursorStream = cursor.stream();
      cursorStream.on("data", function (docs)

      { console.log("query:"); console.log(codeQuery); console.log("result document:"); console.log(docs); }

      );
      cursorStream.on("close", function ()

      { db.close(); }

      );
      });
      });
      });
      });

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            chris@real-programmer.com Christoph Bussler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: