Compare commits

...

1 Commits

Author SHA1 Message Date
Christoph Wurst 57f901170b
Throw our own exception in \OCP\DB\QueryBuilder\IQueryBuilder::execute
Just as documented. This seems to be a leftover form the dbal changes in
21. We noticed that `execute` still throws the raw dbal exception and
catches for the documented execption never trigger.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2021-06-02 18:18:33 +02:00
2 changed files with 9 additions and 9 deletions

View File

@ -31,14 +31,7 @@ use OCP\IDBConnection;
use OCP\UserStatus\IUserStatus; use OCP\UserStatus\IUserStatus;
/** /**
* Class UserStatusMapper * @template-extends QBMapper<UserStatus>
*
* @package OCA\UserStatus\Db
*
* @method UserStatus insert(UserStatus $entity)
* @method UserStatus update(UserStatus $entity)
* @method UserStatus insertOrUpdate(UserStatus $entity)
* @method UserStatus delete(UserStatus $entity)
*/ */
class UserStatusMapper extends QBMapper { class UserStatusMapper extends QBMapper {

View File

@ -36,6 +36,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Query\QueryException; use Doctrine\DBAL\Query\QueryException;
use OC\DB\ConnectionAdapter; use OC\DB\ConnectionAdapter;
use OC\DB\Exceptions\DbalException;
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder;
@ -47,6 +48,7 @@ use OC\DB\QueryBuilder\FunctionBuilder\PgSqlFunctionBuilder;
use OC\DB\QueryBuilder\FunctionBuilder\SqliteFunctionBuilder; use OC\DB\QueryBuilder\FunctionBuilder\SqliteFunctionBuilder;
use OC\DB\ResultAdapter; use OC\DB\ResultAdapter;
use OC\SystemConfig; use OC\SystemConfig;
use OCP\DB\Exception;
use OCP\DB\IResult; use OCP\DB\IResult;
use OCP\DB\QueryBuilder\ICompositeExpression; use OCP\DB\QueryBuilder\ICompositeExpression;
use OCP\DB\QueryBuilder\ILiteral; use OCP\DB\QueryBuilder\ILiteral;
@ -200,6 +202,7 @@ class QueryBuilder implements IQueryBuilder {
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate} * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements. * for insert, update and delete statements.
* *
* @throws Exception since 21.0.0
* @return IResult|int * @return IResult|int
*/ */
public function execute() { public function execute() {
@ -284,7 +287,11 @@ class QueryBuilder implements IQueryBuilder {
]); ]);
} }
try {
$result = $this->queryBuilder->execute(); $result = $this->queryBuilder->execute();
} catch (\Doctrine\DBAL\Exception $e) {
throw DbalException::wrap($e);
}
if (is_int($result)) { if (is_int($result)) {
return $result; return $result;
} }