on dev help sign in
more renderSQL
commit1600aa611fde265fbb56d117cc15e9191a54db52 authorEitan Chatav <eitan.chatav@gmail.com> dateFri 7 Dec 2018, 16:42 (8 years ago) parentc571bae
1 file changed+18−20
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+18−20
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+18−20
@@ -30,7 +30,7 @@ Squeal queries.
3030
3131module Squeal.PostgreSQL.Query
3232 ( -- * Queries
33− Query (UnsafeQuery, renderQuery)
33+ Query (..)
3434 -- ** Select
3535 , select
3636 , select_
@@ -48,7 +48,7 @@ module Squeal.PostgreSQL.Query
4848 , except
4949 , exceptAll
5050 -- ** With
51− , With (with)
51+ , With (..)
5252 , CommonTableExpression (..)
5353 , renderCommonTableExpression
5454 , renderCommonTableExpressions
@@ -89,12 +89,10 @@ module Squeal.PostgreSQL.Query
8989 , rightOuterJoin
9090 , fullOuterJoin
9191 -- * Grouping
92− , By (By1, By2)
92+ , By (..)
9393 , renderBy
94− , GroupByClause (NoGroups, Group)
95− , renderGroupByClause
96− , HavingClause (NoHaving, Having)
97− , renderHavingClause
94+ , GroupByClause (..)
95+ , HavingClause (..)
9896 -- * Sorting
9997 , SortExpression (..)
10098 -- * Subquery Expressions
@@ -594,8 +592,8 @@ renderTableExpression
594592 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
595593 [ "FROM ", renderFromClause frm'
596594 , renderWheres whs'
597− , renderGroupByClause grps'
598− , renderHavingClause hvs'
595+ , renderSQL grps'
596+ , renderSQL hvs'
599597 , renderOrderByClause srts'
600598 , renderLimits lims'
601599 , renderOffsets offs'
@@ -1007,11 +1005,11 @@ data GroupByClause grp from where
10071005 -> GroupByClause ('Grouped bys) from
10081006
10091007-- | Renders a `GroupByClause`.
1010−renderGroupByClause :: GroupByClause grp from -> ByteString
1011−renderGroupByClause = \case
1012− NoGroups -> ""
1013− Group Nil -> ""
1014− Group bys -> " GROUP BY" <+> renderCommaSeparated renderBy bys
1008+instance RenderSQL (GroupByClause grp from) where
1009+ renderSQL = \case
1010+ NoGroups -> ""
1011+ Group Nil -> ""
1012+ Group bys -> " GROUP BY" <+> renderCommaSeparated renderBy bys
10151013
10161014-- | A `HavingClause` is used to eliminate groups that are not of interest.
10171015-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
@@ -1027,12 +1025,12 @@ deriving instance Eq (HavingClause db params grp from)
10271025deriving instance Ord (HavingClause db params grp from)
10281026
10291027-- | Render a `HavingClause`.
1030−renderHavingClause :: HavingClause db params grp from -> ByteString
1031−renderHavingClause = \case
1032− NoHaving -> ""
1033− Having [] -> ""
1034− Having conditions ->
1035− " HAVING" <+> commaSeparated (renderSQL <$> conditions)
1028+instance RenderSQL (HavingClause db params grp from) where
1029+ renderSQL = \case
1030+ NoHaving -> ""
1031+ Having [] -> ""
1032+ Having conditions ->
1033+ " HAVING" <+> commaSeparated (renderSQL <$> conditions)
10361034
10371035{-----------------------------------------
10381036Sorting