[SERVER-2367] Object.property doesn't work with ObjectId in querying Created: 17/Jan/11  Updated: 17/Mar/11  Resolved: 17/Jan/11

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.6.5
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Xiang.Song Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu php 5.3.3 php-mongo 1.10 mongodb 1.6.5-stable


Operating System: Linux
Participants:

 Description   

Querying an document like {str: 'something', obj: {sub1: ObjectId('123'), sub2: 456}} returns nothing while pure strings or integers works well

Mon Jan 17 19:01:06 [conn2349] query: gaoren.test

{ obj.sub1: ObjectId('4d3421722973eb6246140000') }

Mon Jan 17 19:01:06 [conn2349] used cursor: 0x15de360
Mon Jan 17 19:01:06 [conn2349] query gaoren.test reslen:36 nreturned:0 0ms

Mon Jan 17 19:01:06 [conn2349] query: gaoren.test

{ obj.sub2: 456 }

Mon Jan 17 19:01:06 [conn2349] used cursor: 0x168a5c0
Mon Jan 17 19:01:06 [conn2349] query gaoren.test reslen:115 nreturned:1 0ms

Mon Jan 17 19:01:06 [conn2349] query: gaoren.test{ obj: { $elemMatch:

{ sub1: ObjectId('4d3421722973eb6246150000'), sub2: 456 }

} }
Mon Jan 17 19:01:06 [conn2349] used cursor: 0x15d1720
Mon Jan 17 19:01:06 [conn2349] query gaoren.test reslen:36 nreturned:0 0ms



 Comments   
Comment by Eliot Horowitz (Inactive) [ 17/Jan/11 ]

Seems to work fine for me:

)
ObjectId("4d34a7feec5855af36e5448a")
> db.foo.insert( { str : "some string" , obj :

{ sub1 : x , sub2 : 456 }

} )
> db.foo.findOne()
{
"_id" : ObjectId("4d34a806ec5855af36e5448b"),
"str" : "some string",
"obj" :

{ "sub1" : ObjectId("4d34a7feec5855af36e5448a"), "sub2" : 456 }

}
> db.foo.find(

{ "obj.sub1" : ObjectId("4d34a7feec5855af36e5448a") }

)
{ "_id" : ObjectId("4d34a806ec5855af36e5448b"), "str" : "some string", "obj" :

{ "sub1" : ObjectId("4d34a7feec5855af36e5448a"), "sub2" : 456 }

}
>

Can you provide a full non-working example. The snippet you send it not full.

Comment by Xiang.Song [ 17/Jan/11 ]

This problem occurs occasionally right after updating.

Generated at Thu Feb 08 02:59:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.