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

JSqlParser doesn't support convert function used as converting a value to a specified character set #1257

Closed
csxcsx00 opened this issue Jul 7, 2021 · 3 comments · Fixed by #1778

Comments

@csxcsx00
Copy link

csxcsx00 commented Jul 7, 2021

Describe the bug
ParseException occurs when parse SQL

To Reproduce
Steps to reproduce the behavior:

  1. Example SQL
    SELECT id,name,version,identity,type,desc,enable,content FROM tbl_template

WHERE (name like ?) ORDER BY convert(name using GBK) ASC
2. Parsing this SQL using JSqlParser with this statements
CCJSqlParserUtil.parse(String.class)
3. Exception
Exception in thread "main" net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "(" "("
at line 3, column 38.

Was expecting one of:

"&"
"&&"
","
"::"
";"
"<<"
">>"
"AND"
"ASC"
"AT"
"COLLATE"
"DESC"
"FOR"
"NULLS"
"OR"
"ORDER"
"XOR"
"["
"^"
"|"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:190)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:63)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:38)
at com.bes.enterprise.infra.amdb.open.cmd.SqlTest.main(SqlTest.java:12)

Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 3, column 38.

Was expecting one of:

"&"
"&&"
","
"::"
";"
"<<"
">>"
"AND"
"ASC"
"AT"
"COLLATE"
"DESC"
"FOR"
"NULLS"
"OR"
"ORDER"
"XOR"
"["
"^"
"|"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:26917)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:26753)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:93)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:188)
... 3 more

Expected behavior
Return instance of net.sf.jsqlparser.statement.select.Select

System

  • Database you are using
    MySQL 8.0.16
  • Java Version
    1.8.0_212
  • JSqlParser version
    4.0 / 4.1
    Uploading 110827_0f330 110827_0f330374_1957406 374_1957406.png…
@manticore-projects
Copy link
Contributor

MySQL CONVERT() character sets is not supported. https://www.w3schools.com/mysql/func_mysql_convert.asp
Please change the Caption of this issues to point on the correct problem.

@csxcsx00 csxcsx00 changed the title net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "(" JSqlParser doesn't support converting a value to a specified character set Jul 8, 2021
@csxcsx00 csxcsx00 changed the title JSqlParser doesn't support converting a value to a specified character set JSqlParser doesn't support convert function used as converting a value to a specified character set Jul 8, 2021
@csxcsx00
Copy link
Author

csxcsx00 commented Jul 9, 2021

MySQL CONVERT() character sets is not supported. https://www.w3schools.com/mysql/func_mysql_convert.asp
Please change the Caption of this issues to point on the correct problem.

Thanks for your answer, caption has been changed.
Are there any plans to fix this problem in the next version?

@manticore-projects
Copy link
Contributor

I work though the open issue from time to time and try to add the most useful statements with a focus on wide application and SQL standard compliance.

PRs are alsways most welcome and you best chance for exotic features like the MySQL specific Convert() function.

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

Successfully merging a pull request may close this issue.

2 participants