Skip to content

Commit

Permalink
Prevent * and other things in the same query for Oracle
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Dec 14, 2020
1 parent 5fc20e8 commit 5828f3c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Query\QueryException;
use OC\DB\OracleConnection;
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder;
Expand Down Expand Up @@ -223,6 +224,26 @@ public function execute() {
}
}

if (!empty($this->getQueryPart('select'))) {
$select = $this->getQueryPart('select');
$hasSelectAll = array_filter($select, static function ($s) {
return $s === '*';
});
$hasSelectSpecific = array_filter($select, static function ($s) {
return $s !== '*';
});

if (empty($hasSelectAll) === empty($hasSelectSpecific)) {
$exception = new QueryException('Query is selecting * and specific values in the same query. This is not supported in Oracle.');
$this->logger->logException($exception, [
'message' => 'Query is selecting * and specific values in the same query. This is not supported in Oracle.',
'query' => $this->getSQL(),
'level' => ILogger::ERROR,
'app' => 'core',
]);
}
}

return $this->queryBuilder->execute();
}

Expand Down

0 comments on commit 5828f3c

Please sign in to comment.