We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0aed3ec + affe972 commit ab233d5Copy full SHA for ab233d5
lib/public/AppFramework/Db/QBMapper.php
@@ -30,7 +30,7 @@
30
31
namespace OCP\AppFramework\Db;
32
33
-use OCP\DB\Exception;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
34
use OCP\DB\QueryBuilder\IQueryBuilder;
35
use OCP\IDBConnection;
36
@@ -162,11 +162,8 @@ public function insert(Entity $entity): Entity {
162
public function insertOrUpdate(Entity $entity): Entity {
163
try {
164
return $this->insert($entity);
165
- } catch (Exception $ex) {
166
- if ($ex->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
167
- return $this->update($entity);
168
- }
169
- throw $ex;
+ } catch (UniqueConstraintViolationException $ex) {
+ return $this->update($entity);
170
}
171
172
0 commit comments