You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot parse column rename sql without COLUMN keyword #1516
Describe the bug
Cannot parse column rename sql without COLUMN keyword.
To Reproduce
Steps to reproduce the behavior:
Example SQL
ALTER TABLE table_a RENAME col_a TO col_b;
Parsing this SQL using JSqlParser with this statements
CCJSqlParserUtil.parse("ALTER TABLE table_a RENAME col_a TO col_b");
Exception
net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "col_a" <S_IDENTIFIER>
at line 1, column 28.
Was expecting:
"TO"
at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:31468)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:31301)
at net.sf.jsqlparser.parser.CCJSqlParser.AlterExpression(CCJSqlParser.java:17874)
at net.sf.jsqlparser.parser.CCJSqlParser.AlterTable(CCJSqlParser.java:17947)
at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:267)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:153)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:188)
Indeed the COLUMN keyword is mandatory.
In PostgreSQL COLUMN is supported, but optional: ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ] RENAME [ COLUMN ] column_name TO new_column_name
Activity
manticore-projects commentedon Apr 22, 2022
The supported Syntax is shown here: http://217.160.215.75:8080/jsqlformatter/_static/JSqlParserCC.xhtml#AlterTable
Indeed the
COLUMNkeyword is mandatory.In PostgreSQL
COLUMNis supported, but optional:ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ] RENAME [ COLUMN ] column_name TO new_column_name`RENAME ... TO ...` without `COLUMN` keyword
#1516 rename without column keyword (#1533)