diff options
author | Joas Schilling <coding@schilljs.com> | 2021-04-16 09:07:32 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-04-16 10:12:17 +0200 |
commit | 25d11b5197ee529b6e3b8d1d0d338f3c5db9088c (patch) | |
tree | 457de35282c7ad7071ef8bc2368d3b6d55d1fa7b /lib | |
parent | 07278ed57d6997f34be35141ed5fa10dc6ee353a (diff) | |
download | nextcloud-server-25d11b5197ee529b6e3b8d1d0d338f3c5db9088c.tar.gz nextcloud-server-25d11b5197ee529b6e3b8d1d0d338f3c5db9088c.zip |
Fix constraint violation detection in QB Mapper
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Db/QBMapper.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index 3fc7942c0dd..ac6520a9d03 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -30,7 +30,7 @@ declare(strict_types=1); namespace OCP\AppFramework\Db; -use Doctrine\DBAL\Exception\UniqueConstraintViolationException; +use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -157,8 +157,11 @@ abstract class QBMapper { public function insertOrUpdate(Entity $entity): Entity { try { return $this->insert($entity); - } catch (UniqueConstraintViolationException $ex) { - return $this->update($entity); + } catch (Exception $ex) { + if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) { + return $this->update($entity); + } + throw $ex; } } |