diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-06-30 15:38:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-30 15:38:11 +0300 |
commit | affe97235dba25204782783f96bc9d0ef1f4f4d1 (patch) | |
tree | da59e2f2d7bdf954e378b817ce181048e97ca87d /lib/public/AppFramework | |
parent | e76b83393cf95c0ac97850f9487ab3ddc7bf604b (diff) |
Revert "[stable21] Fix constraint violation detection in QB Mapper"
Diffstat (limited to 'lib/public/AppFramework')
-rw-r--r-- | lib/public/AppFramework/Db/QBMapper.php | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index 42b21f8f4b8..d9cd513e5e9 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 OCP\DB\Exception; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -162,11 +162,8 @@ abstract class QBMapper { public function insertOrUpdate(Entity $entity): Entity { try { return $this->insert($entity); - } catch (Exception $ex) { - if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) { - return $this->update($entity); - } - throw $ex; + } catch (UniqueConstraintViolationException $ex) { + return $this->update($entity); } } |