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 43
43
- New #358 : Use ` DateTimeColumn ` class for datetime column types (@Tigrov )
44
44
- New #361 : Implement ` DMLQueryBuilder::upsertWithReturningPks() ` method (@Tigrov )
45
45
- Enh #361 : Refactor ` DMLQueryBuilder::insertWithReturningPks() ` method (@Tigrov )
46
+ - Chg #363 : Add alias in ` DQLQueryBuilder::selectExists() ` method for consistency with other DBMS (@Tigrov )
46
47
47
48
## 1.2.0 March 21, 2024
48
49
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function buildOrderByAndLimit(
39
39
40
40
public function selectExists (string $ rawSql ): string
41
41
{
42
- return 'SELECT CASE WHEN EXISTS( ' . $ rawSql . ') THEN 1 ELSE 0 END ' ;
42
+ return 'SELECT CASE WHEN EXISTS( ' . $ rawSql . ') THEN 1 ELSE 0 END AS [0] ' ;
43
43
}
44
44
45
45
protected function defaultExpressionBuilders (): array
Original file line number Diff line number Diff line change @@ -395,17 +395,6 @@ public static function insertWithReturningPks(): array
395
395
];
396
396
}
397
397
398
- public static function selectExist (): array
399
- {
400
- $ selectExist = parent ::selectExist ();
401
-
402
- $ selectExist [0 ][1 ] = <<<SQL
403
- SELECT CASE WHEN EXISTS(SELECT 1 FROM `table` WHERE `id` = 1) THEN 1 ELSE 0 END
404
- SQL ;
405
-
406
- return $ selectExist ;
407
- }
408
-
409
398
public static function upsert (): array
410
399
{
411
400
$ concreteData = [
Original file line number Diff line number Diff line change @@ -413,10 +413,16 @@ public function testResetSequence(): void
413
413
);
414
414
}
415
415
416
- #[DataProviderExternal(QueryBuilderProvider::class, 'selectExist')]
417
- public function testSelectExists(string $ sql, string $ expected): void
416
+ public function testSelectExists(): void
418
417
{
419
- parent::testSelectExists( $ sql, $ expected);
418
+ $ db = $ this ->getConnection ();
419
+ $ qb = $ db ->getQueryBuilder ();
420
+
421
+ $ sql = 'SELECT 1 FROM [customer] WHERE [id] = 1';
422
+ // Alias is not required in MSSQL, but it is added for consistency with other DBMS.
423
+ $ expected = 'SELECT CASE WHEN EXISTS(SELECT 1 FROM [customer] WHERE [id] = 1) THEN 1 ELSE 0 END AS [0]';
424
+
425
+ $ this ->assertSame ( $ expected, $ qb ->selectExists ( $ sql));
420
426
}
421
427
422
428
#[DataProviderExternal(QueryBuilderProvider::class, 'update')]
You can’t perform that action at this time.
0 commit comments