JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

SET clause with alias not parsed

Open rptr opened this issue 4 years ago • 1 comments

Describe the bug

I found this query in the MySQL 8.0 Reference Manual page 2678

To Reproduce 1. INSERT INTO t1 SET a=1,b=2,c=3 AS new(m,n,p) ON DUPLICATE KEY UPDATE c = m+n; 2. CCJSqlParserUtil.parse(query) 3. Exception:

net.sf.jsqlparser.JSQLParserException
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:65)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:40)
	Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "AS" "AS"
    at line 1, column 32.
    Was expecting one of:
    "&"
    ","
    "::"
    ";"
    "<<"
    ">>"
    "COLLATE"
    "ON"
    "RETURNING"
    "["
    "^"
    "|"
    <EOF>

Expected behavior I expected example queries from the MySQL manual to be parsed correctly.

System

  • MySQL
  • Java 8 (OpenJDK)
  • JSqlParser 4.1

rptr avatar Aug 26 '21 10:08 rptr

Greetings.

the as new(m, n, p,) is MySQL specific and not supported. Please see the allowed/understood syntax here: http://217.160.215.75:8080/jsqlformatter/_static/railroad_diagram.xhtml#Update

manticore-projects avatar Aug 26 '21 11:08 manticore-projects