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)
|
public function walkComparison(Comparison $comparison)
|
||||||
{
|
{
|
||||||
$parameterName = str_replace('.', '_', $comparison->getField());
|
$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()));
|
$parameter = new Parameter($parameterName, $this->walkValue($comparison->getValue()));
|
||||||
$placeholder = ':' . $parameterName;
|
$placeholder = ':' . $parameterName;
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id'
|
'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testComplexInnerJoinWithIndexBy()
|
public function testComplexInnerJoinWithIndexBy()
|
||||||
{
|
{
|
||||||
$qb = $this->_em->createQueryBuilder()
|
$qb = $this->_em->createQueryBuilder()
|
||||||
@ -153,7 +153,7 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$qb,
|
$qb,
|
||||||
'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INDEX BY a.name ON u.id = a.author_id'
|
'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INDEX BY a.name ON u.id = a.author_id'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLeftJoin()
|
public function testLeftJoin()
|
||||||
{
|
{
|
||||||
@ -411,6 +411,17 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertNotNull($qb->getParameter('field'));
|
$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()
|
public function testAddCriteriaOrder()
|
||||||
{
|
{
|
||||||
$qb = $this->_em->createQueryBuilder();
|
$qb = $this->_em->createQueryBuilder();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user