[SERVER-2330] order of keys is matters in hashes, in find, similar object gives different results on different queries. Created: 05/Jan/11 Updated: 17/Mar/11 Resolved: 05/Jan/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 1.6.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Shimon Doodkin | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 10 server 64bit |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
I cant expect programmers to remember the order in all places in the code especially in large code base. db.eventstatus.insert( ] db.eventstatus.insert({ ] db.eventstatus.find({"t12_status":{"status":"coming","invite":ObjectId("4d208cdb50e82e8f65000002"),"value":1}}); //expected: both queries will return the 2 documents. - wanted |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 05/Jan/11 ] |
|
That is what $elemMatch is for. |
| Comment by Shimon Doodkin [ 05/Jan/11 ] |
|
then this test fails: db.eventstatus.drop(); , { "status": "ride", "invite": ObjectId("4d208cdb50e82e8f65000002"), "value": 1 } ] db.eventstatus.find( {"t12_status.status":"coming","t12_status.invite":ObjectId("4d208cdb50e82e8f65000002"),"t12_status.value":1}); { "_id" : ObjectId("4d2093d0aaed39b6d9716b1d"), "t12_status" : [ , { "status" : "ride", "invite" : ObjectId("4d208cdb50e82e8f65000002"), "value" : 1 }] } it returns incorrectly a document with no { "status" : "coming", "invite" : ObjectId("4d208cdb50e82e8f65000002"), "value" : 1 }in the t12_status array |
| Comment by Eliot Horowitz (Inactive) [ 05/Jan/11 ] |
|
BSON is ordered. If you don't care about order, you can query using { "a.b" : 1 , "a.c" : 1 }style |
| Comment by Shimon Doodkin [ 05/Jan/11 ] |
|
I could not find in my code where the order is switched. |