@@ -73,9 +73,9 @@ let
7373 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[] '[]
7474 manipulation =
7575 insertRow_ #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
76−in renderManipulation manipulation
76+in printSQL manipulation
7777:}
78−"INSERT INTO \"tab\" (\"col1\", \"col2\") VALUES (2, DEFAULT)"
78+INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT)
7979
8080parameterized insert:
8181
@@ -89,9 +89,9 @@ let
8989 manipulation =
9090 insertRow_ #tab
9191 (Set (param @1) `As` #col1 :* Set (param @2) `As` #col2 :* Nil)
92−in renderManipulation manipulation
92+in printSQL manipulation
9393:}
94−"INSERT INTO \"tab\" (\"col1\", \"col2\") VALUES (($1 :: int4), ($2 :: int4))"
94+INSERT INTO "tab" ("col1", "col2") VALUES (($1 :: int4), ($2 :: int4))
9595
9696returning insert:
9797
@@ -105,9 +105,9 @@ let
105105 manipulation =
106106 insertRow #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
107107 OnConflictDoRaise (Returning (#col1 `As` #fromOnly :* Nil))
108−in renderManipulation manipulation
108+in printSQL manipulation
109109:}
110−"INSERT INTO \"tab\" (\"col1\", \"col2\") VALUES (2, DEFAULT) RETURNING \"col1\" AS \"fromOnly\""
110+INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT) RETURNING "col1" AS "fromOnly"
111111
112112upsert:
113113
@@ -126,9 +126,9 @@ let
126126 (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
127127 [#col1 .== #col2])
128128 (Returning $ (#col1 + #col2) `As` #sum :* Nil)
129−in renderManipulation manipulation
129+in printSQL manipulation
130130:}
131−"INSERT INTO \"tab\" (\"col1\", \"col2\") VALUES (2, 4), (6, 8) ON CONFLICT DO UPDATE SET \"col1\" = 2 WHERE (\"col1\" = \"col2\") RETURNING (\"col1\" + \"col2\") AS \"sum\""
131+INSERT INTO "tab" ("col1", "col2") VALUES (2, 4), (6, 8) ON CONFLICT DO UPDATE SET "col1" = 2 WHERE ("col1" = "col2") RETURNING ("col1" + "col2") AS "sum"
132132
133133query insert:
134134
@@ -147,9 +147,9 @@ let
147147 manipulation =
148148 insertQuery_ #tab
149149 (selectStar (from (table (#other_tab `As` #t))))
150−in renderManipulation manipulation
150+in printSQL manipulation
151151:}
152−"INSERT INTO \"tab\" SELECT * FROM \"other_tab\" AS \"t\""
152+INSERT INTO "tab" SELECT * FROM "other_tab" AS "t"
153153
154154update:
155155
@@ -162,9 +162,9 @@ let
162162 manipulation =
163163 update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
164164 (#col1 ./= #col2)
165−in renderManipulation manipulation
165+in printSQL manipulation
166166:}
167−"UPDATE \"tab\" SET \"col1\" = 2 WHERE (\"col1\" <> \"col2\")"
167+UPDATE "tab" SET "col1" = 2 WHERE ("col1" <> "col2")
168168
169169delete:
170170
@@ -177,9 +177,9 @@ let
177177 '[ "col1" ::: 'NotNull 'PGint4
178178 , "col2" ::: 'NotNull 'PGint4 ]
179179 manipulation = deleteFrom #tab (#col1 .== #col2) ReturningStar
180−in renderManipulation manipulation
180+in printSQL manipulation
181181:}
182−"DELETE FROM \"tab\" WHERE (\"col1\" = \"col2\") RETURNING *"
182+DELETE FROM "tab" WHERE ("col1" = "col2") RETURNING *
183183-}
184184newtype Manipulation
185185 (schema :: SchemaType)
@@ -188,6 +188,9 @@ newtype Manipulation
188188 = UnsafeManipulation { renderManipulation :: ByteString }
189189 deriving (GHC.Generic,Show,Eq,Ord,NFData)
190190
191+instance RenderSQL (Manipulation schema params columns) where
192+ renderSQL = renderManipulation
193+
191194-- | Convert a `Query` into a `Manipulation`.
192195queryStatement
193196 :: Query schema params columns
@@ -483,9 +486,9 @@ WITH statements
483486-- manipulation = with
484487-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rows :* Nil)
485488-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `As` #t)))))
486−-- in renderManipulation manipulation
489+-- in printSQL manipulation
487490-- :}
488−-- "WITH \"deleted_rows\" AS (DELETE FROM \"products\" WHERE (\"date\" < ($1 :: date)) RETURNING *) INSERT INTO \"products_deleted\" SELECT * FROM \"deleted_rows\" AS \"t\""
491+-- WITH "deleted_rows" AS (DELETE FROM "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" SELECT * FROM "deleted_rows" AS "t"
489492with
490493 :: SOP.SListI commons
491494 => NP (Aliased (Manipulation schema params)) commons