JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

`= BINARY ` AND `LIKE BINARY` are not support

Open lastmayday opened this issue 7 years ago • 1 comments

Actual Behavior

String sql = "SELECT Name FROM T_User WHERE Name = BINARY 'test' OR Name LIKE BINARY 'test-%'";
Statement stmt = CCJSqlParserUtil.parse(sql);

When I ran these code, I got an exception:

net.sf.jsqlparser.JSQLParserException
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:56)
	at org.lastmayday.example.parser.JSqlParser.main(JSqlParser.java:23)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "=" "= "" at line 1, column 36.
Was expecting one of:
    <EOF> 
    "AND" ...
    "FOR" ...
    "UNION" ...
    "GROUP" ...
    "ORDER" ...
    "HAVING" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...
    "START" ...
    "CONNECT" ...
    ";" ...
    "ORDER" ...
    "ORDER" ...
    
	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:16869)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:16722)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:91)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:54)
	... 1 more
Caused by:
net.sf.jsqlparser.parser.ParseException: Encountered " "=" "= "" at line 1, column 36.
Was expecting one of:
    <EOF> 
    "AND" ...
    "FOR" ...
    "UNION" ...
    "GROUP" ...
    "ORDER" ...
    "HAVING" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...
    "START" ...
    "CONNECT" ...
    ";" ...
    "ORDER" ...
    "ORDER" ...
    
	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:16869)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:16722)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:91)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:54)
	at org.lastmayday.example.parser.JSqlParser.main(JSqlParser.java:23)

But if I remove the BINARY, it works well.

String sql = "SELECT Name FROM T_User WHERE Name = 'test' OR Name LIKE 'test-%'";
Statement stmt = CCJSqlParserUtil.parse(sql);

Expected Behavior

No exception.

Specifications

  • Version:
<dependency>
    <groupId>com.github.jsqlparser</groupId>
    <artifactId>jsqlparser</artifactId>
    <version>1.1</version>
</dependency>
  • Platform: jdk1.8.0_144
  • Subsystem:

lastmayday avatar Mar 26 '18 09:03 lastmayday

Postgres implicit casts are not supported. Explicit casts will work fine. Duplicate of #1344.

manticore-projects avatar Oct 19 '21 14:10 manticore-projects

I am closing this since it is not support and won't be supported (unless any genius provided a PR).

manticore-projects avatar Sep 06 '23 07:09 manticore-projects