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 @@ -2280,6 +2280,12 @@ impl<'a> Parser<'a> {
2280
2280
Ok ( Some ( ColumnOption :: DialectSpecific ( vec ! [
2281
2281
Token :: make_keyword( "AUTOINCREMENT" ) ,
2282
2282
] ) ) )
2283
+ } else if self . parse_keywords ( & [ Keyword :: ON , Keyword :: UPDATE ] )
2284
+ && dialect_of ! ( self is MySqlDialect )
2285
+ {
2286
+ Ok ( Some ( ColumnOption :: DialectSpecific ( vec ! [
2287
+ Token :: make_keyword( "ON UPDATE" ) ,
2288
+ ] ) ) )
2283
2289
} else {
2284
2290
Ok ( None )
2285
2291
}
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