File tree 2 files changed +31
-0
lines changed 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -2254,6 +2254,12 @@ impl<'a> Parser<'a> {
2254
2254
Ok ( Some ( ColumnOption :: DialectSpecific ( vec ! [
2255
2255
Token :: make_keyword( "AUTOINCREMENT" ) ,
2256
2256
] ) ) )
2257
+ } else if self . parse_keywords ( & [ Keyword :: ON , Keyword :: UPDATE ] )
2258
+ && dialect_of ! ( self is MySqlDialect )
2259
+ {
2260
+ Ok ( Some ( ColumnOption :: DialectSpecific ( vec ! [
2261
+ Token :: make_keyword( "ON UPDATE" ) ,
2262
+ ] ) ) )
2257
2263
} else {
2258
2264
Ok ( None )
2259
2265
}
Original file line number Diff line number Diff line change @@ -834,6 +834,31 @@ fn parse_kill() {
834
834
) ;
835
835
}
836
836
837
+ #[ test]
838
+ fn parse_table_colum_option_on_update ( ) {
839
+ let sql1 = "CREATE TABLE foo (`modification_time` DATETIME ON UPDATE)" ;
840
+ match mysql ( ) . verified_stmt ( sql1) {
841
+ Statement :: CreateTable { name, columns, .. } => {
842
+ assert_eq ! ( name. to_string( ) , "foo" ) ;
843
+ assert_eq ! (
844
+ vec![ ColumnDef {
845
+ name: Ident :: with_quote( '`' , "modification_time" ) ,
846
+ data_type: DataType :: Datetime ,
847
+ collation: None ,
848
+ options: vec![ ColumnOptionDef {
849
+ name: None ,
850
+ option: ColumnOption :: DialectSpecific ( vec![ Token :: make_keyword(
851
+ "ON UPDATE"
852
+ ) ] ) ,
853
+ } , ] ,
854
+ } ] ,
855
+ columns
856
+ ) ;
857
+ }
858
+ _ => unreachable ! ( ) ,
859
+ }
860
+ }
861
+
837
862
fn mysql ( ) -> TestedDialects {
838
863
TestedDialects {
839
864
dialects : vec ! [ Box :: new( MySqlDialect { } ) ] ,
You can’t perform that action at this time.
0 commit comments