@@ -72,7 +72,7 @@ let
72 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
72 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
73 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[] '[]
73 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[] '[]
74 manipulation =
74 manipulation =
75− insertRow_ #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
75+ insertRow_ #tab (Set 2 `as` #col1 :* Default `as` #col2)
76in printSQL manipulation
76in printSQL manipulation
78INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT)
78INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT)
@@ -88,7 +88,7 @@ let
88 '[ 'NotNull 'PGint4, 'NotNull 'PGint4 ] '[]
88 '[ 'NotNull 'PGint4, 'NotNull 'PGint4 ] '[]
89 manipulation =
89 manipulation =
90 insertRow_ #tab
90 insertRow_ #tab
91− (Set (param @1) `As` #col1 :* Set (param @2) `As` #col2 :* Nil)
91+ (Set (param @1) `as` #col1 :* Set (param @2) `as` #col2)
92in printSQL manipulation
92in printSQL manipulation
94INSERT INTO "tab" ("col1", "col2") VALUES (($1 :: int4), ($2 :: int4))
94INSERT INTO "tab" ("col1", "col2") VALUES (($1 :: int4), ($2 :: int4))
@@ -103,8 +103,8 @@ let
103 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[]
103 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[]
104 '["fromOnly" ::: 'NotNull 'PGint4]
104 '["fromOnly" ::: 'NotNull 'PGint4]
105 manipulation =
105 manipulation =
106− insertRow #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
106+ insertRow #tab (Set 2 `as` #col1 :* Default `as` #col2)
107− OnConflictDoRaise (Returning (#col1 `As` #fromOnly :* Nil))
107+ OnConflictDoRaise (Returning (#col1 `as` #fromOnly))
108in printSQL manipulation
108in printSQL manipulation
110INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT) RETURNING "col1" AS "fromOnly"
110INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT) RETURNING "col1" AS "fromOnly"
@@ -120,12 +120,12 @@ let
120 '[] '[ "sum" ::: 'NotNull 'PGint4]
120 '[] '[ "sum" ::: 'NotNull 'PGint4]
121 manipulation =
121 manipulation =
122 insertRows #tab
122 insertRows #tab
123− (Set 2 `As` #col1 :* Set 4 `As` #col2 :* Nil)
123+ (Set 2 `as` #col1 :* Set 4 `as` #col2)
124− [Set 6 `As` #col1 :* Set 8 `As` #col2 :* Nil]
124+ [Set 6 `as` #col1 :* Set 8 `as` #col2]
125 (OnConflictDoUpdate
125 (OnConflictDoUpdate
126− (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
126+ (Set 2 `as` #col1 :* Same `as` #col2)
127 [#col1 .== #col2])
127 [#col1 .== #col2])
128− (Returning $ (#col1 + #col2) `As` #sum :* Nil)
128+ (Returning $ (#col1 + #col2) `as` #sum)
129in printSQL manipulation
129in printSQL manipulation
131INSERT INTO "tab" ("col1", "col2") VALUES (2, 4), (6, 8) ON CONFLICT DO UPDATE SET "col1" = 2 WHERE ("col1" = "col2") RETURNING ("col1" + "col2") AS "sum"
131INSERT INTO "tab" ("col1", "col2") VALUES (2, 4), (6, 8) ON CONFLICT DO UPDATE SET "col1" = 2 WHERE ("col1" = "col2") RETURNING ("col1" + "col2") AS "sum"
@@ -146,7 +146,7 @@ let
146 ] '[] '[]
146 ] '[] '[]
147 manipulation =
147 manipulation =
148 insertQuery_ #tab
148 insertQuery_ #tab
149− (selectStar (from (table (#other_tab `As` #t))))
149+ (selectStar (from (table (#other_tab `as` #t))))
150in printSQL manipulation
150in printSQL manipulation
152INSERT INTO "tab" SELECT * FROM "other_tab" AS "t"
152INSERT INTO "tab" SELECT * FROM "other_tab" AS "t"
@@ -160,7 +160,7 @@ let
160 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
160 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
161 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])] '[] '[]
161 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])] '[] '[]
162 manipulation =
162 manipulation =
163− update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
163+ update_ #tab (Set 2 `as` #col1 :* Same `as` #col2)
164 (#col1 ./= #col2)
164 (#col1 ./= #col2)
165in printSQL manipulation
165in printSQL manipulation
@@ -484,16 +484,16 @@ WITH statements
485-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
485-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
486-- manipulation = with
486-- manipulation = with
487−-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rows :* Nil)
487+-- (deleteFrom #products (#date .< param @1) ReturningStar `as` #deleted_rows)
488−-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `As` #t)))))
488+-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `as` #t)))))
489-- in printSQL manipulation
489-- in printSQL manipulation
491-- 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"
493 :: SOP.SListI commons
493 :: SOP.SListI commons
494− => NP (Aliased (Manipulation schema params)) commons
494+ => NP (Aliased (Manipulation schema params)) (common ': commons)
495 -- ^ common table expressions
495 -- ^ common table expressions
496− -> Manipulation (With commons schema) params results
496+ -> Manipulation (With (common ': commons) schema) params results
497 -> Manipulation schema params results
497 -> Manipulation schema params results
498with commons manipulation = UnsafeManipulation $
498with commons manipulation = UnsafeManipulation $
499 "WITH" <+> renderCommaSeparated renderCommon commons
499 "WITH" <+> renderCommaSeparated renderCommon commons