Skip to content

Commit 523e52e

Browse files
feat: add count(distinct) as countdistinct aggregate
Added count(distinct) as countdistinct aggregate. Tested to work, and that it is gated when aggregates are off. Tested against collisions with tables and columns named countdistinct. Returns type based on Postgres rules for count(). Extended test coverage to paths including spread path.
1 parent 24f7d4d commit 523e52e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

test/spec/Feature/Query/AggregateFunctionsSpec.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ allowed =
224224
get "/budget_expenses?select=...budget_categories(total_budget:budget_amount.sum())" `shouldRespondWith`
225225
[json|[{"total_budget": 9501.06}]|]
226226
{ matchHeaders = [matchContentTypeJson] }
227+
it "auto-aliases countdistinct() to 'count' inside a to-one spread" $ do
228+
get "/budget_expenses?select=...budget_categories(budget_amount.countdistinct())" `shouldRespondWith`
229+
[json|[{"count": 4}]|]
230+
{ matchHeaders = [matchContentTypeJson] }
227231
it "supports aggregates from a spread relationships grouped by spreaded fields from other relationships" $ do
228232
get "/processes?select=...process_costs(cost.sum()),...process_categories(name)&order=process_categories(name)" `shouldRespondWith`
229233
[json|[

0 commit comments

Comments
 (0)