Skip to content

Commit 5bfcf16

Browse files
author
Ilija Tovilo
committed
[Translatable] Fix replacement of last group by element
Some Sql vendors (like Sql Server) require every selected element to be in the group by clause. Because the translation walker adds additional columns, those columns must be added to the group by as well. The regex was incorrect and did not replace the very last element in the group by clause.
1 parent 9ee1c35 commit 5bfcf16

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Gedmo/Translatable/Query/TreeWalker/TranslationWalker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ private function getTranslatableListener()
428428
private function replace(array $repl, $str)
429429
{
430430
foreach ($repl as $target => $result) {
431-
$str = preg_replace_callback('/(\s|\()('.$target.')(,?)(\s|\))/smi', function ($m) use ($result) {
431+
$str = preg_replace_callback('/(\s|\()('.$target.')(,?)(\s|\)|$)/smi', function ($m) use ($result) {
432432
return $m[1].$result.$m[3].$m[4];
433433
}, $str);
434434
}

0 commit comments

Comments
 (0)