Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8009

Querying for documents containing code ($type:15) does not match scope

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.0, 2.6.3
    • Component/s: Querying
    • ALL
    • Hide

      1. Insert Document:

      {"x": new Code("function () {}", {a: 55}), "comment": "Code w/scope a:55"}
      

      2. Run query:

      {"x": new Code("function () {}", {b: 77})}
      

      3. Observe that the document from 1. is returned even though the scope does not match.

      Show
      1. Insert Document: { "x" : new Code( "function () {}" , {a: 55}), "comment" : "Code w/scope a:55" } 2. Run query: { "x" : new Code( "function () {}" , {b: 77})} 3. Observe that the document from 1. is returned even though the scope does not match.

      I came across a problem in the node.js driver and I was told that this is a server question (https://github.com/mongodb/node-mongodb-native/issues/811).

      I tried to recreate the problem in the mongo shell, but was not able to, so here what I did in the node.js environment and what the problem is. To recreate:

      1. Insert Document:

      {"x": new Code("function () {}", {a: 55}), "comment": "Code w/scope a:55"}
      

      2. Run query:

      {"x": new Code("function () {}", {b: 77})}
      

      3. Observe that the document from 1. is returned even though the scope does not match.

      Problem:

      It appears that the query for code only matches the function part, but not the scope part. Is this a bug? If not, how to I rewrite the query so that I get back only matching scopes? Or is this a problem to be solved in the client, meaning, I have to do the selection for the scope myself?

            Assignee:
            Unassigned Unassigned
            Reporter:
            chris@real-programmer.com Christoph Bussler
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: