From 33888f1b084c24d3c209888d5c70f5d2c9f4c043 Mon Sep 17 00:00:00 2001 From: Vladislav Vlastovskiy Date: Thu, 9 May 2013 03:30:48 +0400 Subject: [PATCH 1/2] Swapped places indexBy and condition in accordance with EBNF --- lib/Doctrine/ORM/Query/Expr/Join.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Expr/Join.php b/lib/Doctrine/ORM/Query/Expr/Join.php index c7ca935eb..7a59e247a 100644 --- a/lib/Doctrine/ORM/Query/Expr/Join.php +++ b/lib/Doctrine/ORM/Query/Expr/Join.php @@ -139,7 +139,7 @@ class Join { return strtoupper($this->joinType) . ' JOIN ' . $this->join . ($this->alias ? ' ' . $this->alias : '') - . ($this->condition ? ' ' . strtoupper($this->conditionType) . ' ' . $this->condition : '') - . ($this->indexBy ? ' INDEX BY ' . $this->indexBy : ''); + . ($this->indexBy ? ' INDEX BY ' . $this->indexBy : '') + . ($this->condition ? ' ' . strtoupper($this->conditionType) . ' ' . $this->condition : ''); } } From 3997d0df8782927e38dd2bf8bf263c4832bb1d6f Mon Sep 17 00:00:00 2001 From: Vladislav Vlastovskiy Date: Thu, 9 May 2013 03:32:28 +0400 Subject: [PATCH 2/2] Added test complex inner join with indexBy --- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 19e0c0e95..6975c1510 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -141,6 +141,19 @@ 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' ); } + + public function testComplexInnerJoinWithIndexBy() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'a') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->innerJoin('u.articles', 'a', 'ON', 'u.id = a.author_id', 'a.name'); + + $this->assertValidQueryBuilder( + $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' + ); + } public function testLeftJoin() {