Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upEncountered unexpected token: "IF" "IF" when drop table if exists `table1` #960
Comments
|
You are using a quite old version of JSqlParser. Version 3.1 successfully parses your statement. |
Describe the bug
Encountered unexpected token: "IF" "IF" when drop table if exists
table1To Reproduce
Steps to reproduce the behavior:
Example SQL
drop table if exists
table1Parsing this SQL using JSqlParser with this statements
String sqlTemp = "drop table if exists
table1";CCJSqlParserManager parserManager = new CCJSqlParserManager();
Statement parser = parserManager.parse(new StringReader(sqlTemp));
Exception
Encountered unexpected token: "IF" "IF" when drop table if exists
table1Expected behavior
parser.toString() == "drop table if exists
table1", not exceptionSystem
### resolve it, modify the code :
final public Drop Drop() throws ParseException {
Drop drop = new Drop();
Token tk = null;
List dropArgs = new ArrayList();
jj_consume_token(K_DROP);
switch ((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S_IDENTIFIER: {
tk = jj_consume_token(S_IDENTIFIER);
break;
}
case K_TABLE: {
tk = jj_consume_token(K_TABLE);
break;
}
case K_INDEX: {
tk = jj_consume_token(K_INDEX);
break;
}
default:
jj_la1[257] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
drop.setType(tk.image);
and Drop.java
public class Drop implements Statement {