Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Simple.Data.InMemoryTest/InMemoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ public void SelectWithHavingSumShouldReturnOnlyMatchingRows()
Assert.AreEqual("Bob", records[0].Name);
}

[Test]
public void SelectWithDistinctShouldReturnOnlyDistinctRows()
{
var db = CreateAggregateTestDb();
var records = db.Test.All().Select(db.Test.Name).Distinct().ToList();
Assert.AreEqual(2, records.Count);
Assert.AreEqual("Alice", records[0].Name);
Assert.AreEqual("Bob", records[1].Name);
}

private static dynamic CreateAggregateTestDb()
{
Database.UseMockAdapter(new InMemoryAdapter());
Expand Down
7 changes: 4 additions & 3 deletions Simple.Data/QueryPolyfills/DictionaryQueryRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public IEnumerable<IDictionary<string, object>> Run()
}

source = RunOrderByClauses(source);

source = RunHavingClauses(source);
source = RunSelectClauses(source);

foreach (var clause in _clauses)
{
Expand All @@ -56,9 +59,7 @@ public IEnumerable<IDictionary<string, object>> Run()
source = handler(clause, source);
}
}

source = RunHavingClauses(source);
source = RunSelectClauses(source);

return source;
}

Expand Down