[SERVER-6868] prevent use of positional projection with a simple _id query; assert if a positional projection is requested and no match details are supplied Created: 27/Aug/12  Updated: 20/Feb/15  Resolved: 20/Feb/15

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

Type: Bug Priority: Minor - P4
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File server6868.js    
Issue Links:
Duplicate
duplicates SERVER-10026 New query system Closed
Related
is related to SERVER-6865 positional operator projection does n... Closed
Operating System: ALL
Participants:

 Description   

Observed behavior: A simple query on _id with a positional operator projection on another field returns an incorrect result based on a missing positional match.
Expected behavior: Same behavior as if it is not a simple query on _id and there is no query field matching the positional operator - uassert.

Test

c = db.c;
c.drop();
 
c.save( { _id:0, a:[ 1, 2 ] } );
 
// Throws error.
c.find( {}, { 'a.$':1 } ).toArray();
 
// Should throw but instead returns a result I think is incorrect.
printjson( c.find( { _id:0 }, { 'a.$':1 } ).toArray() );

We should also ensure that in cases where a positional operator is used, a match details is always available. We could check this with an assertion.



 Comments   
Comment by J Rassi [ 20/Feb/15 ]

Verified that this is fixed in 2.6.0. Closing as dup of SERVER-10026.

Comment by David Storch [ 11/Nov/13 ]

Attaching a js test for easy repro

Comment by Aaron Staple [ 27/Aug/12 ]

Tentatively assigning to planning bucket a.

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