@@ -30,7 +30,7 @@ Squeal queries.
31module Squeal.PostgreSQL.Query
31module Squeal.PostgreSQL.Query
32 ( -- * Queries
32 ( -- * Queries
33− Query (UnsafeQuery, renderQuery)
33+ Query (..)
34 -- ** Select
34 -- ** Select
@@ -48,7 +48,7 @@ module Squeal.PostgreSQL.Query
49 , exceptAll
49 , exceptAll
50 -- ** With
50 -- ** With
51− , With (with)
51+ , With (..)
52 , CommonTableExpression (..)
52 , CommonTableExpression (..)
53 , renderCommonTableExpression
53 , renderCommonTableExpression
54 , renderCommonTableExpressions
54 , renderCommonTableExpressions
@@ -89,12 +89,10 @@ module Squeal.PostgreSQL.Query
89 , rightOuterJoin
89 , rightOuterJoin
90 , fullOuterJoin
90 , fullOuterJoin
91 -- * Grouping
91 -- * Grouping
92− , By (By1, By2)
92+ , By (..)
93 , renderBy
93 , renderBy
94− , GroupByClause (NoGroups, Group)
94+ , GroupByClause (..)
95− , renderGroupByClause
96− , HavingClause (NoHaving, Having)
95+ , HavingClause (..)
98 -- * Sorting
96 -- * Sorting
99 , SortExpression (..)
97 , SortExpression (..)
100 -- * Subquery Expressions
98 -- * Subquery Expressions
@@ -594,8 +592,8 @@ renderTableExpression
594 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
592 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
595 [ "FROM ", renderFromClause frm'
593 [ "FROM ", renderFromClause frm'
596 , renderWheres whs'
594 , renderWheres whs'
597− , renderGroupByClause grps'
595+ , renderSQL grps'
598− , renderHavingClause hvs'
596+ , renderSQL hvs'
599 , renderOrderByClause srts'
597 , renderOrderByClause srts'
600 , renderLimits lims'
598 , renderLimits lims'
601 , renderOffsets offs'
599 , renderOffsets offs'
@@ -1007,11 +1005,11 @@ data GroupByClause grp from where
1007 -> GroupByClause ('Grouped bys) from
1005 -> GroupByClause ('Grouped bys) from
1009-- | Renders a `GroupByClause`.
1007-- | Renders a `GroupByClause`.
1010−renderGroupByClause :: GroupByClause grp from -> ByteString
1008+instance RenderSQL (GroupByClause grp from) where
1011−renderGroupByClause = \case
1009+ renderSQL = \case
1012− NoGroups -> ""
1010+ NoGroups -> ""
1013− Group Nil -> ""
1011+ Group Nil -> ""
1014− Group bys -> " GROUP BY" <+> renderCommaSeparated renderBy bys
1012+ Group bys -> " GROUP BY" <+> renderCommaSeparated renderBy bys
1016-- | A `HavingClause` is used to eliminate groups that are not of interest.
1014-- | A `HavingClause` is used to eliminate groups that are not of interest.
1017-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1015-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
@@ -1027,12 +1025,12 @@ deriving instance Eq (HavingClause db params grp from)
1027deriving instance Ord (HavingClause db params grp from)
1025deriving instance Ord (HavingClause db params grp from)
1029-- | Render a `HavingClause`.
1027-- | Render a `HavingClause`.
1030−renderHavingClause :: HavingClause db params grp from -> ByteString
1028+instance RenderSQL (HavingClause db params grp from) where
1031−renderHavingClause = \case
1029+ renderSQL = \case
1032− NoHaving -> ""
1030+ NoHaving -> ""
1033− Having [] -> ""
1031+ Having [] -> ""
1034− Having conditions ->
1032+ Having conditions ->
1035− " HAVING" <+> commaSeparated (renderSQL <$> conditions)
1033+ " HAVING" <+> commaSeparated (renderSQL <$> conditions)
1037{-----------------------------------------
1035{-----------------------------------------