mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
Fix constraint violation detection in QB Mapper
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
a0472937af
commit
0214201008
1 changed files with 6 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue