Skip to content

[BUG] JSQLParser Version : 4.6 : If there is a '.' in JdbcNamedParameter, parsing will fail! #1768

Description

@Lzw2016

If there is a '.' in JdbcNamedParameter, parsing will fail:

  • SELECT 1 FROM dual WHERE a = :paramMap.aValue

SQL Example:

-- If there is a '.' sign in JdbcNamedParameter, parsing will fail
String sql = "SELECT 1 FROM dual WHERE a = :paramMap.aValue";
Statement statement = CCJSqlParserUtil.parse(sql);

-- This situation occurs when using the foreach tag of mybatis:
-- ... where line_no in ( :__frch_item_0.receipt_line_no,  :__frch_item_1.receipt_line_no,  :__frch_item_2.receipt_line_no)

Error Info:

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

Was expecting one of:

    "&"
    "::"
    "<<"
    ">>"
    "CONNECT"
    "EMIT"
    "GROUP"
    "HAVING"
    "START"
    "WINDOW"
    "["
    "^"
    "|"
    <EOF>
    <ST_SEMICOLON>

Activity

  1. manticore-projects commented on Apr 19, 2023

    @manticore-projects
    Contributor

    Yes, and I do not really understand why you would like to change that.
    The correct SQL should look like this:

    SELECT 1 FROM dual WHERE a = :aValue

    I have the feeling, that you would need to report this upstream to myBatis instead toJSQLParser.

  2. Lzw2016 commented on Apr 19, 2023

    @Lzw2016
    Author

    Okay, I have my own solution。
    I just think it's best not to restrict the naming of JdbcNamedParameter as spring jdbc's JdbcTemplate also supports the form of "a=: paramMap. aValue"

  3. added a commit that references this issue on Apr 29, 2023
    9da7a06
  4. added a commit that references this issue on Jun 1, 2023
    41b6fce
  5. added a commit that references this issue on Jun 15, 2023
    a815f5f
  6. added a commit that references this issue on Jun 27, 2023
    c79dfff
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