Skip to content

Avoid double-parenthesis in JpqlQueryBuilder.InPredicate rendering #3962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

cwangg897
Copy link
Contributor

Prevent duplicate parentheses when rendering IN/NOT IN predicates with expressions that already contain parentheses. Added logic to check if predicate string starts and ends with parentheses before wrapping with additional parentheses.

This change improves JPQL query readability by avoiding patterns like "field IN (('value1', 'value2'))" and ensures proper syntax for subqueries and already-parenthesized expressions.

Added comprehensive unit tests to verify the fix handles various scenarios including regular expressions, pre-parenthesized expressions, and subquery expressions.

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

Prevent duplicate parentheses when rendering IN/NOT IN predicates
with expressions that already contain parentheses. Added logic to
check if predicate string starts and ends with parentheses before
wrapping with additional parentheses.

This change improves JPQL query readability by avoiding patterns
like "field IN (('value1', 'value2'))" and ensures proper syntax
for subqueries and already-parenthesized expressions.

Added comprehensive unit tests to verify the fix handles various
scenarios including regular expressions, pre-parenthesized
expressions, and subquery expressions.

Signed-off-by: Choi Wang Gyu <dhkdrb897@gmail.com>
@cwangg897
Copy link
Contributor Author

I'm not sure if the code formatting has been properly applied.
I'm using IntelliJ IDEA, and I downloaded the eclipse-formatting.xml file from the official repository and applied it using the Eclipse Code Formatter plugin in IntelliJ.
Could you please check if the formatting looks correct?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 4, 2025
@mp911de
Copy link
Member

mp911de commented Aug 4, 2025

There are still more formatting-related changes than those concerning the actual change. Please make sure to reduce or remove all formatting-related changes, otherwise, this PR creates more work for us than addressing the issue ourselves.

@cwangg897
Copy link
Contributor Author

There are still more formatting-related changes than those concerning the actual change. Please make sure to reduce or remove all formatting-related changes, otherwise, this PR creates more work for us than addressing the issue ourselves.

Yes, I’ve removed it.

@mp911de mp911de added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 4, 2025
@mp911de mp911de self-assigned this Aug 4, 2025
@mp911de
Copy link
Member

mp911de commented Aug 4, 2025

Awesome, thank you.

@mp911de mp911de linked an issue Aug 4, 2025 that may be closed by this pull request
@mp911de mp911de changed the title Fix double parentheses in IN predicate rendering Avoid double-parenthesis in JpqlQueryBuilder.InPredicate rendering Aug 5, 2025
@mp911de mp911de added this to the 4.0 M5 (2025.1.0) milestone Aug 5, 2025
@mp911de
Copy link
Member

mp911de commented Aug 5, 2025

Thank you for your contribution. That's merged and polished now. The formatting changes originate from us not applying consistently our formatting style. Additionally, I have simplified the tests slightly.

mp911de pushed a commit that referenced this pull request Aug 5, 2025
Prevent duplicate parentheses when rendering IN/NOT IN predicates
with expressions that already contain parentheses. Added logic to
check if predicate string starts and ends with parentheses before
wrapping with additional parentheses.

This change improves JPQL query readability by avoiding patterns
like "field IN (('value1', 'value2'))" and ensures proper syntax
for subqueries and already-parenthesized expressions.

Added comprehensive unit tests to verify the fix handles various
scenarios including regular expressions, pre-parenthesized
expressions, and subquery expressions.

Signed-off-by: Choi Wang Gyu <dhkdrb897@gmail.com>

Closes #3961
Original pull request: #3962
@mp911de mp911de closed this Aug 5, 2025
mp911de added a commit that referenced this pull request Aug 5, 2025
Apply consistent formatting. Extract superinterface for rendering. Refine tests.

See #3961
Original pull request: #3962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid double-parenthesis in JpqlQueryBuilder.InPredicate rendering
3 participants