@@ -18,6 +18,7 @@ Squeal queries.
1818 , LambdaCase
1919 , MultiParamTypeClasses
2020 , OverloadedStrings
21+ , QuantifiedConstraints
2122 , ScopedTypeVariables
2223 , StandaloneDeriving
2324 , TypeApplications
@@ -51,8 +52,6 @@ module Squeal.PostgreSQL.Query
5152 -- ** With
5253 , With (..)
5354 , CommonTableExpression (..)
54− , renderCommonTableExpression
55− , renderCommonTableExpressions
5655 -- ** Json
5756 , jsonEach
5857 , jsonbEach
@@ -1346,25 +1345,10 @@ instance
13461345 (AlignedList (CommonTableExpression statement schemas params) commons commons1) where
13471346 statement `as` cte = single (statement `as` cte)
13481347
1349−-- | render a `CommonTableExpression`.
1350−renderCommonTableExpression
1351− :: (forall cs ss ps row. statement cs ss ps row -> ByteString) -- ^ render statement
1352− -> CommonTableExpression statement schemas params commons0 commons1 -> ByteString
1353−renderCommonTableExpression renderStatement
1354− (CommonTableExpression (statement `As` alias)) =
1355− renderSQL alias <+> "AS" <+> parenthesized (renderStatement statement)
1356−
1357−-- | render a non-empty `AlignedList` of `CommonTableExpression`s.
1358−renderCommonTableExpressions
1359− :: (forall cs ss ps row. statement cs ss ps row -> ByteString) -- ^ render statement
1360− -> CommonTableExpression statement schemas params commons0 commons1
1361− -> AlignedList (CommonTableExpression statement schemas params) commons1 commons2
1362− -> ByteString
1363−renderCommonTableExpressions renderStatement cte ctes =
1364− renderCommonTableExpression renderStatement cte <> case ctes of
1365− Done -> ""
1366− cte' :>> ctes' -> "," <+>
1367− renderCommonTableExpressions renderStatement cte' ctes'
1348+instance (forall c s p r. RenderSQL (statement c s p r)) => RenderSQL
1349+ (CommonTableExpression statement schemas params commons0 commons1) where
1350+ renderSQL (CommonTableExpression (statement `As` cte)) =
1351+ renderSQL cte <+> "AS" <+> parenthesized (renderSQL statement)
13681352
13691353-- | `with` provides a way to write auxiliary statements for use in a larger query.
13701354-- These statements, referred to as `CommonTableExpression`s, can be thought of as
@@ -1378,6 +1362,5 @@ class With statement where
13781362 -> statement commons0 schemas params row
13791363instance With Query where
13801364 with Done query = query
1381− with (cte :>> ctes) query = UnsafeQuery $
1382− "WITH" <+> renderCommonTableExpressions renderSQL cte ctes
1383− <+> renderSQL query
1365+ with ctes query = UnsafeQuery $
1366+ "WITH" <+> renderSQL ctes <+> renderSQL query