Ticket Details
Model::find($id) doesn't work for MongoDB
BUG Ticket (closed)
###What happened:
I try to load a document via its _id from MongoDB:
{{{
$manufacturer = Manufacturer::find('first', array(
'conditions' => array('_id' => $id),
));
}}}
$id is a String, containing a ID (e.g. "4b9b7b408ead0e19bc000000"). A document with this ID exists in the Mongo Collection.
The find method returns null.
Mongo's log output:
{{{
Sat Mar 20 10:26:26 connection accepted from 127.0.0.1:52531 #9
Sat Mar 20 10:26:26 runQuery: bt_dev.manufacturers{ query: { _id: ObjId(4b9b7b408ead0e19bc000000) }, orderby: {} }
Sat Mar 20 10:26:26 run command bt_dev.manufacturers { query: { _id: ObjId(4b9b7b408ead0e19bc000000) }, orderby: {} }
Sat Mar 20 10:26:26 query bt_dev.manufacturers ntoreturn:1 reslen:36 nreturned:0 0ms
Sat Mar 20 10:26:26 end connection 127.0.0.1:52531
}}}
###What was expected:
The find method should return the Document identified by its ID.
###My workaround:
If I comment out this line
{{{
$conditions = $this->_toMongoId($conditions);
}}}
in MongoDb::conditions() (Line 353 in MongoDb.php) I get the document as expected. Mongo's log output is now:
{{{
Sat Mar 20 10:29:01 connection accepted from 127.0.0.1:52586 #11
Sat Mar 20 10:29:01 runQuery: bt_dev.manufacturers{ query: { _id: "4b9b7b408ead0e19bc000000" }, orderby: {} }
Sat Mar 20 10:29:01 run command bt_dev.manufacturers { query: { _id: "4b9b7b408ead0e19bc000000" }, orderby: {} }
Sat Mar 20 10:29:01 query bt_dev.manufacturers ntoreturn:1 reslen:120 nreturned:1 12ms
Sat Mar 20 10:29:01 end connection 127.0.0.1:52586
}}}
Updates
(wont-fix)
on 03.21.10
by nate
- owner was changed to nate
- status was changed to closed
- resolution was changed to wont-fix