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

IgnoreCase works only if a String property can be resolved to a column #518

Closed
hakandilek opened this issue Dec 26, 2020 · 3 comments
Closed
Assignees
Labels
type: bug A general bug

Comments

@hakandilek
Copy link

Hello everyone,

I have the following select query using R2dbcEntityTemplate:

template.select(Book.class)
        .matching(query(where("TITLE").like("%" + matchingTitle + "%").ignoreCase(true)))
        .all();

When I run this, it produces the following query:

SELECT T_BOOK.* FROM T_BOOK WHERE T_BOOK.TITLE LIKE UPPER($1) {1: '%title%'}

I would expect that T_BOOK.TITLE would also be wrapped with the UPPER() function like the following:

SELECT T_BOOK.* FROM T_BOOK WHERE UPPER(T_BOOK.TITLE) LIKE UPPER($1) {1: '%title%'}

but it doesn't. In this case it does not produce real case-insensitive queries.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 4, 2021
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 7, 2021
@mp911de
Copy link
Member

mp911de commented Jan 7, 2021

Our QueryMapper validates ignore-case queries against the domain model. If the underlying property is a String, then we're wrapping the column name with UPPER(…).

Omitting that check seems to fix the issue.

@mp911de mp911de changed the title Case ignoring for "like" criteria IgnoreCase works only if property can be resolved to a column Jan 7, 2021
@mp911de mp911de changed the title IgnoreCase works only if property can be resolved to a column IgnoreCase works only if a String property can be resolved to a column Jan 7, 2021
@mp911de mp911de added this to the 1.1.7 (Neumann SR7) milestone Jan 7, 2021
mp911de added a commit that referenced this issue Jan 7, 2021
We now apply the UPPER function regardless of whether we could resolve the criteria property to a column. Previously, we required a resolved property of a String type which prevented non-mapped properties from case-insensitive queries.

Closes #518
mp911de added a commit that referenced this issue Jan 7, 2021
Reduce test method/class visibility.

See #518
@mp911de mp911de self-assigned this Jan 7, 2021
mp911de added a commit that referenced this issue Jan 7, 2021
We now apply the UPPER function regardless of whether we could resolve the criteria property to a column. Previously, we required a resolved property of a String type which prevented non-mapped properties from case-insensitive queries.

Closes #518
@mp911de mp911de closed this as completed in 6e7e039 Jan 7, 2021
mp911de added a commit that referenced this issue Jan 7, 2021
Reduce test method/class visibility.

See #518
@hakandilek
Copy link
Author

@mp911de thanks for the fix!

@ilkerkocatepe
Copy link

Hello everyone, I'm sorry for writing an old issue, but I didn't want to create new one.
I have a problem about Turkish chars.
For instance; "ilker" is the query parameter and the name in db is "İlker". These don't match.
Is there a way to use LOWER instead UPPER? I thought this will help me.

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

No branches or pull requests

4 participants