1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Merge pull request #849 from bsahlhof/master

Error with Same Field, Multiple Values, Criteria and QueryBuilder
This commit is contained in:
Guilherme Blanco 2013-11-25 21:20:14 -08:00
commit 0e3c57dbd3
2 changed files with 21 additions and 2 deletions

View File

@ -127,6 +127,14 @@ class QueryExpressionVisitor extends ExpressionVisitor
public function walkComparison(Comparison $comparison)
{
$parameterName = str_replace('.', '_', $comparison->getField());
foreach($this->parameters as $parameter) {
if($parameter->getName() === $parameterName) {
$parameterName .= '_' . count($this->parameters);
break;
}
}
$parameter = new Parameter($parameterName, $this->walkValue($comparison->getValue()));
$placeholder = ':' . $parameterName;

View File

@ -411,6 +411,17 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
$this->assertNotNull($qb->getParameter('field'));
}
public function testAddMultipleSameCriteriaWhere()
{
$qb = $this->_em->createQueryBuilder();
$criteria = new Criteria();
$criteria->where($criteria->expr()->andX($criteria->expr()->eq('field', 'value1'), $criteria->expr()->eq('field', 'value2')));
$qb->addCriteria($criteria);
$this->assertEquals('field = :field AND field = :field_1', (string) $qb->getDQLPart('where'));
$this->assertNotNull($qb->getParameter('field'));
$this->assertNotNull($qb->getParameter('field_1'));
}
public function testAddCriteriaOrder()
{
$qb = $this->_em->createQueryBuilder();