diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 971f0f1bc..f40ec6762 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -459,6 +459,10 @@ abstract class AbstractQuery } $params = $this->getParameters($params); + + if (isset($params[0])) { + throw QueryException::invalidParameterPosition(0); + } // Check result cache if ($this->_useResultCache && $cacheDriver = $this->getResultCacheDriver()) { diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index a2bc4dc6f..2663b09dd 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -44,4 +44,9 @@ class QueryException extends \Doctrine\Common\DoctrineException { return new self('[Semantical Error] ' . $message); } + + public static function invalidParameterPosition($pos) + { + return new self('Invalid parameter position: ' . $pos); + } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 7c7216ab5..4bf1cad54 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -19,6 +19,15 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->useModelSet('cms'); parent::setUp(); } + + /** + * @expectedException Doctrine\ORM\Query\QueryException + */ + public function testParameterIndexZeroThrowsException() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position + } public function testSimpleQueries() {