File tree Expand file tree Collapse file tree 4 files changed +11
-15
lines changed
Expand file tree Collapse file tree 4 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 4646- New #316 : Realize ` Schema::loadResultColumn() ` method (@Tigrov )
4747- New #323 : Use ` DateTimeColumn ` class for datetime column types (@Tigrov )
4848- Enh #324 : Refactor ` Command::insertWithReturningPks() ` method (@Tigrov )
49+ - Chg #326 : Add alias in ` DQLQueryBuilder::selectExists() ` method for consistency with other DBMS (@Tigrov )
4950
5051## 1.3.0 March 21, 2024
5152
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function buildOrderByAndLimit(
5757
5858 public function selectExists (string $ rawSql ): string
5959 {
60- return 'SELECT CASE WHEN EXISTS( ' . $ rawSql . ') THEN 1 ELSE 0 END FROM DUAL ' ;
60+ return 'SELECT CASE WHEN EXISTS( ' . $ rawSql . ') THEN 1 ELSE 0 END AS "0" FROM DUAL ' ;
6161 }
6262
6363 public function buildFrom (array |null $ tables , array &$ params ): string
Original file line number Diff line number Diff line change @@ -119,17 +119,6 @@ public static function insert(): array
119119 return $ insert ;
120120 }
121121
122- public static function selectExist (): array
123- {
124- $ selectExist = parent ::selectExist ();
125-
126- $ selectExist [0 ][1 ] = <<<SQL
127- SELECT CASE WHEN EXISTS(SELECT 1 FROM `table` WHERE `id` = 1) THEN 1 ELSE 0 END FROM DUAL
128- SQL ;
129-
130- return $ selectExist ;
131- }
132-
133122 public static function upsert (): array
134123 {
135124 $ concreteData = [
Original file line number Diff line number Diff line change @@ -451,10 +451,16 @@ public function testResetSequenceCompositeException(): void
451451 $ db ->close ();
452452 }
453453
454- #[DataProviderExternal(QueryBuilderProvider::class, 'selectExist ' )]
455- public function testSelectExists (string $ sql , string $ expected ): void
454+ public function testSelectExists (): void
456455 {
457- parent ::testSelectExists ($ sql , $ expected );
456+ $ db = $ this ->getConnection ();
457+ $ qb = $ db ->getQueryBuilder ();
458+
459+ $ sql = 'SELECT 1 FROM "customer" WHERE "id" = 1 ' ;
460+ // Alias is not required in Oracle, but it is added for consistency with other DBMS.
461+ $ expected = 'SELECT CASE WHEN EXISTS(SELECT 1 FROM "customer" WHERE "id" = 1) THEN 1 ELSE 0 END AS "0" FROM DUAL ' ;
462+
463+ $ this ->assertSame ($ expected , $ qb ->selectExists ($ sql ));
458464 }
459465
460466 #[DataProviderExternal(QueryBuilderProvider::class, 'update ' )]
You can’t perform that action at this time.
0 commit comments