Skip to content

Allow configuration of transformation for case-insensitive queries #2420

Open

Description

@ViktarRVR

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

Activity

  1. added
    in: querydsl
    and removed
    status: waiting-for-triage
    on Feb 7, 2022
  2. steveratay commented on Mar 4, 2022

    @steveratay

    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.

  3. gregturn commented on Mar 18, 2022

    @gregturn
    Contributor

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

  4. added a commit that references this issue on Mar 18, 2022
    effddbf
  5. added
    type: enhancement
    in: query-parser
    on Mar 18, 2022
  6. schauder commented on Mar 22, 2022

    @schauder
    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.

  7. gregturn commented on Mar 22, 2022

    @gregturn
    Contributor

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

  8. 6 remaining items

  9. OrangeDog commented on Feb 15, 2024

    @OrangeDog

    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.

  10. danwatt commented on Feb 15, 2024

    @danwatt

    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

  11. OrangeDog commented on Feb 15, 2024

    @OrangeDog

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

  12. OrangeDog commented on Nov 19, 2024

    @OrangeDog

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

  13. mp911de commented on Nov 19, 2024

    @mp911de
    Member
  14. removed
    in: query-parser
    on Nov 19, 2024
  15. assigned and unassigned on Nov 19, 2024
  16. 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[/+] on Nov 22, 2024
  17. removed this from the 2.7 RC1 (2021.2.0) milestone on Nov 22, 2024
  18. changed the title [-]IgnoreCase uses Upper function in repository method names and cannot be configured[/-] [+]Allow configuration of transformation for case-insensitive queries[/+] on Nov 22, 2024
  19. removed
    in: querydsl
    on Nov 22, 2024
  20. mp911de commented on Nov 22, 2024

    @mp911de
    Member

    This change concerns:

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

    for Sorting and predicates

  21. OrangeDog commented on Nov 22, 2024

    @OrangeDog

    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

Metadata

Metadata

Assignees

Labels

type: enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions