From aa72619c5da16339f79f7b612c2cfb903b7bd224 Mon Sep 17 00:00:00 2001 From: romanb Date: Wed, 28 Oct 2009 11:29:29 +0000 Subject: [PATCH] [2.0][DDC-55] Fixed. --- lib/Doctrine/ORM/AbstractQuery.php | 4 ++++ lib/Doctrine/ORM/Query/QueryException.php | 5 +++++ tests/Doctrine/Tests/ORM/Functional/QueryTest.php | 9 +++++++++ 3 files changed, 18 insertions(+) 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() {