fluent-kit icon indicating copy to clipboard operation
fluent-kit copied to clipboard

Case/diacritic insensitive sorting

Open Jeehut opened this issue 5 years ago • 2 comments

First, I'm sorry if I created this in the wrong place (I wasn't sure if to create here on on the Fluent repository). Next, I'd like to note that no issue template is provided on GitHub at the time of this writing, it would probably be helpful to create some.

Now to my issue: I'd like to sort all entries in my Task model using the PostgreSQL driver by the name field. But I'd like to sort it in a case-insensitive manner. I found some discussions about case-insensitive filtering (which also seems to be a still unresolved issue within Fluent), but I've found no mentions of sorting anywhere.

As a first step, I'd be happy if the case-insensitivity was provided at all, even if it is using English as the language. As an improvement it could learn to be language-agnostic, or in the best case even support diacritic-insensitive sorting, too (e.g. ü/Ü/u/u/ú/ù/Ú/Ù would all be equal).

Combining case- and diacritic-insensitive sorting would allow for the typically expected sorting, so I think this is key.

Jeehut avatar Oct 18 '20 12:10 Jeehut

I was able to do this in my query (postgres):

.sort(.custom("lower(field_name)"))

grennis avatar Nov 12 '20 16:11 grennis

This is probably out of scope for Fluent since the supported databases don't all support this. Providing a custom query with SQL for the sort function or lowercase function etc is probably the way forward as Fluent needs to be the lowest common denominator of all DBs.

Agree @gwynne ?

0xTim avatar Nov 18 '20 10:11 0xTim