Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ TOKEN:
* Supported tokens:
* - <S_IDENTIFIER>: Standard unquoted SQL identifier
* - <S_QUOTED_IDENTIFIER>: Quoted identifier (e.g., `identifier` or "identifier")
* - <K_NAME>, <K_NEXT>, <K_VALUE>, <K_PUBLIC>, <K_STRING>, <K_DATA>: Specific keywords treated as identifiers
* - <K_NAME>, <K_NEXT>, <K_VALUE>, <K_PUBLIC>, <K_STRING>, <K_DATA>, <K_TYPE>: Specific keywords treated as identifiers
*
* @return Token representing the identifier or keyword used as identifier
*/
Expand All @@ -1774,6 +1774,7 @@ Token KeywordOrIdentifier():
| tk = <K_PUBLIC>
| tk = <K_STRING>
| tk = <K_DATA>
| tk = <K_TYPE>
)
{ return tk; }
}
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ public void testAlterTableDropColumnIssue2339() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("ALTER TABLE test DROP COLUMN Data");
}

@Test
public void testAlterTableDropColumnIssue2447() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("ALTER TABLE test DROP COLUMN type");
}

@Test
public void testAlterTableDropConstraint() throws JSQLParserException {
final String sql = "ALTER TABLE test DROP CONSTRAINT YYY";
Expand Down Expand Up @@ -469,6 +474,11 @@ public void testAlterTableChangeColumnIssue2339() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("ALTER TABLE tb_test CHANGE data INT (10)");
}

@Test
public void testAlterTableChangeColumnIssue2447() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("ALTER TABLE tb_test CHANGE type INT (10)");
}

@Test
public void testAlterTableAddColumnWithZone() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed(
Expand Down Expand Up @@ -668,6 +678,18 @@ public void testAlterTableRenameColumn2() throws JSQLParserException {
assertEquals(expression.getColumnName(), "full_name");
}

@Test
public void testAlterTableRenameColumnIssue2447() throws JSQLParserException {
String sql = "ALTER TABLE test_table RENAME COLUMN type TO type2";
assertSqlCanBeParsedAndDeparsed(sql);

Alter alter = (Alter) CCJSqlParserUtil.parse(sql);
AlterExpression expression = alter.getAlterExpressions().get(0);
assertEquals(expression.getOperation(), AlterOperation.RENAME);
assertEquals(expression.getColOldName(), "type");
assertEquals(expression.getColumnName(), "type2");
}

@Test
public void testAlterTableForeignKeyIssue981() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed(
Expand Down
Loading