Skip to content

Fix parsing of single-character string literals in JPQL and EQL collection member expressions.#4282

Closed
jewoodev wants to merge 2 commits into
spring-projects:mainfrom
jewoodev:fix-gh-4278-single-character-member-literal
Closed

Fix parsing of single-character string literals in JPQL and EQL collection member expressions.#4282
jewoodev wants to merge 2 commits into
spring-projects:mainfrom
jewoodev:fix-gh-4278-single-character-member-literal

Conversation

@jewoodev

@jewoodev jewoodev commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

JPQL and EQL currently tokenize a single-character quoted string such as 'c' as CHARACTER, while other quoted strings are tokenized as STRINGLITERAL. The literal parser rule accepted STRINGLITERAL but not CHARACTER, causing a single-character string literal to fail when used as the left operand of MEMBER OF.

This change adds CHARACTER to the JPQL and EQL literal rules and covers the collection-member case with a shared query renderer round-trip test.

Jakarta Persistence allows a literal as the left operand of MEMBER OF, defines string literals as single-quoted strings without distinguishing single-character strings from longer strings, and itself uses 'Joe' MEMBER OF p.nicknames as an example.

  • 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).

See #4278

…ction member expressions.

Signed-off-by: jewoodev <jewoos15@naver.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 10, 2026
@mp911de mp911de self-assigned this Jun 15, 2026
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 15, 2026
@mp911de

mp911de commented Jun 15, 2026

Copy link
Copy Markdown
Member

Thanks a lot. Do you have a few more examples where the single-char case falls short? Also, getting an overview of unintentionally enabling functionality that wasn't previously possible (or breaking existing) would be great. We might want to introduce a bit more test coverage and cross-check whether we have similar issues in the HQL parser.

Add renderer TCK coverage for additional collection membership predicates
using single-character string literals.

Cover NOT MEMBER OF and the same MEMBER OF predicate in subquery, update,
and delete where clauses.

Signed-off-by: jewoodev <jewoos15@naver.com>
@jewoodev

jewoodev commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback.

I pushed additional TCK coverage for the same root cause in collection-member expressions: NOT MEMBER OF and the same MEMBER OF predicate inside subqueries, UPDATE where clauses, and DELETE where clauses.

I also found MEMBER without OF while probing. These cases fail in JPQL and EQL on main and pass with this branch. Other common single-character string literal positions such as comparisons, IN items, constructor arguments, LIKE, TRIM, FUNCTION, CASE, and UPDATE assignments already parse on main because they can route through string_expression/string_literal rather than literal.

I will follow up with the check for unintended enablement or breakage, and with the HQL parser cross-check.

@mp911de

mp911de commented Jun 19, 2026

Copy link
Copy Markdown
Member

Alright, let me merge this PR. Once there is more, we can commit changes against the original bug report #4278

mp911de pushed a commit that referenced this pull request Jun 19, 2026
…ction member expressions.

Signed-off-by: jewoodev <jewoos15@naver.com>

Closes #4278
Original pull request: #4282
mp911de pushed a commit that referenced this pull request Jun 19, 2026
…ction member expressions.

Signed-off-by: jewoodev <jewoos15@naver.com>

Closes #4278
Original pull request: #4282
mp911de pushed a commit that referenced this pull request Jun 19, 2026
…ction member expressions.

Signed-off-by: jewoodev <jewoos15@naver.com>

Closes #4278
Original pull request: #4282
@mp911de mp911de added this to the 3.5.13 (2025.0.13) milestone Jun 19, 2026
@mp911de

mp911de commented Jun 19, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution. That's merged and backported now.

@mp911de mp911de closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants