[SERVER-11972] $gt and $lt do not combine with some syntax in mongodb shell Created: 05/Dec/13 Updated: 05/Dec/13 Resolved: 05/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | William Cross | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongodb 2.4.8 |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
If I use $lt and $gt on the same variable twice in a find() call, it only uses the last one. This is a problem because we should use all information in a find() call. Steps to reproduce > db.scores.drop() ) } } You now have 300 documents in the 'scores' collection, with 'score' values ranging from 1-100, an average of 3 per score. Input the following query: > db.scores.find({score: {$gt: 50} , score: {$lt: 60}}).count() Expected result Actual result There are ways to do this query correctly, such as > db.scores.find( { score : { $gt : 50 , $lt : 60 }} ).count( ) but the way described above should work, too. |
| Comments |
| Comment by Scott Hernandez (Inactive) [ 05/Dec/13 ] | ||
|
What you are describing is how javascript object/dicts work (in fact most languages have this behavior in their map/dict/hash impls):
You cannot have repeated fields of the same name at the same level. |