mirror of
https://github.com/nextcloud/server.git
synced 2026-07-16 13:23:11 -04:00
Merge pull request #58559 from nextcloud/fix/itypedquerybuilder/chained-calls
This commit is contained in:
commit
77c070bc93
2 changed files with 273 additions and 1 deletions
|
|
@ -21,6 +21,38 @@ $qb->selectColumnsDistinct('f');
|
|||
$qb->selectAlias('g', 'h');
|
||||
$qb->selectAlias($qb->func()->lower('i'), 'j');
|
||||
|
||||
$qb
|
||||
->setParameter('k', 'l')
|
||||
->setParameters([])
|
||||
->setFirstResult(0)
|
||||
->setMaxResults(0)
|
||||
->delete()
|
||||
->update()
|
||||
->insert()
|
||||
->from('m')
|
||||
->join('n', 'o', 'p')
|
||||
->innerJoin('q', 'r', 's')
|
||||
->leftJoin('t', 'u', 'v')
|
||||
->rightJoin('w', 'x', 'y')
|
||||
->set('z', '1')
|
||||
->where()
|
||||
->andWhere()
|
||||
->orWhere()
|
||||
->groupBy()
|
||||
->addGroupBy()
|
||||
->setValue('2', '3')
|
||||
->values([])
|
||||
->having()
|
||||
->andHaving()
|
||||
->orHaving()
|
||||
->orderBy('4')
|
||||
->addOrderBy('5')
|
||||
->resetQueryParts()
|
||||
->resetQueryPart('6')
|
||||
->hintShardKey('7', '8')
|
||||
->runAcrossAllShards()
|
||||
->forUpdate();
|
||||
|
||||
/** @psalm-check-type-exact $result = \OCP\DB\IResult<'a'|'b'|'c'|'d'|'e'|'f'|'h'|'j'> */
|
||||
$result = $qb->executeQuery();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ interface ITypedQueryBuilder extends IQueryBuilder {
|
|||
* @template NewS of string
|
||||
* @param NewS ...$columns The columns to select. They are not allowed to contain table names or aliases, or asterisks. Use {@see self::selectAlias()} for that.
|
||||
* @psalm-this-out self<S|NewS>
|
||||
* @return $this
|
||||
* @since 34.0.0
|
||||
* @note Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439
|
||||
*/
|
||||
public function selectColumns(string ...$columns): self;
|
||||
|
||||
|
|
@ -52,7 +54,9 @@ interface ITypedQueryBuilder extends IQueryBuilder {
|
|||
* @template NewS of string
|
||||
* @param NewS ...$columns The columns to select distinct. They are not allowed to contain table names or aliases, or asterisks. Use {@see self::selectAlias()} for that.
|
||||
* @psalm-this-out self<S|NewS>
|
||||
* @return $this
|
||||
* @since 34.0.0
|
||||
* @note Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439
|
||||
*/
|
||||
public function selectColumnsDistinct(string ...$columns): self;
|
||||
|
||||
|
|
@ -69,8 +73,244 @@ interface ITypedQueryBuilder extends IQueryBuilder {
|
|||
* @template NewS of string
|
||||
* @param NewS $alias
|
||||
* @psalm-this-out self<S|NewS>
|
||||
* @psalm-suppress LessSpecificImplementedReturnType
|
||||
* @return $this
|
||||
* @note Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439
|
||||
*/
|
||||
#[Override]
|
||||
public function selectAlias($select, $alias): self;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function setParameter($key, $value, $type = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
#[Override]
|
||||
public function setParameters(array $params, array $types = []);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function setFirstResult($firstResult);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function setMaxResults($maxResults);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function delete($delete = null, $alias = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function update($update = null, $alias = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function insert($insert = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function from($from, $alias = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function join($fromAlias, $join, $alias, $condition = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function innerJoin($fromAlias, $join, $alias, $condition = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function leftJoin($fromAlias, $join, $alias, $condition = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function rightJoin($fromAlias, $join, $alias, $condition = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function set($key, $value);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function where(...$predicates);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function andWhere(...$where);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function orWhere(...$where);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function groupBy(...$groupBys);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function addGroupBy(...$groupBy);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function setValue($column, $value);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
#[Override]
|
||||
public function values(array $values);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function having(...$having);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function andHaving(...$having);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function orHaving(...$having);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function orderBy($sort, $order = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function addOrderBy($sort, $order = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function resetQueryParts($queryPartNames = null);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
* @psalm-suppress MissingParamType
|
||||
*/
|
||||
#[Override]
|
||||
public function resetQueryPart($queryPartName);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
#[Override]
|
||||
public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
#[Override]
|
||||
public function runAcrossAllShards(): self;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return $this
|
||||
*/
|
||||
#[Override]
|
||||
public function forUpdate(ConflictResolutionMode $conflictResolutionMode = ConflictResolutionMode::Ordinary): self;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue