spring-data-jpa
spring-data-jpa copied to clipboard
Add Enable/disable option for Ignore case
Methods like findByNameIgnoringCase is adding UPPER irrespective of db level configurations and not hitting the indexes. In the scenario, we are supporting mssql and postgres, where postgres needs UPPER in where clause to achieve IgnoreCase whereas MSSQL does not need it. The query will work but it will not hit / use the index on name. Mssql doesnot support functions in Index otherwise we could have add an index with UPPER(name).
There was a similar issue reported a while ago. Not sure if it was for Spring Data JPA or JDBC. And can't find it anymore It was asking for making the function used (lower vs upper) configurable. We probably allow for three options: lower, upper, none
We should also consider introducing a configuration object that can also hold the escape character.
https://github.com/spring-projects/spring-data-jpa/issues/2420 is the issue where we aligned ALL querying, be it JPA or Querydsl, to use the same modifier for ignoresCase suffixes. Since Querydsl was using lower, we ensure everything else did the same.
That issue DID make a request to make this configurable. I will scan the code to see how invasive such a flag setting would be, and to see how easy it would be for Spring Boot to also access it should we apply it.
@gregturn that issue is where you said you would do that. But the associated commits did not appear to do that. It didn't add any tests to confirm it either.