@@ -11407,6 +11407,36 @@ public function testCreateTableWithDefaultNowFunction(): void {
1140711407 ),
1140811408 $ results [0 ]->{'Create Table ' }
1140911409 );
11410+
11411+ // DESCRIBE
11412+ $ this ->assertQuery ( 'DESCRIBE test_now_default ' );
11413+ $ results = $ this ->engine ->get_query_results ();
11414+ $ this ->assertEquals (
11415+ array (
11416+ (object ) array (
11417+ 'Field ' => 'id ' ,
11418+ 'Type ' => 'int ' ,
11419+ 'Null ' => 'NO ' ,
11420+ 'Key ' => '' ,
11421+ 'Default ' => null ,
11422+ 'Extra ' => '' ,
11423+ ),
11424+ (object ) array (
11425+ 'Field ' => 'updated ' ,
11426+ 'Type ' => 'timestamp ' ,
11427+ 'Null ' => 'NO ' ,
11428+ 'Key ' => '' ,
11429+ 'Default ' => '( now( ) ) ' ,
11430+ 'Extra ' => 'DEFAULT_GENERATED on update CURRENT_TIMESTAMP ' ,
11431+ ),
11432+ ),
11433+ $ results
11434+ );
11435+
11436+ // Verify the translated SQLite definition.
11437+ $ result = $ this ->sqlite ->query ( 'PRAGMA table_info(test_now_default) ' )->fetchAll ();
11438+ $ this ->assertSame ( null , $ result [0 ]['dflt_value ' ] );
11439+ $ this ->assertSame ( 'CURRENT_TIMESTAMP ' , $ result [1 ]['dflt_value ' ] );
1141011440 }
1141111441
1141211442 public function testCreateTableWithDefaultExpressions (): void {
@@ -11444,5 +11474,53 @@ public function testCreateTableWithDefaultExpressions(): void {
1144411474 ),
1144511475 $ results [0 ]->{'Create Table ' }
1144611476 );
11477+
11478+ // DESCRIBE
11479+ $ this ->assertQuery ( 'DESCRIBE t ' );
11480+ $ results = $ this ->engine ->get_query_results ();
11481+ $ this ->assertEquals (
11482+ array (
11483+ (object ) array (
11484+ 'Field ' => 'id ' ,
11485+ 'Type ' => 'int ' ,
11486+ 'Null ' => 'NO ' ,
11487+ 'Key ' => '' ,
11488+ 'Default ' => null ,
11489+ 'Extra ' => '' ,
11490+ ),
11491+ (object ) array (
11492+ 'Field ' => 'col1 ' ,
11493+ 'Type ' => 'int ' ,
11494+ 'Null ' => 'NO ' ,
11495+ 'Key ' => '' ,
11496+ 'Default ' => '( 1 + 2 ) ' ,
11497+ 'Extra ' => 'DEFAULT_GENERATED ' ,
11498+ ),
11499+ (object ) array (
11500+ 'Field ' => 'col2 ' ,
11501+ 'Type ' => 'datetime ' ,
11502+ 'Null ' => 'NO ' ,
11503+ 'Key ' => '' ,
11504+ 'Default ' => '( DATE_ADD( NOW( ) , INTERVAL 1 YEAR ) ) ' ,
11505+ 'Extra ' => 'DEFAULT_GENERATED ' ,
11506+ ),
11507+ (object ) array (
11508+ 'Field ' => 'col3 ' ,
11509+ 'Type ' => 'varchar(255) ' ,
11510+ 'Null ' => 'NO ' ,
11511+ 'Key ' => '' ,
11512+ 'Default ' => "( CONCAT( 'a' , 'b' ) ) " ,
11513+ 'Extra ' => 'DEFAULT_GENERATED ' ,
11514+ ),
11515+ ),
11516+ $ results
11517+ );
11518+
11519+ // Verify the translated SQLite definition.
11520+ $ result = $ this ->sqlite ->query ( 'PRAGMA table_info(t) ' )->fetchAll ();
11521+ $ this ->assertSame ( null , $ result [0 ]['dflt_value ' ] );
11522+ $ this ->assertSame ( '1 + 2 ' , $ result [1 ]['dflt_value ' ] );
11523+ $ this ->assertSame ( "DATETIME(CURRENT_TIMESTAMP, '+' || 1 || ' YEAR') " , $ result [2 ]['dflt_value ' ] );
11524+ $ this ->assertSame ( "('a' || 'b') " , $ result [3 ]['dflt_value ' ] );
1144711525 }
1144811526}
0 commit comments