[SERVER-9812] User query is interpreted incorrectly if the first field is "query" Created: 29/May/13 Updated: 01/Sep/15 Resolved: 12/Aug/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Seraj Ahmad | Assignee: | David Storch |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Major Change | ||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||
| Comments |
| Comment by David Storch [ 12/Aug/15 ] | ||||
|
Per my earlier comment, this will be resolved with SERVER-15176. Once this ticket is resolved, the query db.foo.find({query: {b: 1}}) will correctly match documents that have a literal query field with a nested document {b: 1}:
Closing as a duplicate. | ||||
| Comment by David Storch [ 28/May/15 ] | ||||
|
We expect this to be resolved with the introduction of the find and getMore commands (see SERVER-15176). | ||||
| Comment by Daniel Pasette (Inactive) [ 03/Jun/13 ] | ||||
|
It's not currently documented but I did add a ticket for it here: | ||||
| Comment by Seraj Ahmad [ 30/May/13 ] | ||||
|
Is this behaviour documented somewhere? I can't find any documentation related to this. Are there any other such restrictions on queries? | ||||
| Comment by Seraj Ahmad [ 30/May/13 ] | ||||
|
Also, the field 'query' need not be first field in the query. db.sample.find({'a': 1, 'query': { 'b': 2, 'c': 3 }}) | ||||
| Comment by Seraj Ahmad [ 30/May/13 ] | ||||
|
I was using 1.7.x version before and it was working. I was wondering how come it is not backward compatible. | ||||
| Comment by Scott Hernandez (Inactive) [ 29/May/13 ] | ||||
|
This is unfortunately expected behavior. In order to do your "query" you will need to wrap your query like this:
This behavior exists for historic, and internal, reasons and is not currently something which is easy to fix because of backwards compatibility, which it would break. We are working on removing this special behavior but we are not there yet. | ||||
| Comment by Seraj Ahmad [ 29/May/13 ] | ||||
|
Here is how to reproduce it in version 2.4.3 db.sample.insert({'a': 1, 'q': { 'b': 2, 'c: 3 }}) |