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 Jun 2, 2021
1 parent c1d359b commit 57f9011
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 1 addition & 8 deletions apps/user_status/lib/Db/UserStatusMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@
use OCP\UserStatus\IUserStatus;

/**
* Class UserStatusMapper
*
* @package OCA\UserStatus\Db
*
* @method UserStatus insert(UserStatus $entity)
* @method UserStatus update(UserStatus $entity)
* @method UserStatus insertOrUpdate(UserStatus $entity)
* @method UserStatus delete(UserStatus $entity)
* @template-extends QBMapper<UserStatus>
*/
class UserStatusMapper extends QBMapper {

Expand Down
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 57f9011

Please sign in to comment.