Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Draft: accounting for ignore case in sorting #2102

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

Draft
mipo256 wants to merge 1 commit into spring-projects:main
base: main
Choose a base branch
Loading
from mipo256:GH-2101

Conversation

Copy link
Contributor

@mipo256 mipo256 commented Aug 3, 2025
edited
Loading

Closes #2101


Field field = createField(entity, order);

OrderByField orderByField = OrderByField.from( //
Copy link
Member

@mp911de mp911de Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, Order By items accept an expression instead of being configured for case-insensitivity. Case-insensitive ordering requires some sort of normalization (upper or lower-case transformation) and that requires configuration as databases may have upper case or lower case indexes (e.g. spring-projects/spring-data-jpa#2420)

Copy link
Contributor Author

@mipo256 mipo256 Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this concern, and I agree. The case sensitivity is configured via Order#ignoreCase. I think we might consider to add a strategy interface, something like:

interface CaseSensitiveOrderExpressionMapper {
 // What is the contract here? What is the type of an argument?
 // Is it okay to just return String? Maybe we can go for Expression 
 String fromOrder(Order order);
}

This is a global strategy, we can make it a bit more fine-grained to be able to override its behavior on the method level via potentially new annotation

public @interface @OrderNormaliztion {
 
 String orderingClause();
 // Do we need an enum here? It is limiting the possible options. The alternative is to go for a String 
 enum NormalizationFunction {
 LOWER,
 UPPER
 }
}

The abstraction names etc. can vary of course, I want to communicate the overall idea.

As far as I understood this Spring Data JPA 2420 ticket, there is a need for normalization function to be configurable. So I think we can add both the annotation and the strategy interface.

What are you thoughts on this, @mp911de

Copy link
Member

@mp911de mp911de Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have still too little insight for a full overview. In SQL, you can use additionally collations (ORDER BY <column> COLLATE <collation>, https://learn.microsoft.com/de-de/sql/t-sql/statements/collations?view=sql-server-ver17, https://www.postgresql.org/docs/current/collation.html#ICU-TAILORING-RULES) meaning that we can use either normalization or collations.

I started in JPA introducing JpqlQueryTemplates but that seems insufficient. Collations between the JVM and the database (e.g. upper in the database, upper on the JVM) might be different yielding different results.

The simplemost approach could be to use lowercase everywhere, a more sophisticated one to use configurable normalization and the most elaborate variant would be considering collations, maybe even on a per-table (domain type) and per-column (persistent property) basis. Let's discuss this once @schauder is back.

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

mp911de commented Aug 11, 2025

See #2101 (comment), I think this is something for the next (May 2026) release and we won't be able to include this for the November 2025 release.

mipo256 reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@mp911de mp911de mp911de left review comments

Assignees
No one assigned
Labels
type: enhancement A general enhancement
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Support case-insensitive sorting

AltStyle によって変換されたページ (->オリジナル) /