Add case-insensitive ordering

This commit is contained in:
2024-08-21 21:03:38 -04:00
parent 2c24e2e912
commit 27b8a83a7a
5 changed files with 81 additions and 6 deletions

View File

@@ -401,10 +401,13 @@ module Query =
{ it with Name = parts[0] }, Some $" {parts[1]}"
else it, None)
|> Seq.map (fun (field, direction) ->
match dialect, field.Name.StartsWith "n:" with
| PostgreSQL, true -> $"({ { field with Name = field.Name[2..] }.Path PostgreSQL})::numeric"
| SQLite, true -> { field with Name = field.Name[2..] }.Path SQLite
| _, _ -> field.Path dialect
if field.Name.StartsWith "n:" then
let f = { field with Name = field.Name[2..] }
match dialect with PostgreSQL -> $"({f.Path PostgreSQL})::numeric" | SQLite -> f.Path SQLite
elif field.Name.StartsWith "i:" then
let p = { field with Name = field.Name[2..] }.Path dialect
match dialect with PostgreSQL -> $"LOWER({p})" | SQLite -> $"{p} COLLATE NOCASE"
else field.Path dialect
|> function path -> path + defaultArg direction "")
|> String.concat ", "
|> function it -> $" ORDER BY {it}"