Skip to content

where table_name = select database() has exception #1508

Closed
@luoguohua

Description

@luoguohua

Describe the bug
paser where table_name = select database() has exception

To Reproduce Example

       public static void main(String[] args) throws JSQLParserException {
        String sql = " select table_name, table_comment, create_time, update_time from information_schema.tables " +
                " where table_schema = (select database()) ";
        Statement statement = CCJSqlParserUtil.parse(sql);
        System.out.println(statement.toString());
    }

Exception out

Exception in thread "main" net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "=" "="
    at line 1, column 112.

Was expecting one of:

    "&"
    "::"
    ";"
    "<<"
    ">>"
    "COLLATE"
    "CONNECT"
    "EMIT"
    "GROUP"
    "HAVING"
    "START"
    "["
    "^"
    "|"
    <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.seerbigdata.tourism.common.config.MybatisPlusConfig.main(MybatisPlusConfig.java:158)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "=" "="
    at line 1, column 112.

Was expecting one of:

    "&"
    "::"
    ";"
    "<<"
    ">>"
    "COLLATE"
    "CONNECT"
    "EMIT"
    "GROUP"
    "HAVING"
    "START"
    "["
    "^"
    "|"
    <EOF>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:31468)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:31301)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:163)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:188)
	... 3 more

System

  • MySQL-v8.0.27
  • java version "1.8.0_31"
  • JSqlParser 4.4

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