@@ -750,7 +750,7 @@ instance RenderSQL (TableExpression outer commons grp schemas params from) where
751 :: FromClause outer commons schemas params from -- ^ table reference
751 :: FromClause outer commons schemas params from -- ^ table reference
752 -> TableExpression outer commons 'Ungrouped schemas params from
752 -> TableExpression outer commons 'Ungrouped schemas params from
753−from tab = TableExpression tab [] NoGroups NoHaving [] [] []
753+from tab = TableExpression tab [] noGroups NoHaving [] [] []
755-- | A `where_` is an endomorphism of `TableExpression`s which adds a
755-- | A `where_` is an endomorphism of `TableExpression`s which adds a
756-- search condition to the `whereClause`.
756-- search condition to the `whereClause`.
@@ -771,7 +771,7 @@ groupBy
771groupBy bys rels = TableExpression
771groupBy bys rels = TableExpression
772 { fromClause = fromClause rels
772 { fromClause = fromClause rels
773 , whereClause = whereClause rels
773 , whereClause = whereClause rels
774− , groupByClause = Group bys
774+ , groupByClause = group bys
775 , havingClause = Having []
775 , havingClause = Having []
776 , orderByClause = []
776 , orderByClause = []
777 , limitClause = limitClause rels
777 , limitClause = limitClause rels
@@ -985,19 +985,20 @@ instance (Has rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
985-- done on @NoGroups@ while all output `Expression`s must be aggregated
985-- done on @NoGroups@ while all output `Expression`s must be aggregated
986-- in @Group Nil@. In general, all output `Expression`s in the
986-- in @Group Nil@. In general, all output `Expression`s in the
987-- complement of @bys@ must be aggregated in @Group bys@.
987-- complement of @bys@ must be aggregated in @Group bys@.
988−data GroupByClause grp from where
988+newtype GroupByClause grp from = UnsafeGroupByClause
989− NoGroups :: GroupByClause 'Ungrouped from
989+ { renderGroupByClause :: ByteString }
990− Group
990+ deriving (GHC.Generic,Show,Eq,Ord,NFData)
993− -> GroupByClause ('Grouped bys) from
995−-- | Renders a `GroupByClause`.
996instance RenderSQL (GroupByClause grp from) where
991instance RenderSQL (GroupByClause grp from) where
997− renderSQL = \case
992+ renderSQL = renderGroupByClause
998− NoGroups -> ""
993+noGroups :: GroupByClause 'Ungrouped from
994+noGroups = UnsafeGroupByClause ""
998+ -> GroupByClause ('Grouped bys) from
999+group bys = UnsafeGroupByClause $ case bys of
999− Group Nil -> ""
1000+ Nil -> ""
1000− Group bys -> " GROUP BY" <+> renderCommaSeparated renderSQL bys
1001+ bys' -> " GROUP BY" <+> renderCommaSeparated renderSQL bys'
1002-- | A `HavingClause` is used to eliminate groups that are not of interest.
1003-- | A `HavingClause` is used to eliminate groups that are not of interest.
1003-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1004-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`