From 245d3ee5161f82023381456ef373b626a13b4725 Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Sat, 14 Oct 2023 14:44:35 +0700 Subject: [PATCH] Fix CTE query expressions (#240) * Fix CTE * Fix psalm issue * Fix psalm issue --- CHANGELOG.md | 1 + src/DQLQueryBuilder.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 350db64..aef34e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.1.1 under development - Enh #230: Improve column type #230 (@Tigrov) +- Bug #240: Remove `RECURSIVE` expression from CTE queries (@Tigrov) ## 1.1.0 July 24, 2023 diff --git a/src/DQLQueryBuilder.php b/src/DQLQueryBuilder.php index b0d2aa2..d8ce2d3 100644 --- a/src/DQLQueryBuilder.php +++ b/src/DQLQueryBuilder.php @@ -7,6 +7,7 @@ use Yiisoft\Db\Expression\ExpressionInterface; use Yiisoft\Db\Oracle\Builder\InConditionBuilder; use Yiisoft\Db\Oracle\Builder\LikeConditionBuilder; +use Yiisoft\Db\Query\Query; use Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder; use Yiisoft\Db\QueryBuilder\Condition\InCondition; use Yiisoft\Db\QueryBuilder\Condition\LikeCondition; @@ -60,6 +61,16 @@ public function selectExists(string $rawSql): string return 'SELECT CASE WHEN EXISTS(' . $rawSql . ') THEN 1 ELSE 0 END FROM DUAL'; } + public function buildWithQueries(array $withs, array &$params): string + { + /** @psalm-var array{query:string|Query, alias:ExpressionInterface|string, recursive:bool}[] $withs */ + foreach ($withs as &$with) { + $with['recursive'] = false; + } + + return parent::buildWithQueries($withs, $params); + } + protected function defaultExpressionBuilders(): array { return array_merge(