Skip to content

Commit

Permalink
Merge c082938 into a250f14
Browse files Browse the repository at this point in the history
  • Loading branch information
ossinkine committed Feb 27, 2017
2 parents a250f14 + c082938 commit 5fda8f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/ODM/MongoDB/Query/Expr.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function references($document)
}

foreach ($keys as $key => $value) {
$this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key];
$this->query[$mapping['name'] . '.$' . $key] = $dbRef['$' . $key];
}
}
} else {
Expand Down Expand Up @@ -128,7 +128,7 @@ public function includesReferenceTo($document)
}

foreach ($keys as $key => $value) {
$this->query[$this->currentField]['$elemMatch']['$' . $key] = $dbRef['$' . $key];
$this->query[$mapping['name']]['$elemMatch']['$' . $key] = $dbRef['$' . $key];
}
}
} else {
Expand Down
12 changes: 6 additions & 6 deletions tests/Doctrine/ODM/MongoDB/Tests/Query/ExprTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ public function testReferencesUsesMinimalKeys()
->will($this->returnValue($expected));
$class->expects($this->once())
->method('getFieldMapping')
->will($this->returnValue(array('targetDocument' => 'Foo')));
->will($this->returnValue(array('targetDocument' => 'Foo', 'name' => 'foo')));

$expr = new Expr($dm);
$expr->setClassMetadata($class);
$expr->field('foo')->references(new \stdClass());
$expr->field('bar')->references(new \stdClass());

$this->assertEquals($expected, $expr->getQuery(), '->references() uses just $id if a targetDocument is set');
}
Expand Down Expand Up @@ -239,11 +239,11 @@ public function testReferencesUsesAllKeys()
->will($this->returnValue($expected));
$class->expects($this->once())
->method('getFieldMapping')
->will($this->returnValue(array()));
->will($this->returnValue(array('name' => 'foo')));

$expr = new Expr($dm);
$expr->setClassMetadata($class);
$expr->field('foo')->references(new \stdClass());
$expr->field('bar')->references(new \stdClass());

$this->assertEquals($expected, $expr->getQuery(), '->references() uses all keys if no targetDocument is set');
}
Expand Down Expand Up @@ -272,11 +272,11 @@ public function testReferencesUsesSomeKeys()
->will($this->returnValue($expected));
$class->expects($this->once())
->method('getFieldMapping')
->will($this->returnValue(array('storeAs' => ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF)));
->will($this->returnValue(array('storeAs' => ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF, 'name' => 'foo')));

$expr = new Expr($dm);
$expr->setClassMetadata($class);
$expr->field('foo')->references(new \stdClass());
$expr->field('bar')->references(new \stdClass());

$this->assertEquals($expected, $expr->getQuery(), '->references() uses some keys if storeAs=dbRef is set');
}
Expand Down

0 comments on commit 5fda8f8

Please sign in to comment.