From fc98f26371d30021a5939cc76adef6fde0db503a Mon Sep 17 00:00:00 2001 From: beberlei Date: Sat, 21 Nov 2009 12:33:30 +0000 Subject: [PATCH] DDC-127 - Commit missing changes to Query Error handling which make testsuite fail. --- lib/Doctrine/ORM/Query.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 5c3f4831a..9575ed703 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -207,7 +207,16 @@ final class Query extends AbstractQuery $sqlParams = array(); $paramMappings = $this->_parserResult->getParameterMappings(); + + if(count($paramMappings) != count($params)) { + throw new QueryException("Invalid parameter number: number of bound variables does not match number of tokens"); + } + foreach ($params as $key => $value) { + if(!isset($paramMappings[$key])) { + throw new QueryException("Invalid parameter: token ".$key." is not defined in the query."); + } + if (is_object($value)) { $values = $this->_em->getClassMetadata(get_class($value))->getIdentifierValues($value); $sqlPositions = $paramMappings[$key];