Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParseException: Encountered unexpected token: "inner" "INNER" #826

Closed
bruceauyeung opened this issue Jul 16, 2019 · 11 comments
Closed

ParseException: Encountered unexpected token: "inner" "INNER" #826

bruceauyeung opened this issue Jul 16, 2019 · 11 comments
Assignees

Comments

@bruceauyeung
Copy link

bruceauyeung commented Jul 16, 2019

sql:

update message_topic inner join message_topic_config on
 message_topic.id=message_topic_config.topic_id 
set message_topic_config.enable_flag='N', 
message_topic_config.updated_by='test', 
message_topic_config.update_at='2019-07-16' 
where message_topic.name='test' 
AND message_topic_config.enable_flag='Y'

Expected Behavior

the sql runs well on MariaDB-server-10.1.40-1.el7.centos.x86_64, i expect jsqlparser parses it also well

Actual Behavior

net.sf.jsqlparser.JSQLParserException: null
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:43)
	at com.zte.itp.seo.commons.sql.SqlTableNameCaseHandler.handle(SqlTableNameCaseHandler.java:72)
	at com.zte.itp.seo.Main.main(Main.java:214)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "inner" "INNER"
    at line 1, column 22.

Was expecting one of:

    ","
    "ACTION"
    "ANY"
    "AS"
    "BYTE"
    "CASCADE"
    "CAST"
    "CHAR"
    "COLUMN"
    "COLUMNS"
    "COMMENT"
    "COMMIT"
    "DESCRIBE"
    "DO"
    "ENABLE"
    "END"
    "EXTRACT"
    "FIRST"
    "FN"
    "FOLLOWING"
    "INDEX"
    "INSERT"
    "INTERVAL"
    "ISNULL"
    "KEY"
    "LAST"
    "MATERIALIZED"
    "NEXTVAL"
    "NO"
    "NULLS"
    "OPEN"
    "OVER"
    "PARTITION"
    "PATH"
    "PERCENT"
    "PRECISION"
    "PRIMARY"
    "PRIOR"
    "RANGE"
    "REPLACE"
    "ROW"
    "ROWS"
    "SEPARATOR"
    "SET"
    "SIBLINGS"
    "TABLE"
    "TEMP"
    "TEMPORARY"
    "TOP"
    "TRUNCATE"
    "TYPE"
    "UNSIGNED"
    "VALUE"
    "VALUES"
    "XML"
    "ZONE"
    <K_DATETIMELITERAL>
    <K_DATE_LITERAL>
    <S_CHAR_LITERAL>
    <S_IDENTIFIER>
    <S_QUOTED_IDENTIFIER>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:20951)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:20798)
	at net.sf.jsqlparser.parser.CCJSqlParser.Update(CCJSqlParser.java:745)
	at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:127)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:70)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:41)
	... 2 common frames omitted

Specifications

  • Version: 2.1
  • Platform: centos 7 64bit
  • Java version: 1.8.0_211

@wumpz

@bruceauyeung
Copy link
Author

bruceauyeung commented Jul 18, 2019

@wumpz would you please take a look ?
thanks !

@wumpz
Copy link
Member

wumpz commented Jul 18, 2019

This syntax update table1 join table2 ... set ... is not (yet) supported. PRs are welcome.

@wumpz
Copy link
Member

wumpz commented Jul 21, 2019

At the moment there are no plans to support this. Or is this an urgent request?

@bruceauyeung
Copy link
Author

@wumpz it's urgent to me. i have tried SQL parser in Alibaba druid library, it supports table join,
thanks for your effort!

@wumpz
Copy link
Member

wumpz commented Jul 23, 2019

I will look into it.

@wumpz wumpz self-assigned this Aug 7, 2019
@wumpz
Copy link
Member

wumpz commented Aug 8, 2019

Sorry, it took a while. Now I am on it.

@wumpz wumpz closed this as completed in 01296c3 Aug 9, 2019
wumpz added a commit that referenced this issue Aug 9, 2019
@wumpz
Copy link
Member

wumpz commented Aug 9, 2019

Could you check it? I changed the version to 3.0-SNAPSHOT due to API changes introduced by the solution of your request.

@mantou16
Copy link

mantou16 commented Nov 2, 2019

@wumpz could you please kindly share why getTables() is removed and replaced with getTable(), seems like roll back to the version before 5/25/2014 commit. Thank you!!

@wumpz
Copy link
Member

wumpz commented Nov 2, 2019

@mantou16 this was indeed an API change. So maybe this had to be in version 4. Sorry about that.

The cause was #826. Now JSqlParser supports not only multiple tables, but joins at the start. (01296c3#diff-609c7e6ed30a0309ddb39397703f93f1)
As you see it is not a step backward but a step forward.

So to get what you want is now a combination of getTable + getStartJoins.

@wumpz
Copy link
Member

wumpz commented Nov 2, 2019

@mantou16 as you see here:

assertSqlCanBeParsedAndDeparsed("UPDATE T1, T2 SET T1.C2 = T2.C2, T2.C3 = 'UPDATED' WHERE T1.C1 = T2.C1 AND T1.C2 < 10");

the test for multi table list is still intact.

@mantou16
Copy link

mantou16 commented Nov 2, 2019

@mantou16 as you see here:

assertSqlCanBeParsedAndDeparsed("UPDATE T1, T2 SET T1.C2 = T2.C2, T2.C3 = 'UPDATED' WHERE T1.C1 = T2.C1 AND T1.C2 < 10");

the test for multi table list is still intact.

got it! thank you so much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants