Skip to content

[BUG] JSQLParser Version : 5.1 RDBMS : MySql can't parse simple update sql  #2136

Description

@leonchen83

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

  • Brief description of the failing SQL feature
    can't parse sql update QUOTE set GROUP_ID=11077, SYMBOL_ID=18099, SOURCE_ID=4911626959315300, PRODUCT_ID=305846785, COMPANY_ID=21, LOW=3671269332022271850, HIGH=2113385670496105969, OPEN=1043534829692535483, SCALE=106, STATUS=0, LADDERED=1 where ID=2384974680491559964

Reproduce code

public static void main(String[] args) {
	String sql = "update QUOTE set GROUP_ID=11077, SYMBOL_ID=18099, SOURCE_ID=4911626959315300, PRODUCT_ID=305846785, COMPANY_ID=21, LOW=3671269332022271850, HIGH=2113385670496105969, OPEN=1043534829692535483, SCALE=106, STATUS=0, LADDERED=1 where ID=2384974680491559964";
	try {
		CCJSqlParserUtil.parseStatements(sql);
	} catch (JSQLParserException e) {
		e.printStackTrace();
	}
}

Exception stack

net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
    at line 1, column 114.

Was expecting one of:

    "FROM"
    "LIMIT"
    "ORDER"
    "OUTPUT"
    "PREFERRING"
    "RETURN"
    "RETURNING"
    "WHERE"
    <EOF>
    <ST_SEMICOLON>

	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:444)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:414)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:377)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:367)
	at cn.nextop.erebor.core.common.storage.support.XPreparedStatementHandler.main(XPreparedStatementHandler.java:76)
Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
    at line 1, column 114.

Was expecting one of:

    "FROM"
    "LIMIT"
    "ORDER"
    "OUTPUT"
    "PREFERRING"
    "RETURN"
    "RETURNING"
    "WHERE"
    <EOF>
    <ST_SEMICOLON>

	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:205)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:437)
	... 4 more
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
    at line 1, column 114.

Was expecting one of:

    "FROM"
    "LIMIT"
    "ORDER"
    "OUTPUT"
    "PREFERRING"
    "RETURN"
    "RETURNING"
    "WHERE"
    <EOF>
    <ST_SEMICOLON>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:48520)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:48341)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:1071)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil$2.call(CCJSqlParserUtil.java:433)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil$2.call(CCJSqlParserUtil.java:430)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Software Information:

  • JSqlParser version : 5.1
  • Database MySql

Tips:

Please write in English and avoid Screenshots (as we can't copy and paste content from it).
Try your example online with the latest JSQLParser and share the link in the error report.
Do provide Links or References to the specific Grammar and Syntax you are trying to use.

Activity

  1. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    I think this is a result of this PR, where the word "LOW" was added as a restricted keyword to support Skyline syntax -> #2078

  2. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    The "HIGH" restricted keyword was also added in the same PR, so this will also be impacting the parsing of the same UPDATE statement

  3. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    Adding "s around the LOW and HIGH columns seems to help, the statement below parses successfully as far as I can see...

    update QUOTE
      set
        GROUP_ID = 11077,
        SYMBOL_ID = 18099,
        SOURCE_ID = 4911626959315300,
        PRODUCT_ID = 305846785,
        COMPANY_ID = 21,
        "LOW" = 3671269332022271850,
        "HIGH" = 2113385670496105969,
        OPEN = 1043534829692535483,
        SCALE = 106,
        STATUS = 0,
        LADDERED = 1
      where
        ID = 2384974680491559964
    
  4. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    In version 5.1

    These statements do not parse...

    UPDATE mytable SET low = 1, high = 2 WHERE id = 3;
    DELETE FROM mytable WHERE low = 1 AND high = 2;
    SELECT low, high FROM mytable;
    

    These statements successfully parse...

    UPDATE mytable SET "low" = 1, "high" = 2 WHERE id = 3;
    DELETE FROM mytable WHERE "low" = 1 AND "high" = 2;
    SELECT "low", "high" FROM mytable;
    
  5. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    Same thing for the "INVERSE", "PLUS" and "PREFERRING" restricted keywords also added in the same PR

  6. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    Ive created this PR which I think might fix the issue -> #2137

  7. nicky6s commented on Jan 5, 2025

    @nicky6s
    Contributor

    Added this discussion -> #2138

  8. nicky6s commented on Jan 7, 2025

    @nicky6s
    Contributor

    #2137 is merged

  9. manticore-projects commented on Jan 14, 2025

    @manticore-projects
    Contributor

    I think this has been resolved.

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