fix: Adjust types of IQueryBuilder to properly allow joining with sub-query

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2024-09-09 17:42:01 +02:00
parent 531862d474
commit 027fc052e7
No known key found for this signature in database
GPG key ID: 45FAE7268762B400
3 changed files with 8 additions and 4 deletions

View file

@ -185,7 +185,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder {
}
public function leftJoin($fromAlias, $join, $alias, $condition = null): self {
return $this->join($fromAlias, $join, $alias, $condition, PartitionQuery::JOIN_MODE_LEFT);
return $this->join($fromAlias, (string)$join, $alias, $condition, PartitionQuery::JOIN_MODE_LEFT);
}
public function join($fromAlias, $join, $alias, $condition = null, $joinMode = PartitionQuery::JOIN_MODE_INNER): self {

View file

@ -764,7 +764,7 @@ class QueryBuilder implements IQueryBuilder {
* </code>
*
* @param string $fromAlias The alias that points to a from clause.
* @param string $join The table name to join.
* @param string|IQueryFunction $join The table name or sub-query to join.
* @param string $alias The alias of the join table.
* @param string|ICompositeExpression|null $condition The condition for the join.
*

View file

@ -541,12 +541,13 @@ interface IQueryBuilder {
* </code>
*
* @param string $fromAlias The alias that points to a from clause.
* @param string $join The table name to join.
* @param string|IQueryFunction $join The table name to join.
* @param string $alias The alias of the join table.
* @param string|ICompositeExpression|null $condition The condition for the join.
*
* @return $this This QueryBuilder instance.
* @since 8.2.0
* @since 30.0.0 Allow passing IQueryFunction as parameter for `$join` to allow join with a sub-query.
*
* @psalm-taint-sink sql $fromAlias
* @psalm-taint-sink sql $join
@ -1001,11 +1002,14 @@ interface IQueryBuilder {
public function getLastInsertId(): int;
/**
* Returns the table name quoted and with database prefix as needed by the implementation
* Returns the table name quoted and with database prefix as needed by the implementation.
* If a query function is passed the function is casted to string,
* this allows passing functions as sub-queries for join expression.
*
* @param string|IQueryFunction $table
* @return string
* @since 9.0.0
* @since 24.0.0 accepts IQueryFunction as parameter
*/
public function getTableName($table);