Skip to content

Allow whitespace in JPQL and EQL JDBC escape literals. - #4294

Open
jewoodev wants to merge 1 commit into
spring-projects:mainfrom
jewoodev:jdbc-escape-whitespace
Open

jewoodev wants to merge 1 commit into
spring-projects:mainfrom
jewoodev:jdbc-escape-whitespace

Conversation

@jewoodev

@jewoodev jewoodev commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

JPQL and EQL tokenize JDBC date, time, and timestamp escape literals as single tokens, requiring the marker to be directly followed by the quoted literal. This rejects common JDBC-style forms such as {d '2012-01-03'}.

This change aligns JPQL and EQL parsing with HQL's *_ESCAPE_START structure. A shared JPQL, EQL, and HQL rendering path preserves both whitespace and no-whitespace forms, covered by the shared renderer TCK.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@jewoodev jewoodev changed the title Allow whitespace in JPQL and EQL JDBC escape literals Allow whitespace in JPQL and EQL JDBC escape literals. Jul 4, 2026
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 4, 2026
DATELITERAL : '{' D STRINGLITERAL '}';
TIMELITERAL : '{' T STRINGLITERAL '}';
TIMESTAMPLITERAL : '{' T S STRINGLITERAL '}';
DATELITERAL : '{' D [ \t\r\n]* STRINGLITERAL '}';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about switching the general logic towards TIMESTAMP_ESCAPE_START (dateTime | genericTemporalLiteralText) '}' style as it is done in the HQL parser? The TIMESTAMP_ESCAPE_START is a bit strange though but it seems to require much less ceremony. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree that this structure is cleaner. I updated JPQL and EQL to use *_ESCAPE_START ... '}' parser rules, following HQL's approach. Since JPQL and EQL do not have HQL's structured dateTime, date, and time rules, they retain their existing quoted-literal scope through generic_temporal_literal_text.

Splitting the composite lexer tokens also exposed a round-trip detail: the default renderer adds a space before }, while always rendering inline changes the existing no-whitespace forms. I therefore introduced a shared JDBC escape rendering path for JPQL, EQL, and HQL that preserves whether whitespace follows the marker. The shared renderer TCK now covers both forms for date, time, and timestamp literals.

Replace the composite JDBC date, time, and timestamp lexer tokens with
parser rules based on `TIMESTAMP_ESCAPE_START`, `DATE_ESCAPE_START`, and
`TIME_ESCAPE_START`.

Use a shared rendering path for JPQL, EQL, and HQL that preserves whether
whitespace follows the escape marker. Cover both whitespace and
no-whitespace forms through the shared renderer TCK.

Signed-off-by: jewoodev <jewoos15@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants