summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-16 09:07:32 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-04-16 09:14:29 +0000
commit02142010084173655296a5bd973910a9cf582579 (patch)
treecc3ea16fcaccfb54918916ffc84504aa72cddb09 /lib/public
parenta0472937afe0c28984fe8f7410eef156c326a156 (diff)
downloadnextcloud-server-02142010084173655296a5bd973910a9cf582579.tar.gz
nextcloud-server-02142010084173655296a5bd973910a9cf582579.zip
Fix constraint violation detection in QB Mapper
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/AppFramework/Db/QBMapper.php9
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;
}
}