Add case-insensitive ordering
This commit is contained in:
@@ -450,6 +450,18 @@ let queryTests = testList "Query" [
|
||||
" ORDER BY data->>'Test'"
|
||||
"Order By not constructed correctly for numeric field"
|
||||
}
|
||||
test "succeeds for PostgreSQL case-insensitive ordering" {
|
||||
Expect.equal
|
||||
(Query.orderBy [ Field.Named "i:Test.Field DESC" ] PostgreSQL)
|
||||
" ORDER BY LOWER(data#>>'{Test,Field}') DESC"
|
||||
"Order By not constructed correctly for case-insensitive field"
|
||||
}
|
||||
test "succeeds for SQLite case-insensitive ordering" {
|
||||
Expect.equal
|
||||
(Query.orderBy [ Field.Named "i:Test.Field ASC" ] SQLite)
|
||||
" ORDER BY data->>'Test'->>'Field' COLLATE NOCASE ASC"
|
||||
"Order By not constructed correctly for case-insensitive field"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@@ -527,6 +527,7 @@ let findTests = testList "Find" [
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.GT "NumValue" 15 ] [ Field.Named "Id" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "five|four" "The documents were not ordered correctly"
|
||||
}
|
||||
@@ -537,9 +538,32 @@ let findTests = testList "Find" [
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName Any [ Field.GT "NumValue" 15 ] [ Field.Named "Id DESC" ]
|
||||
Expect.hasLength docs 2 "There should have been two documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "four|five" "The documents were not ordered correctly"
|
||||
}
|
||||
testTask "succeeds when sorting case-sensitively" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName All [ Field.LE "NumValue" 10 ] [ Field.Named "Value" ]
|
||||
Expect.hasLength docs 3 "There should have been three documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "three|one|two" "Documents not ordered correctly"
|
||||
}
|
||||
testTask "succeeds when sorting case-insensitively" {
|
||||
use! db = SqliteDb.BuildDb()
|
||||
do! loadDocs ()
|
||||
|
||||
let! docs =
|
||||
Find.byFieldsOrdered<JsonDocument>
|
||||
SqliteDb.TableName All [ Field.LE "NumValue" 10 ] [ Field.Named "i:Value" ]
|
||||
Expect.hasLength docs 3 "There should have been three documents returned"
|
||||
Expect.equal
|
||||
(docs |> List.map _.Id |> String.concat "|") "three|two|one" "Documents not ordered correctly"
|
||||
}
|
||||
]
|
||||
testList "firstByFields" [
|
||||
testTask "succeeds when a document is found" {
|
||||
|
||||
Reference in New Issue
Block a user