glassfish
  1. glassfish
  2. GLASSFISH-550

JPQL: misleading error message for invalid query

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 9.0pe
    • Fix Version/s: 9.1pe_dev
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      550

      Description

      The JPQL query compiler sometimes throws a misleading error message for an
      invalid query. It complains about an unexpected token, where the token named in
      the error message is correct, but the following token is unexpected.

      Here are some examples (there might be more):

      (1) SELECT c FORM Customer c
      Syntax error parsing the query [SELECT c FORM Customer c], unexpected token [c].
      There is a typo in the query: the keyword FROM is misspelled. The error message
      says token c is unexpected, but c after SELECT is correct. Instead it should
      say: unexpected token [FORM].

      (2) SELECT COUNT(c FROM Customer c
      Syntax error parsing the query [SELECT COUNT(c FROM Customer c], unexpected
      token [c].
      The COUNT aggregate misses the closing parenthesis, but the error message
      complains about c being unexpected. It should say: unexpected token [FROM].

      (3) SELECT c FROM Customer c WHERE c.name LIKE 1
      Syntax error parsing the query [SELECT c FROM Customer c WHERE c.name LIKE 1],
      unexpected token [LIKE].
      The LIKE pattern cannot be an integer literal, but the error message complains
      about LIKE being unexpected. It should say: unexpected token [1].

      (4) SELECT c FROM Customer c WHERE c.orders IS EMPYT
      Syntax error parsing the query [SELECT c FROM Customer c WHERE c.orders IS
      EMPYT], unexpected token [IS].
      The keyword EMPTY after IS is misspelled. The error message should be:
      unexpected token [EMPYT].

      (5) SELECT c FROM Customer c WHERE :param MEMBER c
      Syntax error parsing the query [SELECT c FROM Customer c WHERE :param MEMBER c],
      unexpected token [MEMBER].
      The MEMBER expression needs to be a path expression, so it cannot be a variable.
      The error message should be: unexpected token [c].

        Issue Links

          Activity

          Hide
          vince kraemer added a comment -

          error message improvement initiative

          Show
          vince kraemer added a comment - error message improvement initiative
          Hide
          marina vatkina added a comment -

          All misleading messages must be fixed for 9.1

          Show
          marina vatkina added a comment - All misleading messages must be fixed for 9.1
          Hide
          jielin added a comment -

          working on it.

          Show
          jielin added a comment - working on it.
          Hide
          jielin added a comment -
              • Issue 1165 has been marked as a duplicate of this issue. ***
          Show
          jielin added a comment - Issue 1165 has been marked as a duplicate of this issue. ***
          Hide
          jielin added a comment -

          Adding more test cases with have the similar error:

          SELECT e* FROM Employee e
          NoViableAltException "line 1:8 unexpected token : e"

          SELECT c FROM Customer c WHERE c.orders IS nall
          Syntax error parsing the query [SELECT c FROM Customer c WHERE c.orders IS
          EMPYT], unexpected token [IS].
          The keyword EMPTY after IS is misspelled. The error message should be:
          unexpected token [nall].

          SELECT c FROM Customer c WHERE c.name IN 1.5
          Syntax error parsing the query [SELECT c FROM Customer c WHERE c.name IN 1.5],
          unexpected token [IN].
          The LIKE pattern cannot be an integer literal, but the error message complains
          about LIKE being unexpected. It should say: unexpected token [1.5].

          The fix is in my workspace and try to cover all test cases for similar error.

          Show
          jielin added a comment - Adding more test cases with have the similar error: SELECT e* FROM Employee e NoViableAltException "line 1:8 unexpected token : e" SELECT c FROM Customer c WHERE c.orders IS nall Syntax error parsing the query [SELECT c FROM Customer c WHERE c.orders IS EMPYT], unexpected token [IS] . The keyword EMPTY after IS is misspelled. The error message should be: unexpected token [nall] . SELECT c FROM Customer c WHERE c.name IN 1.5 Syntax error parsing the query [SELECT c FROM Customer c WHERE c.name IN 1.5] , unexpected token [IN] . The LIKE pattern cannot be an integer literal, but the error message complains about LIKE being unexpected. It should say: unexpected token [1.5] . The fix is in my workspace and try to cover all test cases for similar error.
          Hide
          jielin added a comment -

          Check in the code which fix all above test cases.

          But there is one case:
          SELECT COUNT(disctint c) FROM Customer c
          Syntax error parsing the query [SELECT c FORM Customer c], unexpected token [c].
          It should complain disctint is typo. But this case JPQL compiler may expecting
          IDENTIFIER, it treats disctint as IDENT. So can not fix this error message.

          Show
          jielin added a comment - Check in the code which fix all above test cases. But there is one case: SELECT COUNT(disctint c) FROM Customer c Syntax error parsing the query [SELECT c FORM Customer c] , unexpected token [c] . It should complain disctint is typo. But this case JPQL compiler may expecting IDENTIFIER, it treats disctint as IDENT. So can not fix this error message.
          Hide
          jielin added a comment -

          change target milestone.

          Show
          jielin added a comment - change target milestone.
          Hide
          marina vatkina added a comment -

          Fixed build#

          Show
          marina vatkina added a comment - Fixed build#

            People

            • Assignee:
              jielin
              Reporter:
              mb124283
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: