Skip to content
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

Allow configuration of transformation for case-insensitive queries #2420

Open
ViktarRVR opened this issue Jan 26, 2022 · 13 comments
Open

Allow configuration of transformation for case-insensitive queries #2420

ViktarRVR opened this issue Jan 26, 2022 · 13 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@ViktarRVR
Copy link

ViktarRVR commented Jan 26, 2022

We use Spring Data JPA + Querydsl JPA. If we perform queries with ignoreCase keyword in repository methods Spring data JPA use UPPER function on parameters in SQL(as described in documentation, Table 3. Supported keywords inside method names), but Querydsl JPA uses LOWER function. We should use two types of indexes or don't use ignoreCase keyword in repository methods.

It would be great, if it was possible to configured to use UPPER function or LOWER function in Spring Data JPA.

See also #3540

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 26, 2022
@odrotbohm odrotbohm added in: querydsl Querydsl integration and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 7, 2022
@steveratay
Copy link

I ran into the same problem in the query by example code. It also appears to be hard-coded to use a lower conversion. As stated above, this is challenging because I only want to maintain a single case-insensitive index on either the upper or lowercase version of certain columns.

See https://github.com/spring-projects/spring-data-jpa/blob/main/src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java#L182.

It would be great if this were able to be customized in the ExampleMatcher methods.

@gregturn
Copy link
Contributor

gregturn commented Mar 18, 2022

Whereas another knob would work, I wonder if it isn't simpler to just update things to use lower across the board.

gregturn added a commit that referenced this issue Mar 18, 2022
To avoid developers having to maintain multiples indices, use 'lower' for all ignoreCase operations (JSqlParser, QueryByExample, Querydsl).

Resolves #2420.
@gregturn gregturn added type: enhancement A general enhancement in: query-parser Everything related to parsing JPQL or SQL labels Mar 18, 2022
@schauder
Copy link
Contributor

Going consistently with lower sounds like a good way to go. Please make sure to have this change included in release notes since it might disable existing indexes and therefore cause a performance degradation when not addressed.

gregturn added a commit that referenced this issue Mar 22, 2022
To avoid developers having to maintain multiples indices, use 'lower' for all ignoreCase operations (JSqlParser, QueryByExample, Querydsl).

Resolves #2420.
gregturn added a commit that referenced this issue Mar 22, 2022
To avoid having to maintain multiples indices, use 'lower' for all ignoreCase operations (JSqlParser, QueryByExample, Querydsl).

See #2420.
gregturn added a commit that referenced this issue Mar 22, 2022
To avoid having to maintain multiples indices, use 'lower' for all ignoreCase operations (JSqlParser, QueryByExample, Querydsl).

See #2420.
@gregturn
Copy link
Contributor

This has been merged to main and to 3.0.x.

@gregturn gregturn changed the title IgnoreCase use Upper function in repository method names and cannot be configured. IgnoreCase uses Upper function in repository method names and cannot be configured. Mar 22, 2022
@gregturn
Copy link
Contributor

@OrangeDog
Copy link

OrangeDog commented Feb 15, 2024

Did this get reverted, or did I miss something? According to the logged HQL, 3.2.2 is using upper instead of lower.

Edit:
15e8e3b doesn't look right at all. All it did was change a variable name from lower to upper.

@danwatt
Copy link

danwatt commented Feb 15, 2024

I am with @OrangeDog - I just wrapped up dropping an UPPER index thinking this had been resolved in 2.7.x, only to discover that a QueryDsl Repository IgnoreCase method is still generating where upper(...)=upper(?)

I am on 2.7.18 for this project, upgraded to 2.6.x, and was following the release notes assuming this had been fixed in 2.7: https://github.com/spring-projects/spring-data-commons/wiki/Spring-Data-2021.2-(Raj)-Release-Notes#ignorecase-operators-now-use-lower-functions-across-the-board

@OrangeDog
Copy link

@danwatt QueryDSL is using lower, repositories are using upper. Same as described in the original issue.

@OrangeDog
Copy link

@gregturn @mp911de can this be reopened? It was not fixed. It looks like someone messed up resolving conflicts in the merge or something.

@mp911de mp911de reopened this Nov 19, 2024
@mp911de
Copy link
Member

mp911de commented Nov 19, 2024

Sure. We've started exploring configuration for ignore-case transformations with https://github.com/spring-projects/spring-data-jpa/pull/3653/files#diff-fdc19ed3d18aab513d05cd0418ab02dbaa8f1bdf5f8f8574d26d1ecdd9914486

@mp911de mp911de removed the in: query-parser Everything related to parsing JPQL or SQL label Nov 19, 2024
@mp911de mp911de assigned mp911de and unassigned gregturn Nov 19, 2024
@mp911de mp911de changed the title IgnoreCase uses Upper function in repository method names and cannot be configured. IgnoreCase uses Upper function in repository method names and cannot be configured Nov 22, 2024
@mp911de mp911de removed this from the 2.7 RC1 (2021.2.0) milestone Nov 22, 2024
@mp911de mp911de changed the title IgnoreCase uses Upper function in repository method names and cannot be configured Allow configuration of transformation for case-insensitive queries Nov 22, 2024
@mp911de mp911de removed the in: querydsl Querydsl integration label Nov 22, 2024
@mp911de
Copy link
Member

mp911de commented Nov 22, 2024

This change concerns:

  • Derived Queries (JPQL)
  • Querydsl
  • QueryByExamplePredicateBuilder
  • SimpleJpaRepository

for Sorting and predicates

@OrangeDog
Copy link

Is there any plan to actually fix this issue as originally intended (i.e. make everything use lower)? That would be much easier than adding new configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

9 participants