[SERVER-4395] $query operator not working in _addSpecial Created: 30/Nov/11 Updated: 12/Feb/13 Resolved: 07/May/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Uladzimir Mihura | Assignee: | Tad Marshall |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Operating System: | ALL | ||||
| Participants: | |||||
| Description |
|
In the documentation http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24query :
You can try this in shell:
|
| Comments |
| Comment by Tad Marshall [ 07/May/12 ] | |||
|
This is messed up in several ways: 1) The example given first, reportedly from the wiki ("db.foo.find()._addSpecial( "$query" : {x : {$lt : 5}} )"), does not work at all ... it gets an error from the shell ("SyntaxError: missing ) after argument list (shell):1"). There is no JavaScript syntax that lets you pass a function "$query":{}. A "more correct" version of this usage would be 'db.tmp.find()._addSpecial("$query", {"title":2})'. This also doesn't work but is at least syntactically correct. The actual trouble in the "more correct" version is that the initial query (which is nothing in this case, the contents of the () in the find() part) is repackaged as "query" and then "$query" is appended. The original "query" takes precedence over the added "$query" and so the "$query" is not used. A "fully correct" version of this is 'db.tmp.find()._addSpecial("query", {"title":2})', where "query" is used instead of "$query". This actually works. It's not a very exciting feature, but it works. Since this is now undocumented and is harmless and works if used correctly, I don't think this needs "fixing". | |||
| Comment by Uladzimir Mihura [ 14/Dec/11 ] | |||
|
Ok Guys, Thank you. So looks like this issue can be closed. -vova | |||
| Comment by Eliot Horowitz (Inactive) [ 30/Nov/11 ] | |||
|
This is not supposed to work - I updated the documentation. | |||
| Comment by Uladzimir Mihura [ 30/Nov/11 ] | |||
|
The following code not working too:
-vova | |||
| Comment by Uladzimir Mihura [ 30/Nov/11 ] | |||
|
I can see similar behavior for a Java driver. |