Ticket Details

MongoDB - find() conditions for $in - do not automatically convert id strings to mongodb id's

RFC Ticket (closed)

###What happened:
$ids = array(id string, id string, id string);
Model::find('conditions' => array(Model::key() => $ids));

That will not return any results. However,
$id = array(mongoid object, mongoid object, mongoid object);
Model::find('conditions' => array(Model::key() => $ids));

Will return the results as expected using $in.

###What was expected:
The MongoDb class -I would- (maybe not everyone) expect to convert the string id's automatically rather than having to run new MongoId() on each string before making the query. Something perhaps like the _toMongoId() method.

This is not a huge deal, but is especially handy for situations where multiple database types are to be used or if one day the code needs to run using MySQL isntead. Where Model::key() keeps us ambiguous for the MongoDB's _id primary key and any MySQL primary key (usually id), this "IN()" / "$in" find condition key is not database agnostic.

on 07.19.10 reported by: tom_m owned by: nate

Updates

(fixed) on 10.02.10 by nate
  • owner was changed to nate
  • status was changed to closed
  • resolution was changed to fixed
Fixed in x-data. Thanks Tom.