[SERVER-5276] Positional operator with multiple query parameters matching the same sub-document. Created: 09/Mar/12  Updated: 15/Aug/12  Resolved: 14/Mar/12

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

Type: Bug Priority: Minor - P4
Reporter: Kyle Banker Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

http://groups.google.com/group/mongodb-user/browse_thread/thread/594ecef659072978



 Comments   
Comment by Steve Green [ 14/Mar/12 ]

Thanks... I should have read the docs a bit more carefully (especially the sections about $elemMatch and dot notation.

Comment by Eliot Horowitz (Inactive) [ 14/Mar/12 ]

Ah - ok.
This is actually correct.
Doing matching like that is not a single doc, but a pair.
Pretty sure you want:

 
t = db.foo;
t.drop()
t.insert( { _id : 1 ,
            any : [
                { a : 1 , b : 0 } ,
                { a : 2 , b : 0 } ,
                { a : 3 , b : 0 } ,
                { a : 4 , b : 0 } ]
          } )
 
printjson( t.findOne() )
 
t.update( { _id : 1 , any : { $elemMatch : { a : 2 , b : 0 } } } , 
          { $set : { "any.$.b" : 1 } } )
 
printjson( t.findOne() )

Comment by Steve Green [ 13/Mar/12 ]

I just noticed that the Kyle linked to the wrong posting in google groups. It should be

http://groups.google.com/group/mongodb-user/browse_thread/thread/d53dd4c4d35ac88f

Hopefully this will make the problem clear...

Comment by Eliot Horowitz (Inactive) [ 13/Mar/12 ]

I'm not sure I understand the exact issue.

Steve - can you describe exactly what you can't do?

Comment by Steve Green [ 12/Mar/12 ]

I'm not sure that I would consider this a 'minor' bug in that it makes the positional operator unusable in cases where multiple fields in a sub-document are used in the query. I also don't believe there is an "easy workaround"...

Generated at Thu Feb 08 03:08:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.