Add case-insensitive ordering
This commit is contained in:
@@ -613,6 +613,18 @@ public static class CommonCSharpTests
|
||||
{
|
||||
Expect.equal(Query.OrderBy([Field.Named("n:Test")], Dialect.SQLite), " ORDER BY data->>'Test'",
|
||||
"Order By not constructed correctly for numeric field");
|
||||
}),
|
||||
TestCase("succeeds for PostgreSQL case-insensitive ordering", () =>
|
||||
{
|
||||
Expect.equal(Query.OrderBy([Field.Named("i:Test.Field DESC")], Dialect.PostgreSQL),
|
||||
" ORDER BY LOWER(data#>>'{Test,Field}') DESC",
|
||||
"Order By not constructed correctly for case-insensitive field");
|
||||
}),
|
||||
TestCase("succeeds for SQLite case-insensitive ordering", () =>
|
||||
{
|
||||
Expect.equal(Query.OrderBy([Field.Named("i:Test.Field ASC")], Dialect.SQLite),
|
||||
" ORDER BY data->>'Test'->>'Field' COLLATE NOCASE ASC",
|
||||
"Order By not constructed correctly for case-insensitive field");
|
||||
})
|
||||
])
|
||||
]);
|
||||
|
||||
@@ -627,8 +627,9 @@ public static class SqliteCSharpTests
|
||||
|
||||
var docs = await Find.ByFieldsOrdered<JsonDocument>(SqliteDb.TableName, FieldMatch.Any,
|
||||
[Field.GT("NumValue", 15)], [Field.Named("Id")]);
|
||||
Expect.hasLength(docs, 2, "There should have been two documents returned");
|
||||
Expect.equal(string.Join('|', docs.Select(x => x.Id)), "five|four",
|
||||
"There should have been two documents returned");
|
||||
"The documents were not sorted correctly");
|
||||
}),
|
||||
TestCase("succeeds when documents are not found", async () =>
|
||||
{
|
||||
@@ -637,8 +638,31 @@ public static class SqliteCSharpTests
|
||||
|
||||
var docs = await Find.ByFieldsOrdered<JsonDocument>(SqliteDb.TableName, FieldMatch.Any,
|
||||
[Field.GT("NumValue", 15)], [Field.Named("Id DESC")]);
|
||||
Expect.hasLength(docs, 2, "There should have been two documents returned");
|
||||
Expect.equal(string.Join('|', docs.Select(x => x.Id)), "four|five",
|
||||
"There should have been two documents returned");
|
||||
"The documents were not sorted correctly");
|
||||
}),
|
||||
TestCase("succeeds when sorting case-sensitively", async () =>
|
||||
{
|
||||
await using var db = await SqliteDb.BuildDb();
|
||||
await LoadDocs();
|
||||
|
||||
var docs = await Find.ByFieldsOrdered<JsonDocument>(SqliteDb.TableName, FieldMatch.Any,
|
||||
[Field.LE("NumValue", 10)], [Field.Named("Value")]);
|
||||
Expect.hasLength(docs, 3, "There should have been three documents returned");
|
||||
Expect.equal(string.Join('|', docs.Select(x => x.Id)), "three|one|two",
|
||||
"The documents were not sorted correctly");
|
||||
}),
|
||||
TestCase("succeeds when sorting case-insensitively", async () =>
|
||||
{
|
||||
await using var db = await SqliteDb.BuildDb();
|
||||
await LoadDocs();
|
||||
|
||||
var docs = await Find.ByFieldsOrdered<JsonDocument>(SqliteDb.TableName, FieldMatch.Any,
|
||||
[Field.LE("NumValue", 10)], [Field.Named("i:Value")]);
|
||||
Expect.hasLength(docs, 3, "There should have been three documents returned");
|
||||
Expect.equal(string.Join('|', docs.Select(x => x.Id)), "three|two|one",
|
||||
"The documents were not sorted correctly");
|
||||
})
|
||||
]),
|
||||
TestList("FirstByFields",
|
||||
|
||||
Reference in New Issue
Block a user