doctrine/mongodb-odm — Issue #268: using $exists on Simple Referenced field gives random object id
Author: ulugbekenuygun
Created: 2012-03-06 16:00:11+00:00
State: open

What I am trying to do is

$filter = array();
$filter['open'] = true;
$filter['agent'] = array('$exists' => false);

...->('Project:Application')->findOneBy($filter);

agent field is a referenced to User collection in Application collection's Document

/**
* @MongoDB\ReferenceOne(targetDocument="Project\UserBundle\Document\User", simple=true)
*/
protected $agent;

Monolog's log seems as following:

[2012-03-06 17:57:17] doctrine.INFO: MongoDB query: { "find": true, "query": { "open": true,
"agent": ObjectId("4f5633dd9963a31d41000000") }, "fields": [ ], "db": "project", "collection": "Application" } [] []

[2012-03-06 17:57:17] doctrine.INFO: MongoDB query: { "limit": true, "limitNum": 1, "query": { "open": true, "agent": ObjectId("4f5633dd9963a31d41000000") }, "fields": [ ] } [] []

[2012-03-06 17:57:17] doctrine.INFO: MongoDB query: { "limit": true, "limitNum": 1, "query": { "open": true, "agent": ObjectId("4f5633dd9963a31d41000000") }, "fields": [ ] } [] []

As you see it gets ObjectId(), but when I use other fields which aren't referenced, $exists works all fine.