@@ -382,14 +382,13 @@ public function buildUnion(array $unions, array &$params): string
382382
383383 $ result = '' ;
384384
385- /** @psalm-var array<array{query:Query|string, all:bool}> $unions */
386- foreach ($ unions as $ i => $ union ) {
387- $ query = $ union ['query ' ];
388- if ($ query instanceof QueryInterface) {
389- [$ unions [$ i ]['query ' ], $ params ] = $ this ->build ($ query , $ params );
385+ /** @psalm-var array<array{query:string|Query, all:bool}> $unions */
386+ foreach ($ unions as $ union ) {
387+ if ($ union ['query ' ] instanceof QueryInterface) {
388+ [$ union ['query ' ], $ params ] = $ this ->build ($ union ['query ' ], $ params );
390389 }
391390
392- $ result .= 'UNION ' . ($ union ['all ' ] ? 'ALL ' : '' ) . '( ' . $ unions [ $ i ] ['query ' ] . ' ) ' ;
391+ $ result .= 'UNION ' . ($ union ['all ' ] ? 'ALL ' : '' ) . '( ' . $ union ['query ' ] . ' ) ' ;
393392 }
394393
395394 return trim ($ result );
@@ -418,9 +417,8 @@ public function buildWithQueries(array $withs, array &$params): string
418417 $ recursive = true ;
419418 }
420419
421- $ query = $ with ['query ' ];
422- if ($ query instanceof QueryInterface) {
423- [$ with ['query ' ], $ params ] = $ this ->build ($ query , $ params );
420+ if ($ with ['query ' ] instanceof QueryInterface) {
421+ [$ with ['query ' ], $ params ] = $ this ->build ($ with ['query ' ], $ params );
424422 }
425423
426424 $ result [] = $ with ['alias ' ] . ' AS ( ' . $ with ['query ' ] . ') ' ;
0 commit comments