Skip to content

Commit

Permalink
Try to fix MSSQL and Oracle differently
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Sep 26, 2023
1 parent 9de7184 commit bdf10e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ItemTreeTraversal/CteItemTreeTraversal.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
abstract class CteItemTreeTraversal implements ItemTreeTraversalInterface
{
protected bool $useRecursiveInWith = true;

/**
* @param ConnectionInterface $database Yii Database connection instance.
*
Expand Down Expand Up @@ -124,8 +126,13 @@ private function getRowsCommand(
->from($this->tableName)
->where(['name' => $name])
->union($cteSelectRelationQuery, all: true);

Check warning on line 128 in src/ItemTreeTraversal/CteItemTreeTraversal.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ $cteParameterName = 'parent_name'; } $cteSelectRelationQuery = (new Query($this->database))->select($cteSelectRelationName)->from(['item_child_recursive' => $this->childrenTableName])->innerJoin($cteName, ["item_child_recursive.{$cteConditionRelationName}" => new Expression("{{{$cteName}}}.[[{$cteParameterName}]]")]); - $cteSelectItemQuery = (new Query($this->database))->select('name')->from($this->tableName)->where(['name' => $name])->union($cteSelectRelationQuery, all: true); + $cteSelectItemQuery = (new Query($this->database))->select('name')->from($this->tableName)->where(['name' => $name])->union($cteSelectRelationQuery, all: false); $quoter = $this->database->getQuoter(); $outerQuery = $baseOuterQuery->withQuery($cteSelectItemQuery, $quoter->quoteTableName($cteName) . '(' . $quoter->quoteColumnName($cteParameterName) . ')', recursive: $this->useRecursiveInWith)->from($cteName)->leftJoin(['item' => $this->tableName], ['item.name' => new Expression("{{{$cteName}}}.[[{$cteParameterName}]]")]); return $outerQuery->createCommand(); } }

Check warning on line 128 in src/ItemTreeTraversal/CteItemTreeTraversal.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ $cteParameterName = 'parent_name'; } $cteSelectRelationQuery = (new Query($this->database))->select($cteSelectRelationName)->from(['item_child_recursive' => $this->childrenTableName])->innerJoin($cteName, ["item_child_recursive.{$cteConditionRelationName}" => new Expression("{{{$cteName}}}.[[{$cteParameterName}]]")]); - $cteSelectItemQuery = (new Query($this->database))->select('name')->from($this->tableName)->where(['name' => $name])->union($cteSelectRelationQuery, all: true); + $cteSelectItemQuery = (new Query($this->database))->select('name')->from($this->tableName)->where(['name' => $name])->union($cteSelectRelationQuery, all: false); $quoter = $this->database->getQuoter(); $outerQuery = $baseOuterQuery->withQuery($cteSelectItemQuery, $quoter->quoteTableName($cteName) . '(' . $quoter->quoteColumnName($cteParameterName) . ')', recursive: $this->useRecursiveInWith)->from($cteName)->leftJoin(['item' => $this->tableName], ['item.name' => new Expression("{{{$cteName}}}.[[{$cteParameterName}]]")]); return $outerQuery->createCommand(); } }
$quoter = $this->database->getQuoter();
$outerQuery = $baseOuterQuery
->withQuery($cteSelectItemQuery, "$cteName($cteParameterName)", recursive: true)
->withQuery(
$cteSelectItemQuery,
$quoter->quoteTableName($cteName) . '(' . $quoter->quoteColumnName($cteParameterName) . ')',
recursive: $this->useRecursiveInWith,
)
->from($cteName)
->leftJoin(
['item' => $this->tableName],
Expand Down
1 change: 1 addition & 0 deletions src/ItemTreeTraversal/MssqlCteItemTreeTraversal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
*/
final class MssqlCteItemTreeTraversal extends CteItemTreeTraversal
{
protected bool $useRecursiveInWith = false;
}
1 change: 1 addition & 0 deletions src/ItemTreeTraversal/OracleCteItemTreeTraversal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
*/
final class OracleCteItemTreeTraversal extends CteItemTreeTraversal
{
protected bool $useRecursiveInWith = false;
}

0 comments on commit bdf10e6

Please sign in to comment.