Skip to content

Commit af72c4a

Browse files
Adam van Reijswoudstevelacey
authored andcommitted
Fixed exception that is thrown when combining the sqlite CONCAT_WS extension with a LimitSubqueryOutputWalker
1 parent fccc6a9 commit af72c4a

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Query/Sqlite/ConcatWs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public function parse(\Doctrine\ORM\Query\Parser $parser)
5555

5656
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
5757
{
58-
$separator = array_shift($this->values)->simpleArithmeticExpression->value;
58+
$separator = $this->values[0]->simpleArithmeticExpression->value;
5959

6060
// Create an array to hold the query elements.
6161
$queryBuilder = ['('];
6262

6363
// Iterate over the captured expressions and add them to the query.
64-
for ($i = 0; $i < count($this->values); $i++) {
65-
if ($i > 0) {
64+
for ($i = 1; $i < count($this->values); $i++) {
65+
if ($i > 1) {
6666
$queryBuilder[] = " || '${separator}' || ";
6767
}
6868

tests/Query/Sqlite/ConcatWsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace DoctrineExtensions\Tests\Query\Sqlite;
4+
5+
use DoctrineExtensions\Tests\Query\SqliteTestCase;
6+
7+
class ConcatWsTest extends SqliteTestCase
8+
{
9+
public function testConcatWs()
10+
{
11+
$dql = "SELECT CONCAT_WS(',', p.id, p.name) FROM DoctrineExtensions\\Tests\\Entities\\Product p";
12+
13+
$this->assertEquals(
14+
"SELECT (IFNULL(p0_.id, '') || ',' || IFNULL(p0_.name, '')) AS {$this->columnAlias} FROM Product p0_",
15+
$this->entityManager->createQuery($dql)->getSql()
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)