Reputation: 1124
I found the Scala slick package's "sortBy" method is not case sensitive. Ex:
after implementing the following command: q.sortBy(columnMap("name").desc)
, I got:
TestingIsFun, testing foo1, Testing foo,
Is this expected behavior? How can I make it case sensitive? Thx.
Upvotes: 2
Views: 869
Reputation: 12573
When it comes to the database, the sorting of particular column will be done according to the collation for that column. By default, MySQL uses case-insensitive collation (unless you specify binary
charset). You can override the default collation on any of the 4 levels (server, database, table or column) or even only in specific ORDER BY clause. Which way is the most efficient, depends on your particular use case. Using case-sensitive collation obviously affects performance, so most of the time it makes sense doing it either on table or on column level.
Upvotes: 1
Reputation: 13746
I think as it currently stands, slick just depends on the RDBMS default handling of case in sorting. You did not mention the RDBMS type, but e.g. in mysql, case-insensitive is the default in sorting. However, you can define a column to-be-sorted in a way overiding that, in mysql, as per Altering Mysql Table column to be case sensitive. This will work without having to touch the query or slick parameters, as the solution is at the schema definition level. It should be possible to define the column as a binary string in the first place, with slick if needed:
O.DBType("binary")
in the slick column definition should work for that.
Upvotes: 1