File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -1468,6 +1468,29 @@ mod tests {
14681468 assert_eq ! ( format( input, & QueryParams :: None , & options) , expected) ;
14691469 }
14701470
1471+ #[ test]
1472+ fn it_formats_alter_table_add_and_drop ( ) {
1473+ let input = r#"ALTER TABLE "public"."event" DROP CONSTRAINT "validate_date", ADD CONSTRAINT "validate_date" CHECK (end_date IS NULL
1474+ OR (start_date IS NOT NULL AND end_date > start_date));"# ;
1475+
1476+ let options = FormatOptions :: default ( ) ;
1477+ let expected = indoc ! (
1478+ r#"
1479+ ALTER TABLE
1480+ "public"."event"
1481+ DROP CONSTRAINT "validate_date",
1482+ ADD CONSTRAINT "validate_date" CHECK (
1483+ end_date IS NULL
1484+ OR (
1485+ start_date IS NOT NULL
1486+ AND end_date > start_date
1487+ )
1488+ );"#
1489+ ) ;
1490+
1491+ assert_eq ! ( format( input, & QueryParams :: None , & options) , expected) ;
1492+ }
1493+
14711494 #[ test]
14721495 fn it_recognizes_bracketed_strings ( ) {
14731496 let inputs = [ "[foo JOIN bar]" , "[foo ]] JOIN bar]" ] ;
@@ -2239,8 +2262,7 @@ mod tests {
22392262 -- 自动加载数据到 Hive 分区中
22402263 ALTER TABLE
22412264 sales_data
2242- ADD
2243- PARTITION (sale_year = '2024', sale_month = '08') LOCATION '/user/hive/warehouse/sales_data/2024/08';"
2265+ ADD PARTITION (sale_year = '2024', sale_month = '08') LOCATION '/user/hive/warehouse/sales_data/2024/08';"
22442266 ) ;
22452267
22462268 assert_eq ! ( format( input, & QueryParams :: None , & options) , expected) ;
Original file line number Diff line number Diff line change @@ -504,7 +504,6 @@ fn get_top_level_reserved_token<'a>(
504504 // Match keywords based on their first letter
505505 let result: Result < & str > = match first_char {
506506 'A' => alt ( (
507- terminated ( "ADD" , end_of_word) ,
508507 terminated ( "AFTER" , end_of_word) ,
509508 terminated ( ( "ALTER " , alterable_or_droppable) . take ( ) , end_of_word) ,
510509 ) )
You can’t perform that action at this time.
0 commit comments