diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index bd49e30ca..576c3a296 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -154,7 +154,7 @@ abstract class AbstractQuery public function getParameters($params = array()) { if ($params) { - return array_merge($this->_params, $params); + return ($this->_params + $params); } return $this->_params; } diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 816753ca5..2b20e1667 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -29,6 +29,19 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase $query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position } + public function testGetParameters() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $this->assertEquals(array(1 => 42), $query->getParameters(array(1 => 42))); + } + + public function testGetParameters_HasSomeAlready() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $query->setParameter(2, 84); + $this->assertEquals(array(2 => 84, 1 => 42), $query->getParameters(array(1 => 42))); + } + public function testSimpleQueries() { $user = new CmsUser;