Skip to content

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

Closed

Description

@csxcsx00

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…

Activity

  1. manticore-projects commented on Jul 8, 2021

    @manticore-projects
    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.

  2. changed the title [-]net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("[/-] [+]JSqlParser doesn't support converting a value to a specified character set[/+] on Jul 8, 2021
  3. 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[/+] on Jul 8, 2021
  4. csxcsx00 commented on Jul 9, 2021

    @csxcsx00
    Author

    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?

  5. manticore-projects commented on Jul 9, 2021

    @manticore-projects
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions