Skip to content

Commit 95f2926

Browse files
author
Adrian Hall
committed
(#206) Ensures stable ordering across database types.
1 parent 24ec586 commit 95f2926

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

tests/CommunityToolkit.Datasync.Server.Test/Helpers/LiveControllerTests.cs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ private async Task MovieQueryTest(string pathAndQuery, int itemCount, string nex
119119
items.Should().HaveCount(itemCount);
120120
result.Count.Should().Be(totalCount);
121121
List<string> actualItems = items.Select(m => m.Id).Take(firstItems.Length).ToList();
122-
123-
// Get the list of items in firstItems and actualItems
124-
List<TEntity> expA1 = await GetListOfEntitiesAsync(firstItems);
125-
List<TEntity> expA2 = await GetListOfEntitiesAsync(actualItems);
126-
expA2.Count.Should().Be(actualItems.Count);
127-
128122
actualItems.Should().BeEquivalentTo(firstItems);
129123

130124
if (nextLinkQuery is not null)
@@ -3381,19 +3375,19 @@ await MovieQueryTest(
33813375
}
33823376

33833377
// PROBLEM - THIS TEST RESULTS IN DIFFERENT ORDERING ON PGSQL vs. AZURESQL
3384-
//[SkippableFact]
3385-
//public async Task Query_Test_235()
3386-
//{
3387-
// Skip.IfNot(CanRunLiveTests());
3388-
3389-
// await MovieQueryTest(
3390-
// $"{MovieEndpoint}?$orderby=title asc&$skip=5",
3391-
// DefaultPageSize,
3392-
// "$orderby=title asc&$skip=105",
3393-
// null,
3394-
// ["id-214", "id-102", "id-215", "id-039", "id-057"]
3395-
// );
3396-
//}
3378+
[SkippableFact]
3379+
public async Task Query_Test_235()
3380+
{
3381+
Skip.IfNot(CanRunLiveTests());
3382+
3383+
await MovieQueryTest(
3384+
$"{MovieEndpoint}?$orderby=title asc&$skip=5",
3385+
DefaultPageSize,
3386+
"$orderby=title asc&$skip=105",
3387+
null,
3388+
["id-214", "id-102", "id-215", "id-039", "id-057"]
3389+
);
3390+
}
33973391

33983392
[SkippableFact]
33993393
public async Task Query_Test_236()

tests/CommunityToolkit.Datasync.TestCommon/Databases/Postgresql/PgDbContext.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ FOR EACH ROW EXECUTE PROCEDURE
5353

5454
protected override void OnModelCreating(ModelBuilder modelBuilder)
5555
{
56-
modelBuilder.Entity<PgEntityMovie>()
57-
.Property(m => m.UpdatedAt).HasDefaultValueSql("NOW() AT TIME ZONE 'UTC'");
56+
modelBuilder.Entity<PgEntityMovie>().Property(m => m.UpdatedAt)
57+
.HasDefaultValueSql("NOW() AT TIME ZONE 'UTC'");
58+
59+
// Ensures stable ordering across all database types.
60+
modelBuilder.Entity<PgEntityMovie>().Property(m => m.Title)
61+
.UseCollation("POSIX");
62+
5863
base.OnModelCreating(modelBuilder);
5964
}
6065
}

0 commit comments

Comments
 (0)