on dev help sign in
some manipulation docs nil scrapping
commit0bb54fac214f328eb435a18be37d2fe52f9215bd authorEitan Chatav <eitan.chatav@gmail.com> dateMon 2 Jul 2018, 00:04 (8 years ago) parent06a2d7b
1 file changed+14−14
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+14−14
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+14−14
@@ -72,7 +72,7 @@ let
7272 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
7373 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[] '[]
7474 manipulation =
75− insertRow_ #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
75+ insertRow_ #tab (Set 2 `as` #col1 :* Default `as` #col2)
7676in printSQL manipulation
7777:}
7878INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT)
@@ -88,7 +88,7 @@ let
8888 '[ 'NotNull 'PGint4, 'NotNull 'PGint4 ] '[]
8989 manipulation =
9090 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)
9292in printSQL manipulation
9393:}
9494INSERT INTO "tab" ("col1", "col2") VALUES (($1 :: int4), ($2 :: int4))
@@ -103,8 +103,8 @@ let
103103 , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[]
104104 '["fromOnly" ::: 'NotNull 'PGint4]
105105 manipulation =
106− insertRow #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
107− OnConflictDoRaise (Returning (#col1 `As` #fromOnly :* Nil))
106+ insertRow #tab (Set 2 `as` #col1 :* Default `as` #col2)
107+ OnConflictDoRaise (Returning (#col1 `as` #fromOnly))
108108in printSQL manipulation
109109:}
110110INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT) RETURNING "col1" AS "fromOnly"
@@ -120,12 +120,12 @@ let
120120 '[] '[ "sum" ::: 'NotNull 'PGint4]
121121 manipulation =
122122 insertRows #tab
123− (Set 2 `As` #col1 :* Set 4 `As` #col2 :* Nil)
124− [Set 6 `As` #col1 :* Set 8 `As` #col2 :* Nil]
123+ (Set 2 `as` #col1 :* Set 4 `as` #col2)
124+ [Set 6 `as` #col1 :* Set 8 `as` #col2]
125125 (OnConflictDoUpdate
126− (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
126+ (Set 2 `as` #col1 :* Same `as` #col2)
127127 [#col1 .== #col2])
128− (Returning $ (#col1 + #col2) `As` #sum :* Nil)
128+ (Returning $ (#col1 + #col2) `as` #sum)
129129in printSQL manipulation
130130:}
131131INSERT 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
146146 ] '[] '[]
147147 manipulation =
148148 insertQuery_ #tab
149− (selectStar (from (table (#other_tab `As` #t))))
149+ (selectStar (from (table (#other_tab `as` #t))))
150150in printSQL manipulation
151151:}
152152INSERT INTO "tab" SELECT * FROM "other_tab" AS "t"
@@ -160,7 +160,7 @@ let
160160 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
161161 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])] '[] '[]
162162 manipulation =
163− update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
163+ update_ #tab (Set 2 `as` #col1 :* Same `as` #col2)
164164 (#col1 ./= #col2)
165165in printSQL manipulation
166166:}
@@ -484,16 +484,16 @@ WITH statements
484484-- let
485485-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
486486-- manipulation = with
487−-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rows :* Nil)
488−-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `As` #t)))))
487+-- (deleteFrom #products (#date .< param @1) ReturningStar `as` #deleted_rows)
488+-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `as` #t)))))
489489-- in printSQL manipulation
490490-- :}
491491-- WITH "deleted_rows" AS (DELETE FROM "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" SELECT * FROM "deleted_rows" AS "t"
492492with
493493 :: SOP.SListI commons
494− => NP (Aliased (Manipulation schema params)) commons
494+ => NP (Aliased (Manipulation schema params)) (common ': commons)
495495 -- ^ common table expressions
496− -> Manipulation (With commons schema) params results
496+ -> Manipulation (With (common ': commons) schema) params results
497497 -> Manipulation schema params results
498498with commons manipulation = UnsafeManipulation $
499499 "WITH" <+> renderCommaSeparated renderCommon commons