Skip to content

[mysql] can't parse convert function in order by clause #688

@HiwayChe

Description

@HiwayChe

Actual Behavior

 String sql2 = "select * from a order by convert(a.name using gbk) desc";
CCJSqlParserUtil.parse(sql2);

above code throws an exception:

Caused by:
net.sf.jsqlparser.parser.ParseException: Encountered " "(" "( "" at line 1, column 33.
Was expecting one of:
    <EOF> 
    "ASC" ...
    "DESC" ...
    "FOR" ...
    "UNION" ...
    "ORDER" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...
    "NULLS" ...
    ";" ...
    "," ...
    "|" ...
    "&" ...
    "^" ...
    "::" ...

    at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:16395)

Expected Behavior

I hope jsqlparse can support order by convert(column using charset) desc/asc

Steps to Reproduce the Problem

  1. use jsqlparse, version:1.0, (jsqlparse-1.3 has same issue)
  2. execute above code in IDE(java)
  3. throws exception

Specifications

  • Version:1.0
  • Platform:Windows, jdk8
  • Subsystem:

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