Skip to content

Commit 50e897a

Browse files
authored
Merge pull request #26587 from nextcloud/backport/26581/stable21
[stable21] Fix constraint violation detection in QB Mapper
2 parents a047293 + 0214201 commit 50e897a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/public/AppFramework/Db/QBMapper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
namespace OCP\AppFramework\Db;
3232

33-
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
33+
use OCP\DB\Exception;
3434
use OCP\DB\QueryBuilder\IQueryBuilder;
3535
use OCP\IDBConnection;
3636

@@ -157,8 +157,11 @@ public function insert(Entity $entity): Entity {
157157
public function insertOrUpdate(Entity $entity): Entity {
158158
try {
159159
return $this->insert($entity);
160-
} catch (UniqueConstraintViolationException $ex) {
161-
return $this->update($entity);
160+
} catch (Exception $ex) {
161+
if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
162+
return $this->update($entity);
163+
}
164+
throw $ex;
162165
}
163166
}
164167

0 commit comments

Comments
 (0)