Skip to content

Commit

Permalink
Throw our own exception in \OCP\DB\QueryBuilder\IQueryBuilder::execute
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ChristophWurst committed Mar 17, 2021
1 parent 7a09b7d commit afffc0c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Query\QueryException;
use OC\DB\ConnectionAdapter;
use OC\DB\Exceptions\DbalException;
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder;
Expand All @@ -47,6 +48,7 @@
use OC\DB\QueryBuilder\FunctionBuilder\SqliteFunctionBuilder;
use OC\DB\ResultAdapter;
use OC\SystemConfig;
use OCP\DB\Exception;
use OCP\DB\IResult;
use OCP\DB\QueryBuilder\ICompositeExpression;
use OCP\DB\QueryBuilder\ILiteral;
Expand Down Expand Up @@ -200,6 +202,7 @@ public function getState() {
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements.
*
* @throws Exception since 21.0.0
* @return IResult|int
*/
public function execute() {
Expand Down Expand Up @@ -284,7 +287,11 @@ public function execute() {
]);
}

$result = $this->queryBuilder->execute();
try {
$result = $this->queryBuilder->execute();
} catch (\Doctrine\DBAL\Exception $e) {
throw DbalException::wrap($e);
}
if (is_int($result)) {
return $result;
}
Expand Down

0 comments on commit afffc0c

Please sign in to comment.