Skip to content

Commit ce620a6

Browse files
committed
Mysql Use str_ends_with
1 parent 6c651e7 commit ce620a6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Database/Adapter/MariaDB.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,10 +1798,8 @@ protected function processException(PDOException $e): \Exception
17981798

17991799
// Duplicate row
18001800
if ($e->getCode() === '23000' && isset($e->errorInfo[1]) && $e->errorInfo[1] === 1062) {
1801-
if (preg_match("/for key '(?:[^.]+\.)?([^']+)'/", $e->getMessage(), $matches)) {
1802-
if ($matches[1] === '_uid') {
1803-
return new DuplicateException('Document already exists', $e->getCode(), $e);
1804-
}
1801+
if (str_ends_with($e->getMessage(), "._uid'")) {
1802+
return new DuplicateException('Document already exists', $e->getCode(), $e);
18051803
}
18061804

18071805
return new UniqueException('Document already exists', $e->getCode(), $e);

0 commit comments

Comments
 (0)