Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-16 10:07:32 +0300
committerJoas Schilling <coding@schilljs.com>2021-04-16 11:12:17 +0300
commit25d11b5197ee529b6e3b8d1d0d338f3c5db9088c (patch)
tree457de35282c7ad7071ef8bc2368d3b6d55d1fa7b /lib/public
parent07278ed57d6997f34be35141ed5fa10dc6ee353a (diff)
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 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;
}
}