Skip to content

Commit 7ddf61d

Browse files
authored
Adapt to refactor "WITH" in Yii DB (#406)
1 parent 9120d7e commit 7ddf61d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
- Enh #393: Refactor `DMLQueryBuilder::upsert()` method (@Tigrov)
6060
- Chg #398: Update expression namespaces according to changes in `yiisoft/db` package (@Tigrov)
6161
- Enh #392: Update `DMLQueryBuilder::update()` method to adapt changes in `yiisoft/db` (@rustamwin)
62+
- Enh #406: Adapt to `DQLQueryBuilderInterface::buildWithQueries()` signature changes in `yiisoft/db` package (@vjik)
6263

6364
## 1.2.0 March 21, 2024
6465

src/DQLQueryBuilder.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Yiisoft\Db\Mssql\Builder\LongestBuilder;
2323
use Yiisoft\Db\Mssql\Builder\ShortestBuilder;
2424
use Yiisoft\Db\Query\Query;
25+
use Yiisoft\Db\Query\WithQuery;
2526
use Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder;
2627
use Yiisoft\Db\QueryBuilder\Condition\In;
2728
use Yiisoft\Db\QueryBuilder\Condition\Like;
@@ -135,13 +136,17 @@ protected function extractAlias(string $table): array|bool
135136
return parent::extractAlias($table);
136137
}
137138

138-
public function buildWithQueries(array $withs, array &$params): string
139+
public function buildWithQueries(array $withQueries, array &$params): string
139140
{
140-
/** @psalm-var array{query:string|Query, alias:ExpressionInterface|string, recursive:bool}[] $withs */
141-
foreach ($withs as &$with) {
142-
$with['recursive'] = false;
143-
}
144-
145-
return parent::buildWithQueries($withs, $params);
141+
$withQueries = array_map(
142+
static fn(WithQuery $withQuery) => new WithQuery(
143+
$withQuery->query,
144+
$withQuery->alias,
145+
false
146+
),
147+
$withQueries,
148+
);
149+
150+
return parent::buildWithQueries($withQueries, $params);
146151
}
147152
}

0 commit comments

Comments
 (0)