diff --git a/src/Persistence/Sql/Mysql/Query.php b/src/Persistence/Sql/Mysql/Query.php index 04c5f484e..8fe90afcd 100644 --- a/src/Persistence/Sql/Mysql/Query.php +++ b/src/Persistence/Sql/Mysql/Query.php @@ -21,15 +21,13 @@ class Query extends BaseQuery protected function _renderConditionRegexpOperator(bool $negated, string $sqlLeft, string $sqlRight): string { $serverVersion = $this->connection->getConnection()->getWrappedConnection()->getServerVersion(); // @phpstan-ignore-line - if (str_contains($serverVersion, 'MariaDB')) { - return $sqlLeft . ($negated ? ' not' : '') . ' regexp concat(' - . $this->escapeStringLiteral('(?s)') . ', ' . $sqlRight . ')'; - } elseif (str_starts_with($serverVersion, '5.')) { - return $sqlLeft . ($negated ? ' not' : '') . ' regexp ' . $sqlRight; - } - - return ($negated ? 'not ' : '') . 'regexp_like(' . $sqlLeft . ', ' . $sqlRight - . ', ' . $this->escapeStringLiteral('in') . ')'; + $isMysql5x = str_starts_with($serverVersion, '5.') && !str_contains($serverVersion, 'MariaDB'); + + return $sqlLeft . ($negated ? ' not' : '') . ' regexp ' . ( + $isMysql5x + ? $sqlRight + : 'concat(' . $this->escapeStringLiteral('(?s)') . ', ' . $sqlRight . ')' + ); } #[\Override]