Skip to content

Commit 8dde6cc

Browse files
committed
separator for group_concat for mysql cannot be parametrized
1 parent 49a57d2 commit 8dde6cc

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/Persistence/Sql/Mysql/Query.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ class Query extends BaseQuery
1818

1919
public function groupConcat($field, string $delimiter = ',')
2020
{
21-
return $this->expr('group_concat({} separator [])', [$field, $delimiter]);
21+
return $this->expr('group_concat({} separator \'' . str_replace('\'', '\'\'', $delimiter) . '\')', [$field]);
2222
}
2323
}

tests/Persistence/Sql/QueryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ public function testGroupConcatException(): void
10821082
public function testGroupConcat(): void
10831083
{
10841084
$q = new Mysql\Query();
1085-
$this->assertSame('group_concat(`foo` separator :a)', $q->groupConcat('foo', '-')->render()[0]);
1085+
$this->assertSame('group_concat(`foo` separator \'-\')', $q->groupConcat('foo', '-')->render()[0]);
10861086

10871087
$q = new Oracle\Query();
10881088
$this->assertSame('listagg("foo", :a) within group (order by "foo")', $q->groupConcat('foo', '-')->render()[0]);

tests/Persistence/Sql/RandomTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function _groupConcatTest(string $expected, Query $q): void
8888
public function testGroupConcat(): void
8989
{
9090
$this->_groupConcatTest(
91-
'select `age`, group_concat(`name` separator :a) from `people` group by `age`',
91+
'select `age`, group_concat(`name` separator \',\') from `people` group by `age`',
9292
new Mysql\Query()
9393
);
9494

0 commit comments

Comments
 (0)