JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

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

Open csxcsx00 opened this issue 4 years ago • 3 comments

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…

csxcsx00 avatar Jul 07 '21 11:07 csxcsx00

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.

manticore-projects avatar Jul 08 '21 04:07 manticore-projects

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?

csxcsx00 avatar Jul 09 '21 08:07 csxcsx00

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.

manticore-projects avatar Jul 09 '21 08:07 manticore-projects