@@ -350,7 +350,7 @@ public function getRawState(?string $key = null): mixed
350350 self ::TABLE => $ this ->table ->getFrom (),
351351 self ::QUANTIFIER => $ this ->quantifier ?->get(),
352352 self ::COLUMNS => $ this ->table ->getColumns (),
353- self ::JOINS => $ this ->table ->joins () ?? new Join (),
353+ self ::JOINS => $ this ->table ->join ?? new Join (),
354354 self ::WHERE => $ this ->where ??= new Where (),
355355 self ::ORDER => $ this ->orderBy ?->get() ?? [],
356356 self ::GROUP => $ this ->groupBy ?->get() ?? [],
@@ -380,12 +380,13 @@ public function buildSqlString(AbstractSqlRenderer $renderer): string
380380 {
381381 $ renderer ->getTypeDecorator ($ this )?->prepare($ this , $ renderer );
382382
383+ $ combine = $ this ->combine ?->toSql($ renderer );
384+
383385 $ sql = implode (' ' , array_filter ([
384- 'SELECT ' ,
385386 $ this ->quantifier ?->toSql($ renderer ),
386- $ this ->table ->columns () ->toSql ($ renderer ),
387- $ this ->table ->from () ->toSql ($ renderer ),
388- $ this ->table ->joins () ?->toSql($ renderer ),
387+ $ this ->table ->columns ->toSql ($ renderer ),
388+ $ this ->table ->from ->toSql ($ renderer ),
389+ $ this ->table ->join ?->toSql($ renderer ),
389390 $ this ->where ?->toSql($ renderer ),
390391 $ this ->groupBy ?->toSql($ renderer ),
391392 $ this ->having ?->toSql($ renderer ),
@@ -394,9 +395,9 @@ public function buildSqlString(AbstractSqlRenderer $renderer): string
394395 $ this ->offset ?->toSql($ renderer ),
395396 ]));
396397
397- $ combine = $ this -> combine ?->toSql( $ renderer );
398-
399- return $ combine !== null ? " ( $ sql ) $ combine " : $ sql ;
398+ return $ combine !== null
399+ ? " ( SELECT $ sql ) $ combine "
400+ : " SELECT $ sql" ;
400401 }
401402
402403 /**
@@ -412,7 +413,7 @@ public function __get(string $name): Where|Join|Having
412413 case 'having ' :
413414 return $ this ->having ??= new Having ();
414415 case 'joins ' :
415- return $ this ->table ->joins () ?? new Join ();
416+ return $ this ->table ->join ?? new Join ();
416417 default :
417418 throw new Exception \InvalidArgumentException ('Not a valid magic property for this object ' );
418419 }
0 commit comments