@@ -11332,6 +11332,36 @@ public function testCreateTableWithDefaultNowFunction(): void {
1133211332 ),
1133311333 $ results [0 ]->{'Create Table ' }
1133411334 );
11335+
11336+ // DESCRIBE
11337+ $ this ->assertQuery ( 'DESCRIBE test_now_default ' );
11338+ $ results = $ this ->engine ->get_query_results ();
11339+ $ this ->assertEquals (
11340+ array (
11341+ (object ) array (
11342+ 'Field ' => 'id ' ,
11343+ 'Type ' => 'int ' ,
11344+ 'Null ' => 'NO ' ,
11345+ 'Key ' => '' ,
11346+ 'Default ' => null ,
11347+ 'Extra ' => '' ,
11348+ ),
11349+ (object ) array (
11350+ 'Field ' => 'updated ' ,
11351+ 'Type ' => 'timestamp ' ,
11352+ 'Null ' => 'NO ' ,
11353+ 'Key ' => '' ,
11354+ 'Default ' => '( now( ) ) ' ,
11355+ 'Extra ' => 'DEFAULT_GENERATED on update CURRENT_TIMESTAMP ' ,
11356+ ),
11357+ ),
11358+ $ results
11359+ );
11360+
11361+ // Verify the translated SQLite definition.
11362+ $ result = $ this ->sqlite ->query ( 'PRAGMA table_info(test_now_default) ' )->fetchAll ();
11363+ $ this ->assertSame ( null , $ result [0 ]['dflt_value ' ] );
11364+ $ this ->assertSame ( 'CURRENT_TIMESTAMP ' , $ result [1 ]['dflt_value ' ] );
1133511365 }
1133611366
1133711367 public function testCreateTableWithDefaultExpressions (): void {
@@ -11369,5 +11399,53 @@ public function testCreateTableWithDefaultExpressions(): void {
1136911399 ),
1137011400 $ results [0 ]->{'Create Table ' }
1137111401 );
11402+
11403+ // DESCRIBE
11404+ $ this ->assertQuery ( 'DESCRIBE t ' );
11405+ $ results = $ this ->engine ->get_query_results ();
11406+ $ this ->assertEquals (
11407+ array (
11408+ (object ) array (
11409+ 'Field ' => 'id ' ,
11410+ 'Type ' => 'int ' ,
11411+ 'Null ' => 'NO ' ,
11412+ 'Key ' => '' ,
11413+ 'Default ' => null ,
11414+ 'Extra ' => '' ,
11415+ ),
11416+ (object ) array (
11417+ 'Field ' => 'col1 ' ,
11418+ 'Type ' => 'int ' ,
11419+ 'Null ' => 'NO ' ,
11420+ 'Key ' => '' ,
11421+ 'Default ' => '( 1 + 2 ) ' ,
11422+ 'Extra ' => 'DEFAULT_GENERATED ' ,
11423+ ),
11424+ (object ) array (
11425+ 'Field ' => 'col2 ' ,
11426+ 'Type ' => 'datetime ' ,
11427+ 'Null ' => 'NO ' ,
11428+ 'Key ' => '' ,
11429+ 'Default ' => '( DATE_ADD( NOW( ) , INTERVAL 1 YEAR ) ) ' ,
11430+ 'Extra ' => 'DEFAULT_GENERATED ' ,
11431+ ),
11432+ (object ) array (
11433+ 'Field ' => 'col3 ' ,
11434+ 'Type ' => 'varchar(255) ' ,
11435+ 'Null ' => 'NO ' ,
11436+ 'Key ' => '' ,
11437+ 'Default ' => "( CONCAT( 'a' , 'b' ) ) " ,
11438+ 'Extra ' => 'DEFAULT_GENERATED ' ,
11439+ ),
11440+ ),
11441+ $ results
11442+ );
11443+
11444+ // Verify the translated SQLite definition.
11445+ $ result = $ this ->sqlite ->query ( 'PRAGMA table_info(t) ' )->fetchAll ();
11446+ $ this ->assertSame ( null , $ result [0 ]['dflt_value ' ] );
11447+ $ this ->assertSame ( '1 + 2 ' , $ result [1 ]['dflt_value ' ] );
11448+ $ this ->assertSame ( "DATETIME(CURRENT_TIMESTAMP, '+' || 1 || ' YEAR') " , $ result [2 ]['dflt_value ' ] );
11449+ $ this ->assertSame ( "('a' || 'b') " , $ result [3 ]['dflt_value ' ] );
1137211450 }
1137311451}
0 commit comments