Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions build/psalm/ITypedQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@
$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();

Expand Down
242 changes: 241 additions & 1 deletion lib/public/DB/QueryBuilder/ITypedQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public function select(...$selects);
* @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;

Expand All @@ -52,7 +54,9 @@ public function selectDistinct($select);
* @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;

Expand All @@ -69,8 +73,244 @@ public function addSelect(...$select);
* @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