on dev help sign in
move countStar
commit4fae49273a7dd8f8011d0e2e03bdb3a7d0f1ca72 authorEitan Chatav <eitan.chatav@gmail.com> dateThu 17 Jan 2019, 22:25 (8 years ago) parentbc9bc31
1 file changed+10−9
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+10−9
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+10−9
@@ -137,7 +137,6 @@ module Squeal.PostgreSQL.Expression
137137 , Aggregate (..)
138138 , Distinction (..)
139139 , PGAvg
140− , countStar
141140 -- * Window Functions
142141 , WindowDefinition (..)
143142 , partitionBy
@@ -1396,6 +1395,14 @@ aggregation
13961395
13971396class Aggregate expr aggr | aggr -> expr where
13981397
1398+
1399+
1400+ -- | A special aggregation that does not require an input
1401+ --
1402+ -- >>> printSQL countStar
1403+ -- count(*)
1404+ countStar :: aggr commons schemas params from ('NotNull 'PGint8)
1405+
13991406 -- | >>> :{
14001407 -- let
14011408 -- 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
15131520 Distinct x -> "DISTINCT" <+> renderSQL x
15141521
15151522instance Aggregate Distinction (Expression ('Grouped bys)) where
1523+ countStar = UnsafeExpression "count(*)"
15161524 count = unsafeAggregate "count"
15171525 sum_ = unsafeAggregate "sum"
15181526 bitAnd = unsafeAggregate "bit_and"
@@ -1524,6 +1532,7 @@ instance Aggregate Distinction (Expression ('Grouped bys)) where
15241532 min_ = unsafeAggregate "min"
15251533 avg = unsafeAggregate "avg"
15261534instance Aggregate (Expression grp) (WindowFunction grp) where
1535+ countStar = UnsafeWindowFunction "count(*)"
15271536 count = unsafeWindowFunction1 "count"
15281537 sum_ = unsafeWindowFunction1 "sum"
15291538 bitAnd = unsafeWindowFunction1 "bit_and"
@@ -1555,14 +1564,6 @@ type family PGAvg ty where
15551564 PGAvg 'PGinterval = 'PGinterval
15561565 -- PGAvg pg = TypeError
15571566
1558−-- | A special aggregation that does not require an input
1559−--
1560−-- >>> printSQL countStar
1561−-- count(*)
1562−countStar
1563− :: Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1564−countStar = UnsafeExpression $ "count(*)"
1565−
15661567{-----------------------------------------
15671568type expressions
15681569-----------------------------------------}