[SERVER-7445] $in operator should require an array Created: 22/Oct/12  Updated: 11/Jul/16  Resolved: 17/May/13

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

Type: Improvement Priority: Major - P3
Reporter: Aaron Staple Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-6400 Refactor Matcher/QueryExpression Closed
is related to SERVER-7391 Parse bson queries into new MatchExpr... Closed
Participants:

 Description   

$in should take a list (array) of values. But it currently also accepts an object. An object should probably trigger a query parse error.

c = db.c;
c.drop();
 
c.save( { a:1 } );
c.save( { a:2 } );
c.save( { a:3 } );
 
// Works
printjson( c.find( { a:{ $in:[ 1, 3 ] } } ).toArray() );
// Works the same as the above line, but it should probably be uassert.
printjson( c.find( { a:{ $in:{ x:1, y:3 } } } ).toArray() );



 Comments   
Comment by auto [ 03/Jun/13 ]

Author:

{u'username': u'monkey101', u'name': u'Dan Pasette', u'email': u'dan@10gen.com'}

Message: SERVER-7445: add jstest for $in only takes an array
Branch: master
https://github.com/mongodb/mongo/commit/7652fb20c47fb3847a53bb2231ea23ee8e485623

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