This repository was archived by the owner on Jun 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -1252,6 +1252,51 @@ public function testColumnWithOnUpdate() {
1252
1252
$ this ->assertNull ( $ result [0 ]->updated_at );
1253
1253
}
1254
1254
1255
+ public function testTimestampColumnNamedTimestamp () {
1256
+ // CREATE TABLE with ON UPDATE
1257
+ $ this ->assertQuery (
1258
+ "CREATE TABLE `_tmp_table` (
1259
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1260
+ `timestamp` datetime NOT NULL,
1261
+ `numeric` int(11) NOT NULL,
1262
+ PRIMARY KEY (`id`),
1263
+ KEY timestamp (timestamp),
1264
+ KEY numeric (numeric)
1265
+ ); "
1266
+ );
1267
+ $ results = $ this ->assertQuery ( 'DESCRIBE _tmp_table; ' );
1268
+ var_dump ( $ results );
1269
+ $ this ->assertEquals (
1270
+ array (
1271
+ (object ) array (
1272
+ 'Field ' => 'id ' ,
1273
+ 'Type ' => 'bigint(20) unsigned ' ,
1274
+ 'Null ' => 'NO ' ,
1275
+ 'Key ' => 'PRI ' ,
1276
+ 'Default ' => '0 ' ,
1277
+ 'Extra ' => '' ,
1278
+ ),
1279
+ (object ) array (
1280
+ 'Field ' => 'timestamp ' ,
1281
+ 'Type ' => 'datetime ' ,
1282
+ 'Null ' => 'NO ' ,
1283
+ 'Key ' => '' ,
1284
+ 'Default ' => null ,
1285
+ 'Extra ' => '' ,
1286
+ ),
1287
+ (object ) array (
1288
+ 'Field ' => 'numeric ' ,
1289
+ 'Type ' => 'int(11) ' ,
1290
+ 'Null ' => 'NO ' ,
1291
+ 'Key ' => '' ,
1292
+ 'Default ' => '0 ' ,
1293
+ 'Extra ' => '' ,
1294
+ ),
1295
+ ),
1296
+ $ results
1297
+ );
1298
+ }
1299
+
1255
1300
public function testColumnWithOnUpdateAndNoIdField () {
1256
1301
// CREATE TABLE with ON UPDATE
1257
1302
$ this ->assertQuery (
Original file line number Diff line number Diff line change @@ -1017,13 +1017,20 @@ private function parse_create_table() {
1017
1017
* token is a data type.
1018
1018
*/
1019
1019
$ second_token = $ this ->rewriter ->peek_nth ( 2 );
1020
+ $ current_token = $ this ->rewriter ->peek ();
1020
1021
1021
1022
if ( $ second_token ->matches (
1022
1023
WP_SQLite_Token::TYPE_KEYWORD ,
1023
1024
WP_SQLite_Token::FLAG_KEYWORD_DATA_TYPE
1025
+ ) && !$ current_token ->matches (
1026
+ WP_SQLite_Token::TYPE_KEYWORD ,
1027
+ WP_SQLite_Token::FLAG_KEYWORD_RESERVED ,
1028
+ array ( 'KEY ' )
1024
1029
) ) {
1030
+ echo 'field ' ;
1025
1031
$ result ->fields [] = $ this ->parse_mysql_create_table_field ();
1026
1032
} else {
1033
+ echo 'constraint ' ;
1027
1034
$ result ->constraints [] = $ this ->parse_mysql_create_table_constraint ();
1028
1035
}
1029
1036
@@ -1236,6 +1243,7 @@ private function parse_mysql_create_table_constraint() {
1236
1243
}
1237
1244
1238
1245
$ result ->value = $ this ->normalize_mysql_index_type ( $ constraint ->value );
1246
+ echo 'result value: ' . $ result ->value . "\n" ;
1239
1247
if ( $ result ->value ) {
1240
1248
$ this ->rewriter ->skip (); // Constraint type.
1241
1249
You can’t perform that action at this time.
0 commit comments