@@ -137,7 +137,6 @@ module Squeal.PostgreSQL.Expression
137 , Aggregate (..)
137 , Aggregate (..)
138 , Distinction (..)
138 , Distinction (..)
141 -- * Window Functions
140 -- * Window Functions
142 , WindowDefinition (..)
141 , WindowDefinition (..)
143 , partitionBy
142 , partitionBy
@@ -1396,6 +1395,14 @@ aggregation
1397class Aggregate expr aggr | aggr -> expr where
1396class Aggregate expr aggr | aggr -> expr where
1400+ -- | A special aggregation that does not require an input
1402+ -- >>> printSQL countStar
1404+ countStar :: aggr commons schemas params from ('NotNull 'PGint8)
1399 -- | >>> :{
1406 -- | >>> :{
1401 -- expression :: Expression (Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1408 -- expression :: Expression (Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
@@ -1513,6 +1520,7 @@ instance RenderSQL (Distinction commons schemas params from ty) where
1513 Distinct x -> "DISTINCT" <+> renderSQL x
1520 Distinct x -> "DISTINCT" <+> renderSQL x
1515instance Aggregate Distinction (Expression ('Grouped bys)) where
1522instance Aggregate Distinction (Expression ('Grouped bys)) where
1523+ countStar = UnsafeExpression "count(*)"
1516 count = unsafeAggregate "count"
1524 count = unsafeAggregate "count"
1517 sum_ = unsafeAggregate "sum"
1525 sum_ = unsafeAggregate "sum"
1518 bitAnd = unsafeAggregate "bit_and"
1526 bitAnd = unsafeAggregate "bit_and"
@@ -1524,6 +1532,7 @@ instance Aggregate Distinction (Expression ('Grouped bys)) where
1524 min_ = unsafeAggregate "min"
1532 min_ = unsafeAggregate "min"
1525 avg = unsafeAggregate "avg"
1533 avg = unsafeAggregate "avg"
1526instance Aggregate (Expression grp) (WindowFunction grp) where
1534instance Aggregate (Expression grp) (WindowFunction grp) where
1535+ countStar = UnsafeWindowFunction "count(*)"
1527 count = unsafeWindowFunction1 "count"
1536 count = unsafeWindowFunction1 "count"
1528 sum_ = unsafeWindowFunction1 "sum"
1537 sum_ = unsafeWindowFunction1 "sum"
1529 bitAnd = unsafeWindowFunction1 "bit_and"
1538 bitAnd = unsafeWindowFunction1 "bit_and"
@@ -1555,14 +1564,6 @@ type family PGAvg ty where
1555 PGAvg 'PGinterval = 'PGinterval
1564 PGAvg 'PGinterval = 'PGinterval
1556 -- PGAvg pg = TypeError
1565 -- PGAvg pg = TypeError
1558−-- | A special aggregation that does not require an input
1560−-- >>> printSQL countStar
1563− :: Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1564−countStar = UnsafeExpression $ "count(*)"
1566{-----------------------------------------
1567{-----------------------------------------
1567type expressions
1568type expressions
1568-----------------------------------------}
1569-----------------------------------------}