[DDC-604] Fixed.
This commit is contained in:
parent
5d00fb764b
commit
d6cb87a0ac
@ -244,7 +244,7 @@ final class Query extends AbstractQuery
|
||||
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) {
|
||||
$values = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
|
||||
$sqlPositions = $paramMappings[$key];
|
||||
$sqlParams = array_merge($sqlParams, array_combine((array)$sqlPositions, $values));
|
||||
$sqlParams += array_combine((array)$sqlPositions, $values);
|
||||
} else {
|
||||
foreach ($paramMappings[$key] as $position) {
|
||||
$sqlParams[$position] = $value;
|
||||
|
@ -281,4 +281,34 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->_em->getConfiguration()->setEntityNamespaces(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-604
|
||||
*/
|
||||
public function testEntityParameters()
|
||||
{
|
||||
$article = new CmsArticle;
|
||||
$article->topic = "dr. dolittle";
|
||||
$article->text = "Once upon a time ...";
|
||||
$author = new CmsUser;
|
||||
$author->name = "anonymous";
|
||||
$author->username = "anon";
|
||||
$author->status = "here";
|
||||
$article->user = $author;
|
||||
$this->_em->persist($author);
|
||||
$this->_em->persist($article);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
|
||||
$q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a where a.topic = :topic and a.user = :user")
|
||||
->setParameter("user", $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $author->id))
|
||||
->setParameter("topic", "dr. dolittle");
|
||||
|
||||
$result = $q->getResult();
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertTrue($result[0] instanceof CmsArticle);
|
||||
$this->assertEquals("dr. dolittle", $result[0]->topic);
|
||||
$this->assertTrue($result[0]->user instanceof \Doctrine\ORM\Proxy\Proxy);
|
||||
$this->assertFalse($result[0]->user->__isInitialized__);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user