-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
How to sort by a String field in a case insensitive way? #448
Comments
Your solution is looks good. There are some other solutions you could consider:
For the solutions that require fragments, there isn't anything that Flop could do for you, unfortunately, since I don't want to use any adapter-specific fragments. |
Thanks for the reply. For alias field method, could you give me an example? Thanks. I just feel strange that I have to use a sub query and lateral join for a field that is in the same table. |
I know it's strange, but Postgres is usually able to optimize such lateral joins on simple sub queries. Please confirm the query plan. There's an example for alias fields in the documentation section I linked above. |
@MaccaCHAN I think citext is a good option as well. For either approach, you'll want to consider how querying on lowercase will impact performance if have an index on fields you're trying to do a case insensitive search (Even with citext). https://www.postgresql.org/docs/current/citext.html#CITEXT-LIMITATIONS I think custom fields would also be a good solution, and probably very reusable with less custom query code as you need to reuse the approach. I haven't tried compiling or running the code below, but I think it would work.
|
With the default way of sorting, it is case sensitive. If I would like to sort case insensitively, what is the most direct way to do this?
I can achieve the result I wanted by join fields like below. I am wondering if there are some more direct way to achieve this. Thanks.
The text was updated successfully, but these errors were encountered: