Skip to content

Commit 9c1a5a7

Browse files
authored
Don't fail parsing ALTER TABLE ADD COLUMN ending with a semicolon (apache#246)
This is a follow-up to apache#203 where ALTER TABLE ADD COLUMN support was initially implemented. Fixes apache#233.
1 parent f8feff4 commit 9c1a5a7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ impl Parser {
11991199
let mut options = vec![];
12001200
loop {
12011201
match self.peek_token() {
1202-
Token::EOF | Token::Comma | Token::RParen => break,
1202+
Token::EOF | Token::Comma | Token::RParen | Token::SemiColon => break,
12031203
_ => options.push(self.parse_column_option_def()?),
12041204
}
12051205
}

tests/sqlparser_common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,8 +1459,8 @@ fn parse_create_external_table_lowercase() {
14591459

14601460
#[test]
14611461
fn parse_alter_table() {
1462-
let add_column = "ALTER TABLE tab ADD COLUMN foo TEXT";
1463-
match verified_stmt(add_column) {
1462+
let add_column = "ALTER TABLE tab ADD COLUMN foo TEXT;";
1463+
match one_statement_parses_to(add_column, "ALTER TABLE tab ADD COLUMN foo TEXT") {
14641464
Statement::AlterTable {
14651465
name,
14661466
operation: AlterTableOperation::AddColumn { column_def },

0 commit comments

Comments
 (0)