on dev help sign in
common
2bef1d3Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+73−107
@@ -81,6 +81,7 @@ module Squeal.PostgreSQL.Query
81 , table
81 , table
82 , subquery
82 , subquery
83 , view
83 , view
84+ , common
84 , crossJoin
85 , crossJoin
85 , innerJoin
86 , innerJoin
86 , leftOuterJoin
87 , leftOuterJoin
@@ -144,12 +145,11 @@ is called a `Query`. Let's see some examples of queries.
144
145
145simple query:
146simple query:
146
147
148+>>> type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]
149+>>> type Schema = '["tab" ::: 'Table ('[] :=> Columns)]
147>>> :{
150>>> :{
148let
151let
149− query :: Query
152+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
150− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
151− '[]
152− '["col" ::: 'Null 'PGint4]
153 query = selectStar (from (table #tab))
153 query = selectStar (from (table #tab))
154in printSQL query
154in printSQL query
155:}
155:}
@@ -159,16 +159,9 @@ restricted query:
159
159
160>>> :{
160>>> :{
161let
161let
162− query :: Query
163− '[ "public" ::: '[ "tab" ::: 'Table ('[] :=>
164− '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
165− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])]]
166− '[]
167− '[ "sum" ::: 'NotNull 'PGint4
168− , "col1" ::: 'NotNull 'PGint4 ]
162+ query :: Query (DBof (Public Schema)) '[] '["sum" ::: 'NotNull 'PGint4, "col1" ::: 'NotNull 'PGint4]
169 query =
163 query =
170− select
171− ((#col1 + #col2) `as` #sum :* #col1)
164+ select ((#col1 + #col2) `as` #sum :* #col1)
172 ( from (table #tab)
165 ( from (table #tab)
173 & where_ (#col1 .> #col2)
166 & where_ (#col1 .> #col2)
174 & where_ (#col2 .> 0) )
167 & where_ (#col2 .> 0) )
@@ -180,13 +173,8 @@ subquery:
180
173
181>>> :{
174>>> :{
182let
175let
183− query :: Query
176+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
184− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
185− '[]
186− '["col" ::: 'Null 'PGint4]
187− query =
188− selectStar
189− (from (subquery (selectStar (from (table #tab)) `as` #sub)))
177+ query = selectStar (from (subquery (selectStar (from (table #tab)) `as` #sub)))
190in printSQL query
178in printSQL query
191:}
179:}
192SELECT * FROM (SELECT * FROM "tab" AS "tab") AS "sub"
180SELECT * FROM (SELECT * FROM "tab" AS "tab") AS "sub"
@@ -195,12 +183,8 @@ limits and offsets:
195
183
196>>> :{
184>>> :{
197let
185let
198− query :: Query
186+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
199− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
200− '[]
201− '["col" ::: 'Null 'PGint4]
202− query = selectStar
203− (from (table #tab) & limit 100 & offset 2 & limit 50 & offset 2)
187+ query = selectStar (from (table #tab) & limit 100 & offset 2 & limit 50 & offset 2)
204in printSQL query
188in printSQL query
205:}
189:}
206SELECT * FROM "tab" AS "tab" LIMIT 50 OFFSET 4
190SELECT * FROM "tab" AS "tab" LIMIT 50 OFFSET 4
@@ -209,27 +193,17 @@ parameterized query:
209
193
210>>> :{
194>>> :{
211let
195let
212− query :: Query
196+ query :: Query (DBof (Public Schema)) '[ 'NotNull 'PGint4] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
213− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGfloat8])]]
214− '[ 'NotNull 'PGfloat8]
215− '["col" ::: 'NotNull 'PGfloat8]
216− query = selectStar
217− (from (table #tab) & where_ (#col .> param @1))
197+ query = selectStar (from (table #tab) & where_ (#col1 .> param @1))
218in printSQL query
198in printSQL query
219:}
199:}
220−SELECT * FROM "tab" AS "tab" WHERE ("col" > ($1 :: float8))
200+SELECT * FROM "tab" AS "tab" WHERE ("col1" > ($1 :: int4))
221
201
222aggregation query:
202aggregation query:
223
203
224>>> :{
204>>> :{
225let
205let
226− query :: Query
227− '["public" ::: '[ "tab" ::: 'Table ('[] :=>
228− '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
229− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])]]
230− '[]
231− '[ "sum" ::: 'NotNull 'PGint4
232− , "col1" ::: 'NotNull 'PGint4 ]
206+ query :: Query (DBof (Public Schema)) '[] '["sum" ::: 'NotNull 'PGint4, "col1" ::: 'NotNull 'PGint4 ]
233 query =
207 query =
234 select (sum_ #col2 `as` #sum :* #col1)
208 select (sum_ #col2 `as` #sum :* #col1)
235 ( from (table (#tab `as` #table1))
209 ( from (table (#tab `as` #table1))
@@ -243,42 +217,43 @@ sorted query:
243
217
244>>> :{
218>>> :{
245let
219let
246− query :: Query
220+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
247− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
248− '[]
249− '["col" ::: 'Null 'PGint4]
250− query = selectStar
221+ query = selectStar (from (table #tab) & orderBy [#col1 & Asc])
251− (from (table #tab) & orderBy [#col & AscNullsFirst])
252in printSQL query
222in printSQL query
253:}
223:}
254−SELECT * FROM "tab" AS "tab" ORDER BY "col" ASC NULLS FIRST
224+SELECT * FROM "tab" AS "tab" ORDER BY "col1" ASC
255
225
256joins:
226joins:
257
227
258>>> :set -XFlexibleContexts
228>>> :set -XFlexibleContexts
229+>>> :{
230+type OrdersColumns =
231+ '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
232+ , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4
233+ , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
234+ , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4
235+ ]
236+:}
237+
238+>>> :{
239+type OrdersConstraints =
240+ '["pk_orders" ::: PrimaryKey '["id"]
241+ ,"fk_customers" ::: ForeignKey '["customer_id"] "customers" '["id"]
242+ ,"fk_shippers" ::: ForeignKey '["shipper_id"] "shippers" '["id"] ]
243+:}
244+
245+>>> type NamesColumns = '["id" ::: 'NoDef :=> 'NotNull 'PGint4, "name" ::: 'NoDef :=> 'NotNull 'PGtext]
246+>>> type NamesConstraints = '["pk_customers" ::: PrimaryKey '["id"]]
247+>>> :{
248+type OrdersSchema =
249+ '[ "orders" ::: 'Table (OrdersConstraints :=> OrdersColumns)
250+ , "customers" ::: 'Table (NamesConstraints :=> NamesColumns)
251+ , "shippers" ::: 'Table (NamesConstraints :=> NamesColumns) ]
252+:}
253+
259>>> :{
254>>> :{
260let
255let
261− query :: Query
256+ query :: Query (DBof (Public OrdersSchema))
262− '["public" ::: '[ "orders" ::: 'Table (
263− '["pk_orders" ::: PrimaryKey '["id"]
264− ,"fk_customers" ::: ForeignKey '["customer_id"] "customers" '["id"]
265− ,"fk_shippers" ::: ForeignKey '["shipper_id"] "shippers" '["id"]] :=>
266− '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
267− , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4
268− , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
269− , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4
270− ])
271− , "customers" ::: 'Table (
272− '["pk_customers" ::: PrimaryKey '["id"]] :=>
273− '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
274− , "name" ::: 'NoDef :=> 'NotNull 'PGtext
275− ])
276− , "shippers" ::: 'Table (
277− '["pk_shippers" ::: PrimaryKey '["id"]] :=>
278− '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
279− , "name" ::: 'NoDef :=> 'NotNull 'PGtext
280− ])
281− ]]
282 '[]
257 '[]
283 '[ "order_price" ::: 'NotNull 'PGfloat4
258 '[ "order_price" ::: 'NotNull 'PGfloat4
284 , "customer_name" ::: 'NotNull 'PGtext
259 , "customer_name" ::: 'NotNull 'PGtext
@@ -301,12 +276,8 @@ self-join:
301
276
302>>> :{
277>>> :{
303let
278let
304− query :: Query
279+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
305− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
306− '[]
307− '["col" ::: 'Null 'PGint4]
308− query = selectDotStar #t1
309− (from (table (#tab `as` #t1) & crossJoin (table (#tab `as` #t2))))
280+ query = selectDotStar #t1 (from (table (#tab `as` #t1) & crossJoin (table (#tab `as` #t2))))
310in printSQL query
281in printSQL query
311:}
282:}
312SELECT "t1".* FROM "tab" AS "t1" CROSS JOIN "tab" AS "t2"
283SELECT "t1".* FROM "tab" AS "t1" CROSS JOIN "tab" AS "t2"
@@ -325,14 +296,8 @@ set operations:
325
296
326>>> :{
297>>> :{
327let
298let
328− query :: Query
299+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
329− '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
330− '[]
331− '["col" ::: 'Null 'PGint4]
332− query =
333− selectStar (from (table #tab))
300+ query = selectStar (from (table #tab)) `unionAll` selectStar (from (table #tab))
334− `unionAll`
335− selectStar (from (table #tab))
336in printSQL query
301in printSQL query
337:}
302:}
338(SELECT * FROM "tab" AS "tab") UNION ALL (SELECT * FROM "tab" AS "tab")
303(SELECT * FROM "tab" AS "tab") UNION ALL (SELECT * FROM "tab" AS "tab")
@@ -341,20 +306,14 @@ with queries:
341
306
342>>> :{
307>>> :{
343let
308let
344− query :: Query
309+ query :: Query (DBof (Public Schema)) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4]
345− '["public" ::: '[ "t1" ::: 'View
346− '[ "c1" ::: 'NotNull 'PGtext
347− , "c2" ::: 'NotNull 'PGtext] ]]
348− '[]
349− '[ "c1" ::: 'NotNull 'PGtext
350− , "c2" ::: 'NotNull 'PGtext ]
351 query = with (
310 query = with (
352− CommonTableExpression (selectStar (from (view #t1)) `as` #t2) :>>
311+ selectStar (from (table #tab)) `as` #cte1 :>>
353− CommonTableExpression (selectStar (from (view #t2)) `as` #t3) :>> Done
312+ selectStar (from (common #cte1)) `as` #cte2
354− ) (selectStar (from (view #t3)))
313+ ) (selectStar (from (common #cte2)))
355in printSQL query
314in printSQL query
356:}
315:}
357−WITH "t2" AS (SELECT * FROM "t1" AS "t1"), "t3" AS (SELECT * FROM "t2" AS "t2") SELECT * FROM "t3" AS "t3"
316+WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"
358-}
317-}
359newtype Query
318newtype Query
360 (db :: DBType)
319 (db :: DBType)
@@ -515,7 +474,7 @@ selectDistinctDotStar rel tab = UnsafeQuery $
515-- but it can be used on its own.
474-- but it can be used on its own.
516--
475--
517-- >>> type Row = '["a" ::: 'NotNull 'PGint4, "b" ::: 'NotNull 'PGtext]
476-- >>> type Row = '["a" ::: 'NotNull 'PGint4, "b" ::: 'NotNull 'PGtext]
518−-- >>> let query = values (1 `as` #a :* "one" `as` #b) [] :: Query '[] '[] Row
477+-- >>> let query = values (1 `as` #a :* "one" `as` #b) [] :: Query db '[] Row
519-- >>> printSQL query
478-- >>> printSQL query
520-- SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
479-- SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
521values
480values
@@ -879,6 +838,13 @@ view
879view (vw `As` alias) = UnsafeFromClause $
838view (vw `As` alias) = UnsafeFromClause $
880 renderQualifiedAlias vw <+> "AS" <+> renderAlias alias
839 renderQualifiedAlias vw <+> "AS" <+> renderAlias alias
881
840
841+common
842+ :: Has cte commons common
843+ => Aliased Alias (alias ::: cte)
844+ -> FromClause (commons :=> schemas) params '[alias ::: common]
845+common (cte `As` alias) = UnsafeFromClause $
846+ renderAlias cte <+> "AS" <+> renderAlias alias
847+
882{- | @left & crossJoin right@. For every possible combination of rows from
848{- | @left & crossJoin right@. For every possible combination of rows from
883 @left@ and @right@ (i.e., a Cartesian product), the joined table will contain
849 @left@ and @right@ (i.e., a Cartesian product), the joined table will contain
884 a row consisting of all columns in @left@ followed by all columns in @right@.
850 a row consisting of all columns in @left@ followed by all columns in @right@.
@@ -1132,7 +1098,7 @@ is `true` if any equal subquery row is found.
1132The result is `false` if no equal row is found
1098The result is `false` if no equal row is found
1133(including the case where the subquery returns no rows).
1099(including the case where the subquery returns no rows).
1134
1100
1135−>>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1101+>>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1136>>> printSQL $ myRow `rowIn` values_ myRow
1102>>> printSQL $ myRow `rowIn` values_ myRow
1137ROW(1, FALSE) IN (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1103ROW(1, FALSE) IN (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1138-}
1104-}
@@ -1151,7 +1117,7 @@ eqAll
1151 -> Expression db from grp params (nullity 'PGbool)
1117 -> Expression db from grp params (nullity 'PGbool)
1152eqAll = unsafeSubqueryExpression "= ALL"
1118eqAll = unsafeSubqueryExpression "= ALL"
1153
1119
1154−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1120+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1155-- >>> printSQL $ myRow `rowEqAll` values_ myRow
1121-- >>> printSQL $ myRow `rowEqAll` values_ myRow
1156-- ROW(1, FALSE) = ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1122-- ROW(1, FALSE) = ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1157rowEqAll
1123rowEqAll
@@ -1169,7 +1135,7 @@ eqAny
1169 -> Expression db from grp params (nullity 'PGbool)
1135 -> Expression db from grp params (nullity 'PGbool)
1170eqAny = unsafeSubqueryExpression "= ANY"
1136eqAny = unsafeSubqueryExpression "= ANY"
1171
1137
1172−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1138+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1173-- >>> printSQL $ myRow `rowEqAny` values_ myRow
1139-- >>> printSQL $ myRow `rowEqAny` values_ myRow
1174-- ROW(1, FALSE) = ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1140-- ROW(1, FALSE) = ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1175rowEqAny
1141rowEqAny
@@ -1187,7 +1153,7 @@ neqAll
1187 -> Expression db from grp params (nullity 'PGbool)
1153 -> Expression db from grp params (nullity 'PGbool)
1188neqAll = unsafeSubqueryExpression "<> ALL"
1154neqAll = unsafeSubqueryExpression "<> ALL"
1189
1155
1190−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1156+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1191-- >>> printSQL $ myRow `rowNeqAll` values_ myRow
1157-- >>> printSQL $ myRow `rowNeqAll` values_ myRow
1192-- ROW(1, FALSE) <> ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1158-- ROW(1, FALSE) <> ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1193rowNeqAll
1159rowNeqAll
@@ -1205,7 +1171,7 @@ neqAny
1205 -> Expression db from grp params (nullity 'PGbool)
1171 -> Expression db from grp params (nullity 'PGbool)
1206neqAny = unsafeSubqueryExpression "<> ANY"
1172neqAny = unsafeSubqueryExpression "<> ANY"
1207
1173
1208−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1174+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1209-- >>> printSQL $ myRow `rowNeqAny` values_ myRow
1175-- >>> printSQL $ myRow `rowNeqAny` values_ myRow
1210-- ROW(1, FALSE) <> ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1176-- ROW(1, FALSE) <> ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1211rowNeqAny
1177rowNeqAny
@@ -1223,7 +1189,7 @@ allLt
1223 -> Expression db from grp params (nullity 'PGbool)
1189 -> Expression db from grp params (nullity 'PGbool)
1224allLt = unsafeSubqueryExpression "ALL <"
1190allLt = unsafeSubqueryExpression "ALL <"
1225
1191
1226−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1192+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1227-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1193-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1228-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1194-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1229rowLtAll
1195rowLtAll
@@ -1241,7 +1207,7 @@ ltAny
1241 -> Expression db from grp params (nullity 'PGbool)
1207 -> Expression db from grp params (nullity 'PGbool)
1242ltAny = unsafeSubqueryExpression "ANY <"
1208ltAny = unsafeSubqueryExpression "ANY <"
1243
1209
1244−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1210+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1245-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1211-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1246-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1212-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1247rowLtAny
1213rowLtAny
@@ -1259,7 +1225,7 @@ lteAll
1259 -> Expression db from grp params (nullity 'PGbool)
1225 -> Expression db from grp params (nullity 'PGbool)
1260lteAll = unsafeSubqueryExpression "<= ALL"
1226lteAll = unsafeSubqueryExpression "<= ALL"
1261
1227
1262−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1228+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1263-- >>> printSQL $ myRow `rowLteAll` values_ myRow
1229-- >>> printSQL $ myRow `rowLteAll` values_ myRow
1264-- ROW(1, FALSE) <= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1230-- ROW(1, FALSE) <= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1265rowLteAll
1231rowLteAll
@@ -1277,7 +1243,7 @@ lteAny
1277 -> Expression db from grp params (nullity 'PGbool)
1243 -> Expression db from grp params (nullity 'PGbool)
1278lteAny = unsafeSubqueryExpression "<= ANY"
1244lteAny = unsafeSubqueryExpression "<= ANY"
1279
1245
1280−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1246+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1281-- >>> printSQL $ myRow `rowLteAny` values_ myRow
1247-- >>> printSQL $ myRow `rowLteAny` values_ myRow
1282-- ROW(1, FALSE) <= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1248-- ROW(1, FALSE) <= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1283rowLteAny
1249rowLteAny
@@ -1295,7 +1261,7 @@ gtAll
1295 -> Expression db from grp params (nullity 'PGbool)
1261 -> Expression db from grp params (nullity 'PGbool)
1296gtAll = unsafeSubqueryExpression "> ALL"
1262gtAll = unsafeSubqueryExpression "> ALL"
1297
1263
1298−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1264+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1299-- >>> printSQL $ myRow `rowGtAll` values_ myRow
1265-- >>> printSQL $ myRow `rowGtAll` values_ myRow
1300-- ROW(1, FALSE) > ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1266-- ROW(1, FALSE) > ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1301rowGtAll
1267rowGtAll
@@ -1313,7 +1279,7 @@ gtAny
1313 -> Expression db from grp params (nullity 'PGbool)
1279 -> Expression db from grp params (nullity 'PGbool)
1314gtAny = unsafeSubqueryExpression "> ANY"
1280gtAny = unsafeSubqueryExpression "> ANY"
1315
1281
1316−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1282+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1317-- >>> printSQL $ myRow `rowGtAny` values_ myRow
1283-- >>> printSQL $ myRow `rowGtAny` values_ myRow
1318-- ROW(1, FALSE) > ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1284-- ROW(1, FALSE) > ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1319rowGtAny
1285rowGtAny
@@ -1331,7 +1297,7 @@ gteAll
1331 -> Expression db from grp params (nullity 'PGbool)
1297 -> Expression db from grp params (nullity 'PGbool)
1332gteAll = unsafeSubqueryExpression ">= ALL"
1298gteAll = unsafeSubqueryExpression ">= ALL"
1333
1299
1334−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1300+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1335-- >>> printSQL $ myRow `rowGteAll` values_ myRow
1301-- >>> printSQL $ myRow `rowGteAll` values_ myRow
1336-- ROW(1, FALSE) >= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1302-- ROW(1, FALSE) >= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1337rowGteAll
1303rowGteAll
@@ -1349,7 +1315,7 @@ gteAny
1349 -> Expression db from grp params (nullity 'PGbool)
1315 -> Expression db from grp params (nullity 'PGbool)
1350gteAny = unsafeSubqueryExpression ">= ANY"
1316gteAny = unsafeSubqueryExpression ">= ANY"
1351
1317
1352−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression '[] '[] 'Ungrouped '[])) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1318+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression db from grp params)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1353-- >>> printSQL $ myRow `rowGteAny` values_ myRow
1319-- >>> printSQL $ myRow `rowGteAny` values_ myRow
1354-- ROW(1, FALSE) >= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1320-- ROW(1, FALSE) >= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1355rowGteAny
1321rowGteAny