@@ -18,6 +18,7 @@ Squeal queries.
18 , LambdaCase
18 , LambdaCase
19 , MultiParamTypeClasses
19 , MultiParamTypeClasses
20 , OverloadedStrings
20 , OverloadedStrings
21+ , QuantifiedConstraints
21 , ScopedTypeVariables
22 , ScopedTypeVariables
22 , StandaloneDeriving
23 , StandaloneDeriving
23 , TypeApplications
24 , TypeApplications
@@ -51,8 +52,6 @@ module Squeal.PostgreSQL.Query
51 -- ** With
52 -- ** With
52 , With (..)
53 , With (..)
53 , CommonTableExpression (..)
54 , CommonTableExpression (..)
54− , renderCommonTableExpression
55− , renderCommonTableExpressions
56 -- ** Json
55 -- ** Json
57 , jsonEach
56 , jsonEach
58 , jsonbEach
57 , jsonbEach
@@ -1346,25 +1345,10 @@ instance
1346 (AlignedList (CommonTableExpression statement schemas params) commons commons1) where
1345 (AlignedList (CommonTableExpression statement schemas params) commons commons1) where
1347 statement `as` cte = single (statement `as` cte)
1346 statement `as` cte = single (statement `as` cte)
1349−-- | render a `CommonTableExpression`.
1348+instance (forall c s p r. RenderSQL (statement c s p r)) => RenderSQL
1350−renderCommonTableExpression
1351− :: (forall cs ss ps row. statement cs ss ps row -> ByteString) -- ^ render statement
1352− -> CommonTableExpression statement schemas params commons0 commons1 -> ByteString
1349+ (CommonTableExpression statement schemas params commons0 commons1) where
1353−renderCommonTableExpression renderStatement
1354− (CommonTableExpression (statement `As` alias)) =
1350+ renderSQL (CommonTableExpression (statement `As` cte)) =
1355− renderSQL alias <+> "AS" <+> parenthesized (renderStatement statement)
1351+ renderSQL cte <+> "AS" <+> parenthesized (renderSQL statement)
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
1363−renderCommonTableExpressions renderStatement cte ctes =
1364− renderCommonTableExpression renderStatement cte <> case ctes of
1366− cte' :>> ctes' -> "," <+>
1367− renderCommonTableExpressions renderStatement cte' ctes'
1369-- | `with` provides a way to write auxiliary statements for use in a larger query.
1353-- | `with` provides a way to write auxiliary statements for use in a larger query.
1370-- These statements, referred to as `CommonTableExpression`s, can be thought of as
1354-- These statements, referred to as `CommonTableExpression`s, can be thought of as
@@ -1378,6 +1362,5 @@ class With statement where
1378 -> statement commons0 schemas params row
1362 -> statement commons0 schemas params row
1379instance With Query where
1363instance With Query where
1380 with Done query = query
1364 with Done query = query
1381− with (cte :>> ctes) query = UnsafeQuery $
1365+ with ctes query = UnsafeQuery $
1382− "WITH" <+> renderCommonTableExpressions renderSQL cte ctes
1383− <+> renderSQL query
1366+ "WITH" <+> renderSQL ctes <+> renderSQL query