diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index ac0d5bdd6..18087ddd0 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -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; diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index b1074cbc5..c55c76149 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -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__); + } } \ No newline at end of file