diff options
-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 72373ba26c3..fb5215895a2 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; } } |