[MODM-164] DocumentPersister's prepareQuery() method is not suitable for preparing newObj for update queries Created: 05/Apr/12  Updated: 05/Apr/12

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Juha Suni Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


Doctrine\ODM\MongoDB\Query\Expr::getNewObj() uses Doctrine\ODM\MongoDB\Persisters\DocumentPersister::prepareQuery() method for preparing newObj. However, prepareQuery is not suitable for that.

The first lines in prepareQuery method should apply to find queries only:

if (is_scalar($query) || $query instanceof \MongoId) {
$query = array('_id' => $query);
if ($this->class->hasDiscriminator() && ! isset($query[$this->class->discriminatorField['name']])) {
$discriminatorValues = $this->getClassDiscriminatorValues($this->class);
$query[$this->class->discriminatorField['name']] = array('$in' => $discriminatorValues);

Recommendation: DocumentPersister should introduce a new method, such as prepareNewObj($newObj) for preparing the newObj array. Expr::getNewObj() should be change to invoke the new method.

Generated at Tue Dec 01 07:56:40 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.