Merge pull request #849 from bsahlhof/master
Error with Same Field, Multiple Values, Criteria and QueryBuilder
This commit is contained in:
commit
0e3c57dbd3
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user