]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Adjust types of IQueryBuilder to properly allow joining with sub-query 47586/head
authorFerdinand Thiessen <opensource@fthiessen.de>
Mon, 9 Sep 2024 15:42:01 +0000 (17:42 +0200)
committerFerdinand Thiessen <opensource@fthiessen.de>
Tue, 10 Sep 2024 15:51:27 +0000 (17:51 +0200)
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php
lib/private/DB/QueryBuilder/QueryBuilder.php
lib/public/DB/QueryBuilder/IQueryBuilder.php

index 175b7c1a42eb769a84a35148b09e3517a4f5550e..9d351c1d3f17e1e874f7b0d1aab5ae893b0178fb 100644 (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 {
index 5c7e273c9ec7342ce552190414e0b25d9e39dabb..6cdf97b01e9fc72a3ff35dc9d034e87c358c968a 100644 (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.
         *
index c21793a24217eeb3e023e7961926e87550b2751d..22724c0c8005ed07fd478fc22fa03a6336b3320b 100644 (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);