[SERVER-8009] Querying for documents containing code ($type:15) does not match scope Created: 21/Dec/12  Updated: 07/Apr/23  Resolved: 02/Feb/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.2.0, 2.6.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Christoph Bussler Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: nh-240
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

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.

Participants:

 Description   

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?



 Comments   
Comment by J Rassi [ 02/Feb/16 ]

This has been fixed in 2.8.0-rc5 by SERVER-7804.

Closing as a dup of SERVER-7804.

Generated at Thu Feb 08 03:16:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.