Skip to content

Commit a25fb7c

Browse files
committed
fixes #551
1 parent f0ffe4c commit a25fb7c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,7 @@ AlterExpression AlterExpression():
34623462
alterExp.setOperation(AlterOperation.DROP);
34633463
}
34643464
(
3465-
( <K_COLUMN>
3465+
( (LOOKAHEAD(2) <K_COLUMN>)?
34663466
(tk=<S_IDENTIFIER> | tk=<S_QUOTED_IDENTIFIER>)
34673467
{
34683468
alterExp.setColumnName(tk.image);

src/test/java/net/sf/jsqlparser/test/alter/AlterTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,12 @@ public void testAlterTableAddColumnKeywordTypes() throws JSQLParserException {
244244
public void testDropColumnRestrictIssue510() throws JSQLParserException {
245245
assertSqlCanBeParsedAndDeparsed("ALTER TABLE TABLE1 DROP COLUMN NewColumn CASCADE");
246246
}
247+
248+
public void testDropColumnRestrictIssue551() throws JSQLParserException {
249+
Statement stmt = CCJSqlParserUtil.parse("ALTER TABLE table1 DROP NewColumn");
250+
251+
// COLUMN keyword appears in deparsed statement, drop becomes all caps
252+
assertStatementCanBeDeparsedAs(stmt, "ALTER TABLE table1 DROP COLUMN NewColumn");
253+
254+
}
247255
}

0 commit comments

Comments
 (0)