@@ -397,14 +397,21 @@ public function testExceptionContainsRawQuery(): void
397397 /**
398398 * @param Connection $connection
399399 */
400- private function runExceptionTest ($ connection ): void
400+ private function runExceptionTest (Connection $ connection ): void
401401 {
402402 $ thrown = false ;
403+ $ sqlAssertLog = 'INSERT INTO qlog1(a) VALUES(1); ' ;
404+
405+ if ($ connection ->getDriverName () === 'sqlite ' ) {
406+ // SQLite shows placeholders (`:a`), other drivers show values (`1`) in error messages.
407+ $ sqlAssertLog = 'INSERT INTO qlog1(a) VALUES(:a); ' ;
408+ }
409+
403410 try {
404411 $ connection ->createCommand ('INSERT INTO qlog1(a) VALUES(:a); ' , [':a ' => 1 ])->execute ();
405412 } catch (\yii \db \Exception $ e ) {
406413 $ this ->assertStringContainsString (
407- ' INSERT INTO qlog1(a) VALUES(1); ' ,
414+ $ sqlAssertLog ,
408415 $ e ->getMessage (),
409416 'Exception message should contain raw SQL query: ' . (string ) $ e
410417 );
@@ -413,11 +420,18 @@ private function runExceptionTest($connection): void
413420 $ this ->assertTrue ($ thrown , 'An exception should have been thrown by the command. ' );
414421
415422 $ thrown = false ;
423+ $ sqlAssertLog = 'SELECT * FROM qlog1 WHERE id=1 ORDER BY nonexistingcolumn; ' ;
424+
425+ if ($ connection ->getDriverName () === 'sqlite ' ) {
426+ // SQLite shows placeholders (`:a`), other drivers show values (`1`) in error messages.
427+ $ sqlAssertLog = 'SELECT * FROM qlog1 WHERE id=:a ORDER BY nonexistingcolumn; ' ;
428+ }
429+
416430 try {
417431 $ connection ->createCommand ('SELECT * FROM qlog1 WHERE id=:a ORDER BY nonexistingcolumn; ' , [':a ' => 1 ])->queryAll ();
418432 } catch (\yii \db \Exception $ e ) {
419433 $ this ->assertStringContainsString (
420- ' SELECT * FROM qlog1 WHERE id=1 ORDER BY nonexistingcolumn; ' ,
434+ $ sqlAssertLog ,
421435 $ e ->getMessage (),
422436 'Exception message should contain raw SQL query: ' . (string ) $ e ,
423437 );
0 commit comments