Skip to content

Commit 027fc05

Browse files
committed
fix: Adjust types of IQueryBuilder to properly allow joining with sub-query
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 531862d commit 027fc05

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function innerJoin($fromAlias, $join, $alias, $condition = null): self {
185185
}
186186

187187
public function leftJoin($fromAlias, $join, $alias, $condition = null): self {
188-
return $this->join($fromAlias, $join, $alias, $condition, PartitionQuery::JOIN_MODE_LEFT);
188+
return $this->join($fromAlias, (string)$join, $alias, $condition, PartitionQuery::JOIN_MODE_LEFT);
189189
}
190190

191191
public function join($fromAlias, $join, $alias, $condition = null, $joinMode = PartitionQuery::JOIN_MODE_INNER): self {

lib/private/DB/QueryBuilder/QueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ public function innerJoin($fromAlias, $join, $alias, $condition = null) {
764764
* </code>
765765
*
766766
* @param string $fromAlias The alias that points to a from clause.
767-
* @param string $join The table name to join.
767+
* @param string|IQueryFunction $join The table name or sub-query to join.
768768
* @param string $alias The alias of the join table.
769769
* @param string|ICompositeExpression|null $condition The condition for the join.
770770
*

lib/public/DB/QueryBuilder/IQueryBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,13 @@ public function innerJoin($fromAlias, $join, $alias, $condition = null);
541541
* </code>
542542
*
543543
* @param string $fromAlias The alias that points to a from clause.
544-
* @param string $join The table name to join.
544+
* @param string|IQueryFunction $join The table name to join.
545545
* @param string $alias The alias of the join table.
546546
* @param string|ICompositeExpression|null $condition The condition for the join.
547547
*
548548
* @return $this This QueryBuilder instance.
549549
* @since 8.2.0
550+
* @since 30.0.0 Allow passing IQueryFunction as parameter for `$join` to allow join with a sub-query.
550551
*
551552
* @psalm-taint-sink sql $fromAlias
552553
* @psalm-taint-sink sql $join
@@ -1001,11 +1002,14 @@ public function createFunction($call);
10011002
public function getLastInsertId(): int;
10021003

10031004
/**
1004-
* Returns the table name quoted and with database prefix as needed by the implementation
1005+
* Returns the table name quoted and with database prefix as needed by the implementation.
1006+
* If a query function is passed the function is casted to string,
1007+
* this allows passing functions as sub-queries for join expression.
10051008
*
10061009
* @param string|IQueryFunction $table
10071010
* @return string
10081011
* @since 9.0.0
1012+
* @since 24.0.0 accepts IQueryFunction as parameter
10091013
*/
10101014
public function getTableName($table);
10111015

0 commit comments

Comments
 (0)