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 46
46
- New #316 : Realize ` Schema::loadResultColumn() ` method (@Tigrov )
47
47
- New #323 : Use ` DateTimeColumn ` class for datetime column types (@Tigrov )
48
48
- Enh #324 : Refactor ` Command::insertWithReturningPks() ` method (@Tigrov )
49
+ - Chg #326 : Add alias in ` DQLQueryBuilder::selectExists() ` method for consistency with other DBMS (@Tigrov )
49
50
50
51
## 1.3.0 March 21, 2024
51
52
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function buildOrderByAndLimit(
57
57
58
58
public function selectExists (string $ rawSql ): string
59
59
{
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 ' ;
61
61
}
62
62
63
63
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
119
119
return $ insert ;
120
120
}
121
121
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
-
133
122
public static function upsert (): array
134
123
{
135
124
$ concreteData = [
Original file line number Diff line number Diff line change @@ -451,10 +451,16 @@ public function testResetSequenceCompositeException(): void
451
451
$ db ->close ();
452
452
}
453
453
454
- #[DataProviderExternal(QueryBuilderProvider::class, 'selectExist ' )]
455
- public function testSelectExists (string $ sql , string $ expected ): void
454
+ public function testSelectExists (): void
456
455
{
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 ));
458
464
}
459
465
460
466
#[DataProviderExternal(QueryBuilderProvider::class, 'update ' )]
You can’t perform that action at this time.
0 commit comments