mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
fix(db)!: Empty and adjust query-part related methods
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
a5432e3c69
commit
de0141d83c
2 changed files with 45 additions and 21 deletions
|
|
@ -207,24 +207,24 @@ class QueryBuilder implements IQueryBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
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($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->error($exception->getMessage(), [
|
||||
'query' => $this->getSQL(),
|
||||
'app' => 'core',
|
||||
'exception' => $exception,
|
||||
]);
|
||||
}
|
||||
}
|
||||
// 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->error($exception->getMessage(), [
|
||||
// 'query' => $this->getSQL(),
|
||||
// 'app' => 'core',
|
||||
// 'exception' => $exception,
|
||||
// ]);
|
||||
// }
|
||||
//}
|
||||
|
||||
$numberOfParameters = 0;
|
||||
$hasTooLargeArrayParameter = false;
|
||||
|
|
@ -1096,18 +1096,20 @@ class QueryBuilder implements IQueryBuilder {
|
|||
* @param string $queryPartName
|
||||
*
|
||||
* @return mixed
|
||||
* @deprecated 30.0.0 The function always throws an exception
|
||||
*/
|
||||
public function getQueryPart($queryPartName) {
|
||||
return $this->queryBuilder->getQueryPart($queryPartName);
|
||||
throw new \Exception('Getting query parts is no longer supported as they are implementation details.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all query parts.
|
||||
*
|
||||
* @return array
|
||||
* @deprecated 30.0.0 The function always throws an exception
|
||||
*/
|
||||
public function getQueryParts() {
|
||||
return $this->queryBuilder->getQueryParts();
|
||||
throw new \Exception('Getting query parts is no longer supported as they are implementation details.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1116,9 +1118,20 @@ class QueryBuilder implements IQueryBuilder {
|
|||
* @param array|null $queryPartNames
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
* @since 30.0.0 Only null and a list of 'where'|'having'|'groupBy'|'orderBy' is supported. Everything else will throw.
|
||||
*/
|
||||
public function resetQueryParts($queryPartNames = null) {
|
||||
$this->queryBuilder->resetQueryParts($queryPartNames);
|
||||
if ($queryPartNames === null) {
|
||||
$this->queryBuilder->resetWhere();
|
||||
$this->queryBuilder->resetHaving();
|
||||
$this->queryBuilder->resetGroupBy();
|
||||
$this->queryBuilder->resetOrderBy();
|
||||
return $this;
|
||||
}
|
||||
|
||||
foreach ($queryPartNames as $queryPartName) {
|
||||
$this->resetQueryPart($queryPartName);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -1129,9 +1142,16 @@ class QueryBuilder implements IQueryBuilder {
|
|||
* @param string $queryPartName
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
* @since 30.0.0 Only 'where'|'having'|'groupBy'|'orderBy' are supported. Everything else will throw.
|
||||
*/
|
||||
public function resetQueryPart($queryPartName) {
|
||||
$this->queryBuilder->resetQueryPart($queryPartName);
|
||||
match ($queryPartName) {
|
||||
'where' => $this->queryBuilder->resetWhere(),
|
||||
'having' => $this->queryBuilder->resetHaving(),
|
||||
'groupBy' => $this->queryBuilder->resetGroupBy(),
|
||||
'orderBy' => $this->queryBuilder->resetOrderBy(),
|
||||
default => throw new \Exception('Resetting query part "' . $queryPartName. '" is no longer supported. Please create a new QueryBuilder instead.'),
|
||||
};
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -833,6 +833,7 @@ interface IQueryBuilder {
|
|||
*
|
||||
* @return mixed
|
||||
* @since 8.2.0
|
||||
* @deprecated 30.0.0 The function always throws an exception
|
||||
*/
|
||||
public function getQueryPart($queryPartName);
|
||||
|
||||
|
|
@ -841,6 +842,7 @@ interface IQueryBuilder {
|
|||
*
|
||||
* @return array
|
||||
* @since 8.2.0
|
||||
* @deprecated 30.0.0 The function always throws an exception
|
||||
*/
|
||||
public function getQueryParts();
|
||||
|
||||
|
|
@ -851,6 +853,7 @@ interface IQueryBuilder {
|
|||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
* @since 8.2.0
|
||||
* @since 30.0.0 Only null and a list of 'where'|'having'|'groupBy'|'orderBy' is supported. Everything else will throw.
|
||||
*/
|
||||
public function resetQueryParts($queryPartNames = null);
|
||||
|
||||
|
|
@ -861,6 +864,7 @@ interface IQueryBuilder {
|
|||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
* @since 8.2.0
|
||||
* @since 30.0.0 Only 'where'|'having'|'groupBy'|'orderBy' are supported. Everything else will throw.
|
||||
*/
|
||||
public function resetQueryPart($queryPartName);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue