Signed-off-by: Joas Schilling <coding@schilljs.com>
namespace OCP\AppFramework\Db;
-use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
+use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
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;
}
}