@@ -218,7 +218,8 @@ values from primitive expression using arithmetic, logical,
218and other operations.
218and other operations.
220newtype Expression
220newtype Expression
221− (db :: DBType)
221+ (commons :: FromType)
222+ (schemas :: SchemasType)
222 (params :: [NullityType])
223 (params :: [NullityType])
223 (grp :: Grouping)
224 (grp :: Grouping)
224 (from :: FromType)
225 (from :: FromType)
@@ -226,7 +227,7 @@ newtype Expression
226 = UnsafeExpression { renderExpression :: ByteString }
227 = UnsafeExpression { renderExpression :: ByteString }
227 deriving (GHC.Generic,Show,Eq,Ord,NFData)
228 deriving (GHC.Generic,Show,Eq,Ord,NFData)
229−instance RenderSQL (Expression db params grp from ty) where
230+instance RenderSQL (Expression commons schemas params grp from ty) where
230 renderSQL = renderExpression
231 renderSQL = renderExpression
232{- | A `HasParameter` constraint is used to indicate a value that is
233{- | A `HasParameter` constraint is used to indicate a value that is
@@ -244,12 +245,12 @@ class KnownNat n => HasParameter
244 | n params -> ty where
245 | n params -> ty where
245 -- | `parameter` takes a `Nat` using type application and a `TypeExpression`.
246 -- | `parameter` takes a `Nat` using type application and a `TypeExpression`.
247− -- >>> let expr = parameter @1 int4 :: Expression (DBof schemas) '[ 'Null 'PGint4] grp from ('Null 'PGint4)
248+ -- >>> let expr = parameter @1 int4 :: Expression '[] schemas '[ 'Null 'PGint4] grp from ('Null 'PGint4)
248 -- >>> printSQL expr
249 -- >>> printSQL expr
249 -- ($1 :: int4)
250 -- ($1 :: int4)
250 parameter
251 parameter
251 :: TypeExpression schemas ty
252 :: TypeExpression schemas ty
252− -> Expression (commons :=> schemas) params grp from ty
253+ -> Expression commons schemas params grp from ty
253 parameter ty = UnsafeExpression $ parenthesized $
254 parameter ty = UnsafeExpression $ parenthesized $
254 "$" <> renderNat @n <+> "::"
255 "$" <> renderNat @n <+> "::"
255 <+> renderSQL ty
256 <+> renderSQL ty
@@ -260,38 +261,38 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
260-- | `param` takes a `Nat` using type application and for basic types,
261-- | `param` takes a `Nat` using type application and for basic types,
261-- infers a `TypeExpression`.
262-- infers a `TypeExpression`.
263−-- >>> let expr = param @1 :: Expression (commons :=> schemas) '[ 'Null 'PGint4] grp from ('Null 'PGint4)
264+-- >>> let expr = param @1 :: Expression commons schemas '[ 'Null 'PGint4] grp from ('Null 'PGint4)
264-- >>> printSQL expr
265-- >>> printSQL expr
265-- ($1 :: int4)
266-- ($1 :: int4)
267− :: forall n db commons schemas params from grp ty
268+ :: forall n commons schemas params from grp ty
268− . (db ~ (commons :=> schemas), PGTyped schemas ty, HasParameter n params ty)
269+ . (PGTyped schemas ty, HasParameter n params ty)
269− => Expression db params grp from ty -- ^ param
270+ => Expression commons schemas params grp from ty -- ^ param
270param = parameter @n (pgtype @schemas)
271param = parameter @n (pgtype @schemas)
272instance (HasUnique tab from row, Has col row ty)
273instance (HasUnique tab from row, Has col row ty)
273− => IsLabel col (Expression db params 'Ungrouped from ty) where
274+ => IsLabel col (Expression commons schemas params 'Ungrouped from ty) where
274 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
275 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
275instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
276instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
276 => IsLabel col
277 => IsLabel col
277− (Aliased (Expression db params 'Ungrouped from) column) where
278+ (Aliased (Expression commons schemas params 'Ungrouped from) column) where
278 fromLabel = fromLabel @col `As` Alias
279 fromLabel = fromLabel @col `As` Alias
279instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
280instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
280 => IsLabel col
281 => IsLabel col
281− (NP (Aliased (Expression db params 'Ungrouped from)) columns) where
282+ (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
282 fromLabel = fromLabel @col :* Nil
283 fromLabel = fromLabel @col :* Nil
284instance (Has tab from row, Has col row ty)
285instance (Has tab from row, Has col row ty)
285− => IsQualified tab col (Expression db params 'Ungrouped from ty) where
286+ => IsQualified tab col (Expression commons schemas params 'Ungrouped from ty) where
286 tab ! col = UnsafeExpression $
287 tab ! col = UnsafeExpression $
287 renderSQL tab <> "." <> renderSQL col
288 renderSQL tab <> "." <> renderSQL col
288instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
289instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
289 => IsQualified tab col
290 => IsQualified tab col
290− (Aliased (Expression db params 'Ungrouped from) column) where
291+ (Aliased (Expression commons schemas params 'Ungrouped from) column) where
291 tab ! col = tab ! col `As` col
292 tab ! col = tab ! col `As` col
292instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
293instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
293 => IsQualified tab col
294 => IsQualified tab col
294− (NP (Aliased (Expression db params 'Ungrouped from)) columns) where
295+ (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
295 tab ! col = tab ! col :* Nil
296 tab ! col = tab ! col :* Nil
@@ -299,7 +300,7 @@ instance
299 , Has col row ty
300 , Has col row ty
300 , GroupedBy tab col bys
301 , GroupedBy tab col bys
301 ) => IsLabel col
302 ) => IsLabel col
302− (Expression db params ('Grouped bys) from ty) where
303+ (Expression commons schemas params ('Grouped bys) from ty) where
303 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
304 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
305 ( HasUnique tab from row
306 ( HasUnique tab from row
@@ -307,7 +308,7 @@ instance
307 , GroupedBy tab col bys
308 , GroupedBy tab col bys
308 , column ~ (col ::: ty)
309 , column ~ (col ::: ty)
309 ) => IsLabel col
310 ) => IsLabel col
310− (Aliased (Expression db params ('Grouped bys) from) column) where
311+ (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
311 fromLabel = fromLabel @col `As` Alias
312 fromLabel = fromLabel @col `As` Alias
313 ( HasUnique tab from row
314 ( HasUnique tab from row
@@ -315,7 +316,7 @@ instance
315 , GroupedBy tab col bys
316 , GroupedBy tab col bys
316 , columns ~ '[col ::: ty]
317 , columns ~ '[col ::: ty]
317 ) => IsLabel col
318 ) => IsLabel col
318− (NP (Aliased (Expression db params ('Grouped bys) from)) columns) where
319+ (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
319 fromLabel = fromLabel @col :* Nil
320 fromLabel = fromLabel @col :* Nil
@@ -323,7 +324,7 @@ instance
323 , Has col row ty
324 , Has col row ty
324 , GroupedBy tab col bys
325 , GroupedBy tab col bys
325 ) => IsQualified tab col
326 ) => IsQualified tab col
326− (Expression db params ('Grouped bys) from ty) where
327+ (Expression commons schemas params ('Grouped bys) from ty) where
327 tab ! col = UnsafeExpression $
328 tab ! col = UnsafeExpression $
328 renderSQL tab <> "." <> renderSQL col
329 renderSQL tab <> "." <> renderSQL col
@@ -332,7 +333,7 @@ instance
332 , GroupedBy tab col bys
333 , GroupedBy tab col bys
333 , column ~ (col ::: ty)
334 , column ~ (col ::: ty)
334 ) => IsQualified tab col
335 ) => IsQualified tab col
335− (Aliased (Expression db params ('Grouped bys) from) column) where
336+ (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
336 tab ! col = tab ! col `As` col
337 tab ! col = tab ! col `As` col
338 ( Has tab from row
339 ( Has tab from row
@@ -340,14 +341,14 @@ instance
340 , GroupedBy tab col bys
341 , GroupedBy tab col bys
341 , columns ~ '[col ::: ty]
342 , columns ~ '[col ::: ty]
342 ) => IsQualified tab col
343 ) => IsQualified tab col
343− (NP (Aliased (Expression db params ('Grouped bys) from)) columns) where
344+ (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
344 tab ! col = tab ! col :* Nil
345 tab ! col = tab ! col :* Nil
346-- | analagous to `Nothing`
347-- | analagous to `Nothing`
348-- >>> printSQL null_
349-- >>> printSQL null_
350−null_ :: Expression db rels grouping params ('Null ty)
351+null_ :: Expression commons schemas rels grouping params ('Null ty)
351null_ = UnsafeExpression "NULL"
352null_ = UnsafeExpression "NULL"
353-- | analagous to `Just`
354-- | analagous to `Just`
@@ -355,8 +356,8 @@ null_ = UnsafeExpression "NULL"
355-- >>> printSQL $ notNull true
356-- >>> printSQL $ notNull true
358− :: Expression db rels grouping params ('NotNull ty)
359+ :: Expression commons schemas rels grouping params ('NotNull ty)
359− -> Expression db rels grouping params ('Null ty)
360+ -> Expression commons schemas rels grouping params ('Null ty)
360notNull = UnsafeExpression . renderSQL
361notNull = UnsafeExpression . renderSQL
362-- | return the leftmost value which is not NULL
363-- | return the leftmost value which is not NULL
@@ -364,11 +365,11 @@ notNull = UnsafeExpression . renderSQL
364-- >>> printSQL $ coalesce [null_, true] false
365-- >>> printSQL $ coalesce [null_, true] false
365-- COALESCE(NULL, TRUE, FALSE)
366-- COALESCE(NULL, TRUE, FALSE)
367− :: [Expression db params grp from ('Null ty)]
368+ :: [Expression commons schemas params grp from ('Null ty)]
368 -- ^ @NULL@s may be present
369 -- ^ @NULL@s may be present
369− -> Expression db params grp from ('NotNull ty)
370+ -> Expression commons schemas params grp from ('NotNull ty)
370 -- ^ @NULL@ is absent
371 -- ^ @NULL@ is absent
371− -> Expression db params grp from ('NotNull ty)
372+ -> Expression commons schemas params grp from ('NotNull ty)
372coalesce nullxs notNullx = UnsafeExpression $
373coalesce nullxs notNullx = UnsafeExpression $
373 "COALESCE" <> parenthesized (commaSeparated
374 "COALESCE" <> parenthesized (commaSeparated
374 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
375 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
@@ -378,26 +379,26 @@ coalesce nullxs notNullx = UnsafeExpression $
378-- >>> printSQL $ fromNull true null_
379-- >>> printSQL $ fromNull true null_
379-- COALESCE(NULL, TRUE)
380-- COALESCE(NULL, TRUE)
381− :: Expression db params grp from ('NotNull ty)
382+ :: Expression commons schemas params grp from ('NotNull ty)
382 -- ^ what to convert @NULL@ to
383 -- ^ what to convert @NULL@ to
383− -> Expression db params grp from ('Null ty)
384+ -> Expression commons schemas params grp from ('Null ty)
384− -> Expression db params grp from ('NotNull ty)
385+ -> Expression commons schemas params grp from ('NotNull ty)
385fromNull notNullx nullx = coalesce [nullx] notNullx
386fromNull notNullx nullx = coalesce [nullx] notNullx
387-- | >>> printSQL $ null_ & isNull
388-- | >>> printSQL $ null_ & isNull
388-- NULL IS NULL
389-- NULL IS NULL
390− :: Expression db params grp from ('Null ty)
391+ :: Expression commons schemas params grp from ('Null ty)
391 -- ^ possibly @NULL@
392 -- ^ possibly @NULL@
392− -> Condition db params grp from
393+ -> Condition commons schemas params grp from
393isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
394isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
395-- | >>> printSQL $ null_ & isNotNull
396-- | >>> printSQL $ null_ & isNotNull
396-- NULL IS NOT NULL
397-- NULL IS NOT NULL
398− :: Expression db params grp from ('Null ty)
399+ :: Expression commons schemas params grp from ('Null ty)
399 -- ^ possibly @NULL@
400 -- ^ possibly @NULL@
400− -> Condition db params grp from
401+ -> Condition commons schemas params grp from
401isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
402isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
403-- | analagous to `maybe` using @IS NULL@
404-- | analagous to `maybe` using @IS NULL@
@@ -405,13 +406,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
405-- >>> printSQL $ matchNull true not_ null_
406-- >>> printSQL $ matchNull true not_ null_
406-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
407-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
408− :: Expression db params grp from (nullty)
409+ :: Expression commons schemas params grp from (nullty)
409 -- ^ what to convert @NULL@ to
410 -- ^ what to convert @NULL@ to
410− -> ( Expression db params grp from ('NotNull ty)
411+ -> ( Expression commons schemas params grp from ('NotNull ty)
411− -> Expression db params grp from (nullty) )
412+ -> Expression commons schemas params grp from (nullty) )
412 -- ^ function to perform when @NULL@ is absent
413 -- ^ function to perform when @NULL@ is absent
413− -> Expression db params grp from ('Null ty)
414+ -> Expression commons schemas params grp from ('Null ty)
414− -> Expression db params grp from (nullty)
415+ -> Expression commons schemas params grp from (nullty)
415matchNull y f x = ifThenElse (isNull x) y
416matchNull y f x = ifThenElse (isNull x) y
416 (f (UnsafeExpression (renderSQL x)))
417 (f (UnsafeExpression (renderSQL x)))
@@ -419,25 +420,25 @@ matchNull y f x = ifThenElse (isNull x) y
419`nullIf` gives @NULL@.
420`nullIf` gives @NULL@.
421>>> :set -XTypeApplications -XDataKinds
422>>> :set -XTypeApplications -XDataKinds
422−>>> let expr = nullIf false (param @1) :: Expression (commons :=> schema) '[ 'NotNull 'PGbool] grp from ('Null 'PGbool)
423+>>> let expr = nullIf false (param @1) :: Expression commons schemas '[ 'NotNull 'PGbool] grp from ('Null 'PGbool)
423>>> printSQL expr
424>>> printSQL expr
424NULL IF (FALSE, ($1 :: bool))
425NULL IF (FALSE, ($1 :: bool))
427− :: Expression db params grp from ('NotNull ty)
428+ :: Expression commons schemas params grp from ('NotNull ty)
428 -- ^ @NULL@ is absent
429 -- ^ @NULL@ is absent
429− -> Expression db params grp from ('NotNull ty)
430+ -> Expression commons schemas params grp from ('NotNull ty)
430 -- ^ @NULL@ is absent
431 -- ^ @NULL@ is absent
431− -> Expression db params grp from ('Null ty)
432+ -> Expression commons schemas params grp from ('Null ty)
432nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433 (renderSQL x <> ", " <> renderSQL y)
434 (renderSQL x <> ", " <> renderSQL y)
435-- | >>> printSQL $ array [null_, false, true]
436-- | >>> printSQL $ array [null_, false, true]
436-- ARRAY[NULL, FALSE, TRUE]
437-- ARRAY[NULL, FALSE, TRUE]
438− :: [Expression db params grp from ty]
439+ :: [Expression commons schemas params grp from ty]
439 -- ^ array elements
440 -- ^ array elements
440− -> Expression db params grp from (nullity ('PGvararray ty))
441+ -> Expression commons schemas params grp from (nullity ('PGvararray ty))
441array xs = UnsafeExpression $
442array xs = UnsafeExpression $
442 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
443 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
@@ -445,13 +446,13 @@ array xs = UnsafeExpression $
445-- (ARRAY[NULL, FALSE, TRUE])[2]
446-- (ARRAY[NULL, FALSE, TRUE])[2]
447 :: Word64 -- ^ index
448 :: Word64 -- ^ index
448− -> Expression db params grp from (nullity ('PGvararray ty)) -- ^ array
449+ -> Expression commons schemas params grp from (nullity ('PGvararray ty)) -- ^ array
449− -> Expression db params grp from (NullifyType ty)
450+ -> Expression commons schemas params grp from (NullifyType ty)
450index n expr = UnsafeExpression $
451index n expr = UnsafeExpression $
451 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
452 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
453instance (KnownSymbol label, label `In` labels) => IsPGlabel label
454instance (KnownSymbol label, label `In` labels) => IsPGlabel label
454− (Expression db params grp from (nullity ('PGenum labels))) where
455+ (Expression commons schemas params grp from (nullity ('PGenum labels))) where
455 label = UnsafeExpression $ renderSQL (PGlabel @label)
456 label = UnsafeExpression $ renderSQL (PGlabel @label)
457-- | A row constructor is an expression that builds a row value
458-- | A row constructor is an expression that builds a row value
@@ -463,14 +464,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
463-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
464-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
466−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression db from grp params ('NotNull Complex)
467+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression commons schemas from grp params ('NotNull Complex)
467-- >>> printSQL i
468-- >>> printSQL i
468-- ROW(0, 1)
469-- ROW(0, 1)
470 :: SListI row
471 :: SListI row
471− => NP (Aliased (Expression db params grp from)) row
472+ => NP (Aliased (Expression commons schemas params grp from)) row
472 -- ^ zero or more expressions for the row field values
473 -- ^ zero or more expressions for the row field values
473− -> Expression db params grp from (nullity ('PGcomposite row))
474+ -> Expression commons schemas params grp from (nullity ('PGcomposite row))
474row exprs = UnsafeExpression $ "ROW" <> parenthesized
475row exprs = UnsafeExpression $ "ROW" <> parenthesized
475 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
476 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
@@ -479,10 +480,9 @@ row exprs = UnsafeExpression $ "ROW" <> parenthesized
479-- '[ "real" ::: 'NotNull 'PGfloat8
480-- '[ "real" ::: 'NotNull 'PGfloat8
480-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
481-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
481-- type Schema = '["complex" ::: 'Typedef Complex]
482-- type Schema = '["complex" ::: 'Typedef Complex]
482−-- type DB = DBof (Public Schema)
485−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression DB from grp params ('NotNull Complex)
485+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression '[] (Public Schema) from grp params ('NotNull Complex)
486-- >>> printSQL $ i & field #complex #imaginary
486-- >>> printSQL $ i & field #complex #imaginary
487-- (ROW(0, 1)::"complex")."imaginary"
487-- (ROW(0, 1)::"complex")."imaginary"
@@ -491,41 +491,41 @@ field
491 , Has field row ty)
491 , Has field row ty)
492 => QualifiedAlias sch tydef -- ^ row type
492 => QualifiedAlias sch tydef -- ^ row type
493 -> Alias field -- ^ field name
493 -> Alias field -- ^ field name
494− -> Expression (commons :=> schemas) params grp from ('NotNull ('PGcomposite row))
494+ -> Expression commons schemas params grp from ('NotNull ('PGcomposite row))
495− -> Expression (commons :=> schemas) params grp from ty
495+ -> Expression commons schemas params grp from ty
496field td fld expr = UnsafeExpression $
496field td fld expr = UnsafeExpression $
497 parenthesized (renderSQL expr <> "::" <> renderSQL td)
497 parenthesized (renderSQL expr <> "::" <> renderSQL td)
498 <> "." <> renderSQL fld
498 <> "." <> renderSQL fld
500instance Semigroup
500instance Semigroup
501− (Expression db params grp from (nullity ('PGvararray ty))) where
501+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
502 (<>) = unsafeBinaryOp "||"
502 (<>) = unsafeBinaryOp "||"
504instance Monoid
504instance Monoid
505− (Expression db params grp from (nullity ('PGvararray ty))) where
505+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
506 mempty = array []
506 mempty = array []
507 mappend = (<>)
507 mappend = (<>)
509−-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression (commons :=> schemas) '[ 'NotNull 'PGtimestamptz] grp from ('NotNull 'PGtimestamptz)
509+-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression commons schemas '[ 'NotNull 'PGtimestamptz] grp from ('NotNull 'PGtimestamptz)
510-- >>> printSQL expr
510-- >>> printSQL expr
511-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
511-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
513− :: Expression db params grp from (nullty)
513+ :: Expression commons schemas params grp from (nullty)
514 -- ^ needs at least 1 argument
514 -- ^ needs at least 1 argument
515− -> [Expression db params grp from (nullty)]
515+ -> [Expression commons schemas params grp from (nullty)]
516 -- ^ or more
516 -- ^ or more
517− -> Expression db params grp from (nullty)
517+ -> Expression commons schemas params grp from (nullty)
518greatest x xs = UnsafeExpression $ "GREATEST("
518greatest x xs = UnsafeExpression $ "GREATEST("
519 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
519 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
521-- | >>> printSQL $ least currentTimestamp [null_]
521-- | >>> printSQL $ least currentTimestamp [null_]
522-- LEAST(CURRENT_TIMESTAMP, NULL)
522-- LEAST(CURRENT_TIMESTAMP, NULL)
524− :: Expression db params grp from (nullty)
524+ :: Expression commons schemas params grp from (nullty)
525 -- ^ needs at least 1 argument
525 -- ^ needs at least 1 argument
526− -> [Expression db params grp from (nullty)]
526+ -> [Expression commons schemas params grp from (nullty)]
527 -- ^ or more
527 -- ^ or more
528− -> Expression db params grp from (nullty)
528+ -> Expression commons schemas params grp from (nullty)
529least x xs = UnsafeExpression $ "LEAST("
529least x xs = UnsafeExpression $ "LEAST("
530 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
530 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
@@ -534,9 +534,9 @@ least x xs = UnsafeExpression $ "LEAST("
534unsafeBinaryOp
534unsafeBinaryOp
535 :: ByteString
535 :: ByteString
536 -- ^ operator
536 -- ^ operator
537− -> Expression db params grp from (ty0)
537+ -> Expression commons schemas params grp from (ty0)
538− -> Expression db params grp from (ty1)
538+ -> Expression commons schemas params grp from (ty1)
539− -> Expression db params grp from (ty2)
539+ -> Expression commons schemas params grp from (ty2)
540unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
540unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541 renderSQL x <+> op <+> renderSQL y
541 renderSQL x <+> op <+> renderSQL y
@@ -545,8 +545,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
545unsafeUnaryOp
545unsafeUnaryOp
546 :: ByteString
546 :: ByteString
547 -- ^ operator
547 -- ^ operator
548− -> Expression db params grp from (ty0)
548+ -> Expression commons schemas params grp from (ty0)
549− -> Expression db params grp from (ty1)
549+ -> Expression commons schemas params grp from (ty1)
550unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
550unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551 op <+> renderSQL x
551 op <+> renderSQL x
@@ -555,8 +555,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
555unsafeFunction
555unsafeFunction
556 :: ByteString
556 :: ByteString
557 -- ^ function
557 -- ^ function
558− -> Expression db params grp from (xty)
558+ -> Expression commons schemas params grp from (xty)
559− -> Expression db params grp from (yty)
559+ -> Expression commons schemas params grp from (yty)
560unsafeFunction fun x = UnsafeExpression $
560unsafeFunction fun x = UnsafeExpression $
561 fun <> parenthesized (renderSQL x)
561 fun <> parenthesized (renderSQL x)
@@ -565,13 +565,13 @@ unsafeVariadicFunction
565 :: SListI elems
565 :: SListI elems
566 => ByteString
566 => ByteString
567 -- ^ function
567 -- ^ function
568− -> NP (Expression db params grp from) elems
568+ -> NP (Expression commons schemas params grp from) elems
569− -> Expression db params grp from ret
569+ -> Expression commons schemas params grp from ret
570unsafeVariadicFunction fun x = UnsafeExpression $
570unsafeVariadicFunction fun x = UnsafeExpression $
571 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
571 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
573instance ty `In` PGNum
573instance ty `In` PGNum
574− => Num (Expression db params grp from (nullity ty)) where
574+ => Num (Expression commons schemas params grp from (nullity ty)) where
575 (+) = unsafeBinaryOp "+"
575 (+) = unsafeBinaryOp "+"
576 (-) = unsafeBinaryOp "-"
576 (-) = unsafeBinaryOp "-"
577 (*) = unsafeBinaryOp "*"
577 (*) = unsafeBinaryOp "*"
@@ -583,12 +583,12 @@ instance ty `In` PGNum
585instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
585instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
586− (Expression db params grp from (nullity ty)) where
586+ (Expression commons schemas params grp from (nullity ty)) where
587 (/) = unsafeBinaryOp "/"
587 (/) = unsafeBinaryOp "/"
588 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
588 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
590instance (ty `In` PGNum, ty `In` PGFloating) => Floating
590instance (ty `In` PGNum, ty `In` PGFloating) => Floating
591− (Expression db params grp from (nullity ty)) where
591+ (Expression commons schemas params grp from (nullity ty)) where
592 pi = UnsafeExpression "pi()"
592 pi = UnsafeExpression "pi()"
593 exp = unsafeFunction "exp"
593 exp = unsafeFunction "exp"
594 log = unsafeFunction "ln"
594 log = unsafeFunction "ln"
@@ -611,18 +611,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
612-- | >>> :{
612-- | >>> :{
614−-- expression :: Expression db params grp from (nullity 'PGfloat4)
614+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
615-- expression = atan2_ pi 2
615-- expression = atan2_ pi 2
616-- in printSQL expression
616-- in printSQL expression
618-- atan2(pi(), 2)
618-- atan2(pi(), 2)
620 :: float `In` PGFloating
620 :: float `In` PGFloating
621− => Expression db params grp from (nullity float)
621+ => Expression commons schemas params grp from (nullity float)
622 -- ^ numerator
622 -- ^ numerator
623− -> Expression db params grp from (nullity float)
623+ -> Expression commons schemas params grp from (nullity float)
624 -- ^ denominator
624 -- ^ denominator
625− -> Expression db params grp from (nullity float)
625+ -> Expression commons schemas params grp from (nullity float)
626atan2_ y x = UnsafeExpression $
626atan2_ y x = UnsafeExpression $
627 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
627 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
@@ -635,9 +635,9 @@ atan2_ y x = UnsafeExpression $
636 :: TypeExpression schemas ty1
636 :: TypeExpression schemas ty1
637 -- ^ type to cast as
637 -- ^ type to cast as
638− -> Expression (commons :=> schemas) params grp from ty0
638+ -> Expression commons schemas params grp from ty0
639 -- ^ value to convert
639 -- ^ value to convert
640− -> Expression (commons :=> schemas) params grp from ty1
640+ -> Expression commons schemas params grp from ty1
641cast ty x = UnsafeExpression $ parenthesized $
641cast ty x = UnsafeExpression $ parenthesized $
642 renderSQL x <+> "::" <+> renderSQL ty
642 renderSQL x <+> "::" <+> renderSQL ty
@@ -645,136 +645,136 @@ cast ty x = UnsafeExpression $ parenthesized $
648−-- expression :: Expression db params grp from (nullity 'PGint2)
648+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
649-- expression = 5 `quot_` 2
649-- expression = 5 `quot_` 2
650-- in printSQL expression
650-- in printSQL expression
652-- (5 / 2)
652-- (5 / 2)
654 :: int `In` PGIntegral
654 :: int `In` PGIntegral
655− => Expression db params grp from (nullity int)
655+ => Expression commons schemas params grp from (nullity int)
656 -- ^ numerator
656 -- ^ numerator
657− -> Expression db params grp from (nullity int)
657+ -> Expression commons schemas params grp from (nullity int)
658 -- ^ denominator
658 -- ^ denominator
659− -> Expression db params grp from (nullity int)
659+ -> Expression commons schemas params grp from (nullity int)
660quot_ = unsafeBinaryOp "/"
660quot_ = unsafeBinaryOp "/"
662-- | remainder upon integer division
662-- | remainder upon integer division
666−-- expression :: Expression db params grp from (nullity 'PGint2)
666+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
667-- expression = 5 `rem_` 2
667-- expression = 5 `rem_` 2
668-- in printSQL expression
668-- in printSQL expression
670-- (5 % 2)
670-- (5 % 2)
672 :: int `In` PGIntegral
672 :: int `In` PGIntegral
673− => Expression db params grp from (nullity int)
673+ => Expression commons schemas params grp from (nullity int)
674 -- ^ numerator
674 -- ^ numerator
675− -> Expression db params grp from (nullity int)
675+ -> Expression commons schemas params grp from (nullity int)
676 -- ^ denominator
676 -- ^ denominator
677− -> Expression db params grp from (nullity int)
677+ -> Expression commons schemas params grp from (nullity int)
678rem_ = unsafeBinaryOp "%"
678rem_ = unsafeBinaryOp "%"
680-- | >>> :{
680-- | >>> :{
682−-- expression :: Expression db params grp from (nullity 'PGfloat4)
682+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
683-- expression = trunc pi
683-- expression = trunc pi
684-- in printSQL expression
684-- in printSQL expression
686-- trunc(pi())
686-- trunc(pi())
688 :: frac `In` PGFloating
688 :: frac `In` PGFloating
689− => Expression db params grp from (nullity frac)
689+ => Expression commons schemas params grp from (nullity frac)
690 -- ^ fractional number
690 -- ^ fractional number
691− -> Expression db params grp from (nullity frac)
691+ -> Expression commons schemas params grp from (nullity frac)
692trunc = unsafeFunction "trunc"
692trunc = unsafeFunction "trunc"
694-- | >>> :{
694-- | >>> :{
696−-- expression :: Expression db params grp from (nullity 'PGfloat4)
696+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
697-- expression = round_ pi
697-- expression = round_ pi
698-- in printSQL expression
698-- in printSQL expression
700-- round(pi())
700-- round(pi())
702 :: frac `In` PGFloating
702 :: frac `In` PGFloating
703− => Expression db params grp from (nullity frac)
703+ => Expression commons schemas params grp from (nullity frac)
704 -- ^ fractional number
704 -- ^ fractional number
705− -> Expression db params grp from (nullity frac)
705+ -> Expression commons schemas params grp from (nullity frac)
706round_ = unsafeFunction "round"
706round_ = unsafeFunction "round"
708-- | >>> :{
708-- | >>> :{
710−-- expression :: Expression db params grp from (nullity 'PGfloat4)
710+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
711-- expression = ceiling_ pi
711-- expression = ceiling_ pi
712-- in printSQL expression
712-- in printSQL expression
714-- ceiling(pi())
714-- ceiling(pi())
716 :: frac `In` PGFloating
716 :: frac `In` PGFloating
717− => Expression db params grp from (nullity frac)
717+ => Expression commons schemas params grp from (nullity frac)
718 -- ^ fractional number
718 -- ^ fractional number
719− -> Expression db params grp from (nullity frac)
719+ -> Expression commons schemas params grp from (nullity frac)
720ceiling_ = unsafeFunction "ceiling"
720ceiling_ = unsafeFunction "ceiling"
722-- | A `Condition` is an `Expression`, which can evaluate
722-- | A `Condition` is an `Expression`, which can evaluate
723-- to `true`, `false` or `null_`. This is because SQL uses
723-- to `true`, `false` or `null_`. This is because SQL uses
724-- a three valued logic.
724-- a three valued logic.
725−type Condition db params grp from =
725+type Condition commons schemas params grp from =
726− Expression db params grp from ('Null 'PGbool)
726+ Expression commons schemas params grp from ('Null 'PGbool)
728-- | >>> printSQL true
728-- | >>> printSQL true
730−true :: Expression db params grp from (nullity 'PGbool)
730+true :: Expression commons schemas params grp from (nullity 'PGbool)
731true = UnsafeExpression "TRUE"
731true = UnsafeExpression "TRUE"
733-- | >>> printSQL false
733-- | >>> printSQL false
735−false :: Expression db params grp from (nullity 'PGbool)
735+false :: Expression commons schemas params grp from (nullity 'PGbool)
736false = UnsafeExpression "FALSE"
736false = UnsafeExpression "FALSE"
738-- | >>> printSQL $ not_ true
738-- | >>> printSQL $ not_ true
739-- (NOT TRUE)
739-- (NOT TRUE)
741− :: Expression db params grp from (nullity 'PGbool)
741+ :: Expression commons schemas params grp from (nullity 'PGbool)
742− -> Expression db params grp from (nullity 'PGbool)
742+ -> Expression commons schemas params grp from (nullity 'PGbool)
743not_ = unsafeUnaryOp "NOT"
743not_ = unsafeUnaryOp "NOT"
745-- | >>> printSQL $ true .&& false
745-- | >>> printSQL $ true .&& false
746-- (TRUE AND FALSE)
746-- (TRUE AND FALSE)
748− :: Expression db params grp from (nullity 'PGbool)
748+ :: Expression commons schemas params grp from (nullity 'PGbool)
749− -> Expression db params grp from (nullity 'PGbool)
749+ -> Expression commons schemas params grp from (nullity 'PGbool)
750− -> Expression db params grp from (nullity 'PGbool)
750+ -> Expression commons schemas params grp from (nullity 'PGbool)
751infixr 3 .&&
751infixr 3 .&&
752(.&&) = unsafeBinaryOp "AND"
752(.&&) = unsafeBinaryOp "AND"
754-- | >>> printSQL $ true .|| false
754-- | >>> printSQL $ true .|| false
755-- (TRUE OR FALSE)
755-- (TRUE OR FALSE)
757− :: Expression db params grp from (nullity 'PGbool)
757+ :: Expression commons schemas params grp from (nullity 'PGbool)
758− -> Expression db params grp from (nullity 'PGbool)
758+ -> Expression commons schemas params grp from (nullity 'PGbool)
759− -> Expression db params grp from (nullity 'PGbool)
759+ -> Expression commons schemas params grp from (nullity 'PGbool)
760infixr 2 .||
760infixr 2 .||
761(.||) = unsafeBinaryOp "OR"
761(.||) = unsafeBinaryOp "OR"
763-- | >>> :{
763-- | >>> :{
765−-- expression :: Expression db params grp from (nullity 'PGint2)
765+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
766-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
766-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
767-- in printSQL expression
767-- in printSQL expression
769-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
769-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
770caseWhenThenElse
770caseWhenThenElse
771− :: [ ( Condition db params grp from
771+ :: [ ( Condition commons schemas params grp from
772− , Expression db params grp from ty
772+ , Expression commons schemas params grp from ty
774 -- ^ whens and thens
774 -- ^ whens and thens
775− -> Expression db params grp from ty
775+ -> Expression commons schemas params grp from ty
776 -- ^ else
776 -- ^ else
777− -> Expression db params grp from ty
777+ -> Expression commons schemas params grp from ty
778caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
778caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
780 , mconcat
780 , mconcat
@@ -790,16 +790,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
791-- | >>> :{
791-- | >>> :{
793−-- expression :: Expression db params grp from (nullity 'PGint2)
793+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
794-- expression = ifThenElse true 1 0
794-- expression = ifThenElse true 1 0
795-- in printSQL expression
795-- in printSQL expression
797-- CASE WHEN TRUE THEN 1 ELSE 0 END
797-- CASE WHEN TRUE THEN 1 ELSE 0 END
798ifThenElse
798ifThenElse
799− :: Condition db params grp from
799+ :: Condition commons schemas params grp from
800− -> Expression db params grp from ty -- ^ then
800+ -> Expression commons schemas params grp from ty -- ^ then
801− -> Expression db params grp from ty -- ^ else
801+ -> Expression commons schemas params grp from ty -- ^ else
802− -> Expression db params grp from ty
802+ -> Expression commons schemas params grp from ty
803ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
803ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
805-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
805-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -808,85 +808,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
808-- >>> printSQL $ true .== null_
808-- >>> printSQL $ true .== null_
809-- (TRUE = NULL)
809-- (TRUE = NULL)
811− :: Expression db params grp from (nullity0 ty) -- ^ lhs
811+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
812− -> Expression db params grp from (nullity1 ty) -- ^ rhs
812+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
813− -> Condition db params grp from
813+ -> Condition commons schemas params grp from
814(.==) = unsafeBinaryOp "="
814(.==) = unsafeBinaryOp "="
815infix 4 .==
815infix 4 .==
817-- | >>> printSQL $ true ./= null_
817-- | >>> printSQL $ true ./= null_
818-- (TRUE <> NULL)
818-- (TRUE <> NULL)
820− :: Expression db params grp from (nullity0 ty) -- ^ lhs
820+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
821− -> Expression db params grp from (nullity1 ty) -- ^ rhs
821+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
822− -> Condition db params grp from
822+ -> Condition commons schemas params grp from
823(./=) = unsafeBinaryOp "<>"
823(./=) = unsafeBinaryOp "<>"
824infix 4 ./=
824infix 4 ./=
826-- | >>> printSQL $ true .>= null_
826-- | >>> printSQL $ true .>= null_
827-- (TRUE >= NULL)
827-- (TRUE >= NULL)
829− :: Expression db params grp from (nullity0 ty) -- ^ lhs
829+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
830− -> Expression db params grp from (nullity1 ty) -- ^ rhs
830+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
831− -> Condition db params grp from
831+ -> Condition commons schemas params grp from
832(.>=) = unsafeBinaryOp ">="
832(.>=) = unsafeBinaryOp ">="
833infix 4 .>=
833infix 4 .>=
835-- | >>> printSQL $ true .< null_
835-- | >>> printSQL $ true .< null_
836-- (TRUE < NULL)
836-- (TRUE < NULL)
838− :: Expression db params grp from (nullity0 ty) -- ^ lhs
838+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
839− -> Expression db params grp from (nullity1 ty) -- ^ rhs
839+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
840− -> Condition db params grp from
840+ -> Condition commons schemas params grp from
841(.<) = unsafeBinaryOp "<"
841(.<) = unsafeBinaryOp "<"
842infix 4 .<
842infix 4 .<
844-- | >>> printSQL $ true .<= null_
844-- | >>> printSQL $ true .<= null_
845-- (TRUE <= NULL)
845-- (TRUE <= NULL)
847− :: Expression db params grp from (nullity0 ty) -- ^ lhs
847+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
848− -> Expression db params grp from (nullity1 ty) -- ^ rhs
848+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
849− -> Condition db params grp from
849+ -> Condition commons schemas params grp from
850(.<=) = unsafeBinaryOp "<="
850(.<=) = unsafeBinaryOp "<="
851infix 4 .<=
851infix 4 .<=
853-- | >>> printSQL $ true .> null_
853-- | >>> printSQL $ true .> null_
854-- (TRUE > NULL)
854-- (TRUE > NULL)
856− :: Expression db params grp from (nullity0 ty) -- ^ lhs
856+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
857− -> Expression db params grp from (nullity1 ty) -- ^ rhs
857+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
858− -> Condition db params grp from
858+ -> Condition commons schemas params grp from
859(.>) = unsafeBinaryOp ">"
859(.>) = unsafeBinaryOp ">"
860infix 4 .>
860infix 4 .>
862-- | >>> printSQL currentDate
862-- | >>> printSQL currentDate
863-- CURRENT_DATE
863-- CURRENT_DATE
864currentDate
864currentDate
865− :: Expression db params grp from (nullity 'PGdate)
865+ :: Expression commons schemas params grp from (nullity 'PGdate)
866currentDate = UnsafeExpression "CURRENT_DATE"
866currentDate = UnsafeExpression "CURRENT_DATE"
868-- | >>> printSQL currentTime
868-- | >>> printSQL currentTime
869-- CURRENT_TIME
869-- CURRENT_TIME
870currentTime
870currentTime
871− :: Expression db params grp from (nullity 'PGtimetz)
871+ :: Expression commons schemas params grp from (nullity 'PGtimetz)
872currentTime = UnsafeExpression "CURRENT_TIME"
872currentTime = UnsafeExpression "CURRENT_TIME"
874-- | >>> printSQL currentTimestamp
874-- | >>> printSQL currentTimestamp
875-- CURRENT_TIMESTAMP
875-- CURRENT_TIMESTAMP
876currentTimestamp
876currentTimestamp
877− :: Expression db params grp from (nullity 'PGtimestamptz)
877+ :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
878currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
878currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
880-- | >>> printSQL localTime
880-- | >>> printSQL localTime
881-- LOCALTIME
881-- LOCALTIME
883− :: Expression db params grp from (nullity 'PGtime)
883+ :: Expression commons schemas params grp from (nullity 'PGtime)
884localTime = UnsafeExpression "LOCALTIME"
884localTime = UnsafeExpression "LOCALTIME"
886-- | >>> printSQL localTimestamp
886-- | >>> printSQL localTimestamp
887-- LOCALTIMESTAMP
887-- LOCALTIMESTAMP
888localTimestamp
888localTimestamp
889− :: Expression db params grp from (nullity 'PGtimestamp)
889+ :: Expression commons schemas params grp from (nullity 'PGtimestamp)
890localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
890localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
892{-----------------------------------------
892{-----------------------------------------
@@ -894,7 +894,7 @@ text
894-----------------------------------------}
894-----------------------------------------}
896instance IsString
896instance IsString
897− (Expression db params grp from (nullity 'PGtext)) where
897+ (Expression commons schemas params grp from (nullity 'PGtext)) where
898 fromString str = UnsafeExpression $
898 fromString str = UnsafeExpression $
899 "E\'" <> fromString (escape =<< str) <> "\'"
899 "E\'" <> fromString (escape =<< str) <> "\'"
@@ -910,36 +910,36 @@ instance IsString
912instance Semigroup
912instance Semigroup
913− (Expression db params grp from (nullity 'PGtext)) where
913+ (Expression commons schemas params grp from (nullity 'PGtext)) where
914 (<>) = unsafeBinaryOp "||"
914 (<>) = unsafeBinaryOp "||"
916instance Monoid
916instance Monoid
917− (Expression db params grp from (nullity 'PGtext)) where
917+ (Expression commons schemas params grp from (nullity 'PGtext)) where
918 mempty = fromString ""
918 mempty = fromString ""
919 mappend = (<>)
919 mappend = (<>)
921-- | >>> printSQL $ lower "ARRRGGG"
921-- | >>> printSQL $ lower "ARRRGGG"
922-- lower(E'ARRRGGG')
922-- lower(E'ARRRGGG')
924− :: Expression db params grp from (nullity 'PGtext)
924+ :: Expression commons schemas params grp from (nullity 'PGtext)
925 -- ^ string to lower case
925 -- ^ string to lower case
926− -> Expression db params grp from (nullity 'PGtext)
926+ -> Expression commons schemas params grp from (nullity 'PGtext)
927lower = unsafeFunction "lower"
927lower = unsafeFunction "lower"
929-- | >>> printSQL $ upper "eeee"
929-- | >>> printSQL $ upper "eeee"
930-- upper(E'eeee')
930-- upper(E'eeee')
932− :: Expression db params grp from (nullity 'PGtext)
932+ :: Expression commons schemas params grp from (nullity 'PGtext)
933 -- ^ string to upper case
933 -- ^ string to upper case
934− -> Expression db params grp from (nullity 'PGtext)
934+ -> Expression commons schemas params grp from (nullity 'PGtext)
935upper = unsafeFunction "upper"
935upper = unsafeFunction "upper"
937-- | >>> printSQL $ charLength "four"
937-- | >>> printSQL $ charLength "four"
938-- char_length(E'four')
938-- char_length(E'four')
939charLength
939charLength
940− :: Expression db params grp from (nullity 'PGtext)
940+ :: Expression commons schemas params grp from (nullity 'PGtext)
941 -- ^ string to measure
941 -- ^ string to measure
942− -> Expression db params grp from (nullity 'PGint4)
942+ -> Expression commons schemas params grp from (nullity 'PGint4)
943charLength = unsafeFunction "char_length"
943charLength = unsafeFunction "char_length"
945-- | The `like` expression returns true if the @string@ matches
945-- | The `like` expression returns true if the @string@ matches
@@ -952,11 +952,11 @@ charLength = unsafeFunction "char_length"
952-- >>> printSQL $ "abc" `like` "a%"
952-- >>> printSQL $ "abc" `like` "a%"
953-- (E'abc' LIKE E'a%')
953-- (E'abc' LIKE E'a%')
955− :: Expression db params grp from (nullity 'PGtext)
955+ :: Expression commons schemas params grp from (nullity 'PGtext)
956 -- ^ string
956 -- ^ string
957− -> Expression db params grp from (nullity 'PGtext)
957+ -> Expression commons schemas params grp from (nullity 'PGtext)
958 -- ^ pattern
958 -- ^ pattern
959− -> Expression db params grp from (nullity 'PGbool)
959+ -> Expression commons schemas params grp from (nullity 'PGbool)
960like = unsafeBinaryOp "LIKE"
960like = unsafeBinaryOp "LIKE"
962-- | The key word ILIKE can be used instead of LIKE to make the
962-- | The key word ILIKE can be used instead of LIKE to make the
@@ -965,11 +965,11 @@ like = unsafeBinaryOp "LIKE"
965-- >>> printSQL $ "abc" `ilike` "a%"
965-- >>> printSQL $ "abc" `ilike` "a%"
966-- (E'abc' ILIKE E'a%')
966-- (E'abc' ILIKE E'a%')
968− :: Expression db params grp from (nullity 'PGtext)
968+ :: Expression commons schemas params grp from (nullity 'PGtext)
969 -- ^ string
969 -- ^ string
970− -> Expression db params grp from (nullity 'PGtext)
970+ -> Expression commons schemas params grp from (nullity 'PGtext)
971 -- ^ pattern
971 -- ^ pattern
972− -> Expression db params grp from (nullity 'PGbool)
972+ -> Expression commons schemas params grp from (nullity 'PGbool)
973ilike = unsafeBinaryOp "ILIKE"
973ilike = unsafeBinaryOp "ILIKE"
975{-----------------------------------------
975{-----------------------------------------
@@ -984,36 +984,36 @@ Table 9.44: json and jsonb operators
984-- | Get JSON value (object field or array element) at a key.
984-- | Get JSON value (object field or array element) at a key.
986 :: (json `In` PGJsonType, key `In` PGJsonKey)
986 :: (json `In` PGJsonType, key `In` PGJsonKey)
987− => Expression db params grp from (nullity json)
987+ => Expression commons schemas params grp from (nullity json)
988− -> Expression db params grp from (nullity key)
988+ -> Expression commons schemas params grp from (nullity key)
989− -> Expression db params grp from ('Null json)
989+ -> Expression commons schemas params grp from ('Null json)
990infixl 8 .->
990infixl 8 .->
991(.->) = unsafeBinaryOp "->"
991(.->) = unsafeBinaryOp "->"
993-- | Get JSON value (object field or array element) at a key, as text.
993-- | Get JSON value (object field or array element) at a key, as text.
995 :: (json `In` PGJsonType, key `In` PGJsonKey)
995 :: (json `In` PGJsonType, key `In` PGJsonKey)
996− => Expression db params grp from (nullity json)
996+ => Expression commons schemas params grp from (nullity json)
997− -> Expression db params grp from (nullity key)
997+ -> Expression commons schemas params grp from (nullity key)
998− -> Expression db params grp from ('Null 'PGtext)
998+ -> Expression commons schemas params grp from ('Null 'PGtext)
999infixl 8 .->>
999infixl 8 .->>
1000(.->>) = unsafeBinaryOp "->>"
1000(.->>) = unsafeBinaryOp "->>"
1002-- | Get JSON value at a specified path.
1002-- | Get JSON value at a specified path.
1004 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1004 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1005− => Expression db params grp from (nullity json)
1005+ => Expression commons schemas params grp from (nullity json)
1006− -> Expression db params grp from (nullity path)
1006+ -> Expression commons schemas params grp from (nullity path)
1007− -> Expression db params grp from ('Null json)
1007+ -> Expression commons schemas params grp from ('Null json)
1008infixl 8 .#>
1008infixl 8 .#>
1009(.#>) = unsafeBinaryOp "#>"
1009(.#>) = unsafeBinaryOp "#>"
1011-- | Get JSON value at a specified path as text.
1011-- | Get JSON value at a specified path as text.
1013 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1013 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1014− => Expression db params grp from (nullity json)
1014+ => Expression commons schemas params grp from (nullity json)
1015− -> Expression db params grp from (nullity path)
1015+ -> Expression commons schemas params grp from (nullity path)
1016− -> Expression db params grp from ('Null 'PGtext)
1016+ -> Expression commons schemas params grp from ('Null 'PGtext)
1017infixl 8 .#>>
1017infixl 8 .#>>
1018(.#>>) = unsafeBinaryOp "#>>"
1018(.#>>) = unsafeBinaryOp "#>>"
@@ -1022,48 +1022,48 @@ infixl 8 .#>>
1022-- | Does the left JSON value contain the right JSON path/value entries at the
1022-- | Does the left JSON value contain the right JSON path/value entries at the
1023-- top level?
1023-- top level?
1025− :: Expression db params grp from (nullity 'PGjsonb)
1025+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1026− -> Expression db params grp from (nullity 'PGjsonb)
1026+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1027− -> Condition db params grp from
1027+ -> Condition commons schemas params grp from
1028infixl 9 .@>
1028infixl 9 .@>
1029(.@>) = unsafeBinaryOp "@>"
1029(.@>) = unsafeBinaryOp "@>"
1031-- | Are the left JSON path/value entries contained at the top level within the
1031-- | Are the left JSON path/value entries contained at the top level within the
1032-- right JSON value?
1032-- right JSON value?
1034− :: Expression db params grp from (nullity 'PGjsonb)
1034+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1035− -> Expression db params grp from (nullity 'PGjsonb)
1035+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1036− -> Condition db params grp from
1036+ -> Condition commons schemas params grp from
1037infixl 9 .<@
1037infixl 9 .<@
1038(.<@) = unsafeBinaryOp "<@"
1038(.<@) = unsafeBinaryOp "<@"
1040-- | Does the string exist as a top-level key within the JSON value?
1040-- | Does the string exist as a top-level key within the JSON value?
1042− :: Expression db params grp from (nullity 'PGjsonb)
1042+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1043− -> Expression db params grp from (nullity 'PGtext)
1043+ -> Expression commons schemas params grp from (nullity 'PGtext)
1044− -> Condition db params grp from
1044+ -> Condition commons schemas params grp from
1045infixl 9 .?
1045infixl 9 .?
1046(.?) = unsafeBinaryOp "?"
1046(.?) = unsafeBinaryOp "?"
1048-- | Do any of these array strings exist as top-level keys?
1048-- | Do any of these array strings exist as top-level keys?
1050− :: Expression db params grp from (nullity 'PGjsonb)
1050+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1051− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1051+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1052− -> Condition db params grp from
1052+ -> Condition commons schemas params grp from
1053infixl 9 .?|
1053infixl 9 .?|
1054(.?|) = unsafeBinaryOp "?|"
1054(.?|) = unsafeBinaryOp "?|"
1056-- | Do all of these array strings exist as top-level keys?
1056-- | Do all of these array strings exist as top-level keys?
1058− :: Expression db params grp from (nullity 'PGjsonb)
1058+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1059− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1059+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1060− -> Condition db params grp from
1060+ -> Condition commons schemas params grp from
1061infixl 9 .?&
1061infixl 9 .?&
1062(.?&) = unsafeBinaryOp "?&"
1062(.?&) = unsafeBinaryOp "?&"
1064-- | Concatenate two jsonb values into a new jsonb value.
1064-- | Concatenate two jsonb values into a new jsonb value.
1066− Semigroup (Expression db from grouping param (nullity 'PGjsonb)) where
1066+ Semigroup (Expression commons schemas from grouping param (nullity 'PGjsonb)) where
1067 (<>) = unsafeBinaryOp "||"
1067 (<>) = unsafeBinaryOp "||"
1069-- | Delete a key or keys from a JSON object, or remove an array element.
1069-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1080,9 +1080,9 @@ instance
1080-- count from the end). Throws an error if top level container is not an array.
1080-- count from the end). Throws an error if top level container is not an array.
1082 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1082 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1083− => Expression db params grp from (nullity 'PGjsonb)
1083+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1084− -> Expression db params grp from (nullity key)
1084+ -> Expression commons schemas params grp from (nullity key)
1085− -> Expression db params grp from (nullity 'PGjsonb)
1085+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1086infixl 6 .-.
1086infixl 6 .-.
1087(.-.) = unsafeBinaryOp "-"
1087(.-.) = unsafeBinaryOp "-"
@@ -1090,9 +1090,9 @@ infixl 6 .-.
1090-- integers count from the end)
1090-- integers count from the end)
1092 :: PGTextArray "(#-.)" arrayty
1092 :: PGTextArray "(#-.)" arrayty
1093− => Expression db params grp from (nullity 'PGjsonb)
1093+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1094− -> Expression db params grp from (nullity arrayty)
1094+ -> Expression commons schemas params grp from (nullity arrayty)
1095− -> Expression db params grp from (nullity 'PGjsonb)
1095+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1096infixl 6 #-.
1096infixl 6 #-.
1097(#-.) = unsafeBinaryOp "#-"
1097(#-.) = unsafeBinaryOp "#-"
@@ -1103,14 +1103,14 @@ Table 9.45: JSON creation functions
1103-- | Literal binary JSON
1103-- | Literal binary JSON
1105 :: JSON.ToJSON x
1105 :: JSON.ToJSON x
1106− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjsonb)
1106+ => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
1107jsonbLit = cast jsonb . UnsafeExpression
1107jsonbLit = cast jsonb . UnsafeExpression
1108 . singleQuotedUtf8 . toStrict . JSON.encode
1108 . singleQuotedUtf8 . toStrict . JSON.encode
1110-- | Literal JSON
1110-- | Literal JSON
1112 :: JSON.ToJSON x
1112 :: JSON.ToJSON x
1113− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjson)
1113+ => x -> Expression commons schemas params grp from (nullity 'PGjson)
1114jsonLit = cast json . UnsafeExpression
1114jsonLit = cast json . UnsafeExpression
1115 . singleQuotedUtf8 . toStrict . JSON.encode
1115 . singleQuotedUtf8 . toStrict . JSON.encode
@@ -1121,8 +1121,8 @@ jsonLit = cast json . UnsafeExpression
1121-- number, a Boolean, or a null value, the text representation will be used, in
1121-- number, a Boolean, or a null value, the text representation will be used, in
1122-- such a fashion that it is a valid json value.
1122-- such a fashion that it is a valid json value.
1124− :: Expression db params grp from (nullity ty)
1124+ :: Expression commons schemas params grp from (nullity ty)
1125− -> Expression db params grp from (nullity 'PGjson)
1125+ -> Expression commons schemas params grp from (nullity 'PGjson)
1126toJson = unsafeFunction "to_json"
1126toJson = unsafeFunction "to_json"
1128-- | Returns the value as jsonb. Arrays and composites are converted
1128-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1132,43 +1132,43 @@ toJson = unsafeFunction "to_json"
1132-- number, a Boolean, or a null value, the text representation will be used, in
1132-- number, a Boolean, or a null value, the text representation will be used, in
1133-- such a fashion that it is a valid jsonb value.
1133-- such a fashion that it is a valid jsonb value.
1135− :: Expression db params grp from (nullity ty)
1135+ :: Expression commons schemas params grp from (nullity ty)
1136− -> Expression db params grp from (nullity 'PGjsonb)
1136+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1137toJsonb = unsafeFunction "to_jsonb"
1137toJsonb = unsafeFunction "to_jsonb"
1139-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1139-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1140-- becomes a JSON array of arrays.
1140-- becomes a JSON array of arrays.
1141arrayToJson
1141arrayToJson
1142 :: PGArray "arrayToJson" arr
1142 :: PGArray "arrayToJson" arr
1143− => Expression db params grp from (nullity arr)
1143+ => Expression commons schemas params grp from (nullity arr)
1144− -> Expression db params grp from (nullity 'PGjson)
1144+ -> Expression commons schemas params grp from (nullity 'PGjson)
1145arrayToJson = unsafeFunction "array_to_json"
1145arrayToJson = unsafeFunction "array_to_json"
1147-- | Returns the row as a JSON object.
1147-- | Returns the row as a JSON object.
1148rowToJson
1148rowToJson
1149− :: Expression db params grp from (nullity ('PGcomposite ty))
1149+ :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1150− -> Expression db params grp from (nullity 'PGjson)
1150+ -> Expression commons schemas params grp from (nullity 'PGjson)
1151rowToJson = unsafeFunction "row_to_json"
1151rowToJson = unsafeFunction "row_to_json"
1153-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1153-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1154-- argument list.
1154-- argument list.
1155jsonBuildArray
1155jsonBuildArray
1156 :: SListI elems
1156 :: SListI elems
1157− => NP (Expression db params grp from) elems
1157+ => NP (Expression commons schemas params grp from) elems
1158− -> Expression db params grp from (nullity 'PGjson)
1158+ -> Expression commons schemas params grp from (nullity 'PGjson)
1159jsonBuildArray = unsafeVariadicFunction "json_build_array"
1159jsonBuildArray = unsafeVariadicFunction "json_build_array"
1161-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1161-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1162-- variadic argument list.
1162-- variadic argument list.
1163jsonbBuildArray
1163jsonbBuildArray
1164 :: SListI elems
1164 :: SListI elems
1165− => NP (Expression db params grp from) elems
1165+ => NP (Expression commons schemas params grp from) elems
1166− -> Expression db params grp from (nullity 'PGjsonb)
1166+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1167jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1167jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1169unsafeRowFunction
1169unsafeRowFunction
1170 :: All Top elems
1170 :: All Top elems
1171− => NP (Aliased (Expression db params grp from)) elems
1171+ => NP (Aliased (Expression commons schemas params grp from)) elems
1172 -> [ByteString]
1172 -> [ByteString]
1173unsafeRowFunction =
1173unsafeRowFunction =
1174 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1174 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1183,8 +1183,8 @@ unsafeRowFunction =
1183-- and values.
1183-- and values.
1184jsonBuildObject
1184jsonBuildObject
1185 :: All Top elems
1185 :: All Top elems
1186− => NP (Aliased (Expression db params grp from)) elems
1186+ => NP (Aliased (Expression commons schemas params grp from)) elems
1187− -> Expression db params grp from (nullity 'PGjson)
1187+ -> Expression commons schemas params grp from (nullity 'PGjson)
1188jsonBuildObject
1188jsonBuildObject
1189 = unsafeFunction "json_build_object"
1189 = unsafeFunction "json_build_object"
1190 . UnsafeExpression
1190 . UnsafeExpression
@@ -1196,8 +1196,8 @@ jsonBuildObject
1196-- between text and values.
1196-- between text and values.
1197jsonbBuildObject
1197jsonbBuildObject
1198 :: All Top elems
1198 :: All Top elems
1199− => NP (Aliased (Expression db params grp from)) elems
1199+ => NP (Aliased (Expression commons schemas params grp from)) elems
1200− -> Expression db params grp from (nullity 'PGjsonb)
1200+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1201jsonbBuildObject
1201jsonbBuildObject
1202 = unsafeFunction "jsonb_build_object"
1202 = unsafeFunction "jsonb_build_object"
1203 . UnsafeExpression
1203 . UnsafeExpression
@@ -1210,8 +1210,8 @@ jsonbBuildObject
1210-- array has exactly two elements, which are taken as a key/value pair.
1210-- array has exactly two elements, which are taken as a key/value pair.
1211jsonObject
1211jsonObject
1212 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1212 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1213− => Expression db params grp from (nullity arr)
1213+ => Expression commons schemas params grp from (nullity arr)
1214− -> Expression db params grp from (nullity 'PGjson)
1214+ -> Expression commons schemas params grp from (nullity 'PGjson)
1215jsonObject = unsafeFunction "json_object"
1215jsonObject = unsafeFunction "json_object"
1217-- | Builds a binary JSON object out of a text array. The array must have either
1217-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1220,8 +1220,8 @@ jsonObject = unsafeFunction "json_object"
1220-- array has exactly two elements, which are taken as a key/value pair.
1220-- array has exactly two elements, which are taken as a key/value pair.
1221jsonbObject
1221jsonbObject
1222 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1222 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1223− => Expression db params grp from (nullity arr)
1223+ => Expression commons schemas params grp from (nullity arr)
1224− -> Expression db params grp from (nullity 'PGjsonb)
1224+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1225jsonbObject = unsafeFunction "jsonb_object"
1225jsonbObject = unsafeFunction "jsonb_object"
1227-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1227-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1229,9 +1229,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1229jsonZipObject
1229jsonZipObject
1230 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1230 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1231 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1231 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1232− => Expression db params grp from (nullity keysArray)
1232+ => Expression commons schemas params grp from (nullity keysArray)
1233− -> Expression db params grp from (nullity valuesArray)
1233+ -> Expression commons schemas params grp from (nullity valuesArray)
1234− -> Expression db params grp from (nullity 'PGjson)
1234+ -> Expression commons schemas params grp from (nullity 'PGjson)
1235jsonZipObject ks vs =
1235jsonZipObject ks vs =
1236 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1236 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
@@ -1241,9 +1241,9 @@ jsonZipObject ks vs =
1241jsonbZipObject
1241jsonbZipObject
1242 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1242 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1243 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1243 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1244− => Expression db params grp from (nullity keysArray)
1244+ => Expression commons schemas params grp from (nullity keysArray)
1245− -> Expression db params grp from (nullity valuesArray)
1245+ -> Expression commons schemas params grp from (nullity valuesArray)
1246− -> Expression db params grp from (nullity 'PGjsonb)
1246+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1247jsonbZipObject ks vs =
1247jsonbZipObject ks vs =
1248 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1248 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
@@ -1253,23 +1253,23 @@ Table 9.46: JSON processing functions
1254-- | Returns the number of elements in the outermost JSON array.
1254-- | Returns the number of elements in the outermost JSON array.
1255jsonArrayLength
1255jsonArrayLength
1256− :: Expression db params grp from (nullity 'PGjson)
1256+ :: Expression commons schemas params grp from (nullity 'PGjson)
1257− -> Expression db params grp from (nullity 'PGint4)
1257+ -> Expression commons schemas params grp from (nullity 'PGint4)
1258jsonArrayLength = unsafeFunction "json_array_length"
1258jsonArrayLength = unsafeFunction "json_array_length"
1260-- | Returns the number of elements in the outermost binary JSON array.
1260-- | Returns the number of elements in the outermost binary JSON array.
1261jsonbArrayLength
1261jsonbArrayLength
1262− :: Expression db params grp from (nullity 'PGjsonb)
1262+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1263− -> Expression db params grp from (nullity 'PGint4)
1263+ -> Expression commons schemas params grp from (nullity 'PGint4)
1264jsonbArrayLength = unsafeFunction "jsonb_array_length"
1264jsonbArrayLength = unsafeFunction "jsonb_array_length"
1266-- | Returns JSON value pointed to by the given path (equivalent to #>
1266-- | Returns JSON value pointed to by the given path (equivalent to #>
1267-- operator).
1267-- operator).
1268jsonExtractPath
1268jsonExtractPath
1269 :: SListI elems
1269 :: SListI elems
1270− => Expression db params grp from (nullity 'PGjson)
1270+ => Expression commons schemas params grp from (nullity 'PGjson)
1271− -> NP (Expression db params grp from) elems
1271+ -> NP (Expression commons schemas params grp from) elems
1272− -> Expression db params grp from (nullity 'PGjsonb)
1272+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1273jsonExtractPath x xs =
1273jsonExtractPath x xs =
1274 unsafeVariadicFunction "json_extract_path" (x :* xs)
1274 unsafeVariadicFunction "json_extract_path" (x :* xs)
@@ -1277,9 +1277,9 @@ jsonExtractPath x xs =
1277-- operator).
1277-- operator).
1278jsonbExtractPath
1278jsonbExtractPath
1279 :: SListI elems
1279 :: SListI elems
1280− => Expression db params grp from (nullity 'PGjsonb)
1280+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1281− -> NP (Expression db params grp from) elems
1281+ -> NP (Expression commons schemas params grp from) elems
1282− -> Expression db params grp from (nullity 'PGjsonb)
1282+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1283jsonbExtractPath x xs =
1283jsonbExtractPath x xs =
1284 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1284 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
@@ -1287,9 +1287,9 @@ jsonbExtractPath x xs =
1287-- operator), as text.
1287-- operator), as text.
1288jsonExtractPathAsText
1288jsonExtractPathAsText
1289 :: SListI elems
1289 :: SListI elems
1290− => Expression db params grp from (nullity 'PGjson)
1290+ => Expression commons schemas params grp from (nullity 'PGjson)
1291− -> NP (Expression db params grp from) elems
1291+ -> NP (Expression commons schemas params grp from) elems
1292− -> Expression db params grp from (nullity 'PGjson)
1292+ -> Expression commons schemas params grp from (nullity 'PGjson)
1293jsonExtractPathAsText x xs =
1293jsonExtractPathAsText x xs =
1294 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1294 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
@@ -1297,38 +1297,38 @@ jsonExtractPathAsText x xs =
1297-- operator), as text.
1297-- operator), as text.
1298jsonbExtractPathAsText
1298jsonbExtractPathAsText
1299 :: SListI elems
1299 :: SListI elems
1300− => Expression db params grp from (nullity 'PGjsonb)
1300+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1301− -> NP (Expression db params grp from) elems
1301+ -> NP (Expression commons schemas params grp from) elems
1302− -> Expression db params grp from (nullity 'PGjsonb)
1302+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1303jsonbExtractPathAsText x xs =
1303jsonbExtractPathAsText x xs =
1304 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1304 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1306-- | Returns the type of the outermost JSON value as a text string. Possible
1306-- | Returns the type of the outermost JSON value as a text string. Possible
1307-- types are object, array, string, number, boolean, and null.
1307-- types are object, array, string, number, boolean, and null.
1308jsonTypeof
1308jsonTypeof
1309− :: Expression db params grp from (nullity 'PGjson)
1309+ :: Expression commons schemas params grp from (nullity 'PGjson)
1310− -> Expression db params grp from (nullity 'PGtext)
1310+ -> Expression commons schemas params grp from (nullity 'PGtext)
1311jsonTypeof = unsafeFunction "json_typeof"
1311jsonTypeof = unsafeFunction "json_typeof"
1313-- | Returns the type of the outermost binary JSON value as a text string.
1313-- | Returns the type of the outermost binary JSON value as a text string.
1314-- Possible types are object, array, string, number, boolean, and null.
1314-- Possible types are object, array, string, number, boolean, and null.
1315jsonbTypeof
1315jsonbTypeof
1316− :: Expression db params grp from (nullity 'PGjsonb)
1316+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1317− -> Expression db params grp from (nullity 'PGtext)
1317+ -> Expression commons schemas params grp from (nullity 'PGtext)
1318jsonbTypeof = unsafeFunction "jsonb_typeof"
1318jsonbTypeof = unsafeFunction "jsonb_typeof"
1320-- | Returns its argument with all object fields that have null values omitted.
1320-- | Returns its argument with all object fields that have null values omitted.
1321-- Other null values are untouched.
1321-- Other null values are untouched.
1322jsonStripNulls
1322jsonStripNulls
1323− :: Expression db params grp from (nullity 'PGjson)
1323+ :: Expression commons schemas params grp from (nullity 'PGjson)
1324− -> Expression db params grp from (nullity 'PGjson)
1324+ -> Expression commons schemas params grp from (nullity 'PGjson)
1325jsonStripNulls = unsafeFunction "json_strip_nulls"
1325jsonStripNulls = unsafeFunction "json_strip_nulls"
1327-- | Returns its argument with all object fields that have null values omitted.
1327-- | Returns its argument with all object fields that have null values omitted.
1328-- Other null values are untouched.
1328-- Other null values are untouched.
1329jsonbStripNulls
1329jsonbStripNulls
1330− :: Expression db params grp from (nullity 'PGjsonb)
1330+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1331− -> Expression db params grp from (nullity 'PGjsonb)
1331+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1332jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1332jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1334-- | @ jsonbSet target path new_value create_missing @
1334-- | @ jsonbSet target path new_value create_missing @
@@ -1340,11 +1340,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1340-- arrays.
1340-- arrays.
1342 :: PGTextArray "jsonbSet" arr
1342 :: PGTextArray "jsonbSet" arr
1343− => Expression db params grp from (nullity 'PGjsonb)
1343+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1344− -> Expression db params grp from (nullity arr)
1344+ -> Expression commons schemas params grp from (nullity arr)
1345− -> Expression db params grp from (nullity 'PGjsonb)
1345+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1346− -> Maybe (Expression db params grp from (nullity 'PGbool))
1346+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1347− -> Expression db params grp from (nullity 'PGjsonb)
1347+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1348jsonbSet tgt path val createMissing = case createMissing of
1348jsonbSet tgt path val createMissing = case createMissing of
1349 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1349 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1350 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1350 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1359,19 +1359,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1359-- in path count from the end of JSON arrays.
1359-- in path count from the end of JSON arrays.
1360jsonbInsert
1360jsonbInsert
1361 :: PGTextArray "jsonbInsert" arr
1361 :: PGTextArray "jsonbInsert" arr
1362− => Expression db params grp from (nullity 'PGjsonb)
1362+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1363− -> Expression db params grp from (nullity arr)
1363+ -> Expression commons schemas params grp from (nullity arr)
1364− -> Expression db params grp from (nullity 'PGjsonb)
1364+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1365− -> Maybe (Expression db params grp from (nullity 'PGbool))
1365+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1366− -> Expression db params grp from (nullity 'PGjsonb)
1366+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1367jsonbInsert tgt path val insertAfter = case insertAfter of
1367jsonbInsert tgt path val insertAfter = case insertAfter of
1368 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1368 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1369 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1369 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1371-- | Returns its argument as indented JSON text.
1371-- | Returns its argument as indented JSON text.
1372jsonbPretty
1372jsonbPretty
1373− :: Expression db params grp from (nullity 'PGjsonb)
1373+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1374− -> Expression db params grp from (nullity 'PGtext)
1374+ -> Expression commons schemas params grp from (nullity 'PGtext)
1375jsonbPretty = unsafeFunction "jsonb_pretty"
1375jsonbPretty = unsafeFunction "jsonb_pretty"
1377{-----------------------------------------
1377{-----------------------------------------
@@ -1381,54 +1381,54 @@ aggregation
1381-- | escape hatch to define aggregate functions
1381-- | escape hatch to define aggregate functions
1382unsafeAggregate
1382unsafeAggregate
1383 :: ByteString -- ^ aggregate function
1383 :: ByteString -- ^ aggregate function
1384− -> Expression db from 'Ungrouped params (xty)
1384+ -> Expression commons schemas from 'Ungrouped params (xty)
1385− -> Expression db from ('Grouped bys) params (yty)
1385+ -> Expression commons schemas from ('Grouped bys) params (yty)
1386unsafeAggregate fun x = UnsafeExpression $ mconcat
1386unsafeAggregate fun x = UnsafeExpression $ mconcat
1387 [fun, "(", renderSQL x, ")"]
1387 [fun, "(", renderSQL x, ")"]
1389-- | escape hatch to define aggregate functions over distinct values
1389-- | escape hatch to define aggregate functions over distinct values
1390unsafeAggregateDistinct
1390unsafeAggregateDistinct
1391 :: ByteString -- ^ aggregate function
1391 :: ByteString -- ^ aggregate function
1392− -> Expression db from 'Ungrouped params (xty)
1392+ -> Expression commons schemas from 'Ungrouped params (xty)
1393− -> Expression db from ('Grouped bys) params (yty)
1393+ -> Expression commons schemas from ('Grouped bys) params (yty)
1394unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1394unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1395 [fun, "(DISTINCT ", renderSQL x, ")"]
1395 [fun, "(DISTINCT ", renderSQL x, ")"]
1397-- | >>> :{
1397-- | >>> :{
1399−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1399+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1400-- expression = sum_ #col
1400-- expression = sum_ #col
1401-- in printSQL expression
1401-- in printSQL expression
1403-- sum("col")
1403-- sum("col")
1405 :: ty `In` PGNum
1405 :: ty `In` PGNum
1406− => Expression db from 'Ungrouped params (nullity ty)
1406+ => Expression commons schemas from 'Ungrouped params (nullity ty)
1407 -- ^ what to sum
1407 -- ^ what to sum
1408− -> Expression db from ('Grouped bys) params (nullity ty)
1408+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1409sum_ = unsafeAggregate "sum"
1409sum_ = unsafeAggregate "sum"
1411-- | >>> :{
1411-- | >>> :{
1413−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1413+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1414-- expression = sumDistinct #col
1414-- expression = sumDistinct #col
1415-- in printSQL expression
1415-- in printSQL expression
1417-- sum(DISTINCT "col")
1417-- sum(DISTINCT "col")
1418sumDistinct
1418sumDistinct
1419 :: ty `In` PGNum
1419 :: ty `In` PGNum
1420− => Expression db from 'Ungrouped params (nullity ty)
1420+ => Expression commons schemas from 'Ungrouped params (nullity ty)
1421 -- ^ what to sum
1421 -- ^ what to sum
1422− -> Expression db from ('Grouped bys) params (nullity ty)
1422+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1423sumDistinct = unsafeAggregateDistinct "sum"
1423sumDistinct = unsafeAggregateDistinct "sum"
1425-- | A constraint for `PGType`s that you can take averages of and the resulting
1425-- | A constraint for `PGType`s that you can take averages of and the resulting
1426-- `PGType`.
1426-- `PGType`.
1427class PGAvg ty avg | ty -> avg where
1427class PGAvg ty avg | ty -> avg where
1428 avg, avgDistinct
1428 avg, avgDistinct
1429− :: Expression db from 'Ungrouped params (nullity ty)
1429+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
1430 -- ^ what to average
1430 -- ^ what to average
1431− -> Expression db from ('Grouped bys) params (nullity avg)
1431+ -> Expression commons schemas from ('Grouped bys) params (nullity avg)
1432 avg = unsafeAggregate "avg"
1432 avg = unsafeAggregate "avg"
1433 avgDistinct = unsafeAggregateDistinct "avg"
1433 avgDistinct = unsafeAggregateDistinct "avg"
1434instance PGAvg 'PGint2 'PGnumeric
1434instance PGAvg 'PGint2 'PGnumeric
@@ -1441,110 +1441,110 @@ instance PGAvg 'PGinterval 'PGinterval
1442-- | >>> :{
1442-- | >>> :{
1444−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1444+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1445-- expression = bitAnd #col
1445-- expression = bitAnd #col
1446-- in printSQL expression
1446-- in printSQL expression
1448-- bit_and("col")
1448-- bit_and("col")
1450 :: int `In` PGIntegral
1450 :: int `In` PGIntegral
1451− => Expression db from 'Ungrouped params (nullity int)
1451+ => Expression commons schemas from 'Ungrouped params (nullity int)
1452 -- ^ what to aggregate
1452 -- ^ what to aggregate
1453− -> Expression db from ('Grouped bys) params (nullity int)
1453+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1454bitAnd = unsafeAggregate "bit_and"
1454bitAnd = unsafeAggregate "bit_and"
1456-- | >>> :{
1456-- | >>> :{
1458−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1458+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1459-- expression = bitOr #col
1459-- expression = bitOr #col
1460-- in printSQL expression
1460-- in printSQL expression
1462-- bit_or("col")
1462-- bit_or("col")
1464 :: int `In` PGIntegral
1464 :: int `In` PGIntegral
1465− => Expression db from 'Ungrouped params (nullity int)
1465+ => Expression commons schemas from 'Ungrouped params (nullity int)
1466 -- ^ what to aggregate
1466 -- ^ what to aggregate
1467− -> Expression db from ('Grouped bys) params (nullity int)
1467+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1468bitOr = unsafeAggregate "bit_or"
1468bitOr = unsafeAggregate "bit_or"
1470-- | >>> :{
1470-- | >>> :{
1472−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1472+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1473-- expression = bitAndDistinct #col
1473-- expression = bitAndDistinct #col
1474-- in printSQL expression
1474-- in printSQL expression
1476-- bit_and(DISTINCT "col")
1476-- bit_and(DISTINCT "col")
1477bitAndDistinct
1477bitAndDistinct
1478 :: int `In` PGIntegral
1478 :: int `In` PGIntegral
1479− => Expression db from 'Ungrouped params (nullity int)
1479+ => Expression commons schemas from 'Ungrouped params (nullity int)
1480 -- ^ what to aggregate
1480 -- ^ what to aggregate
1481− -> Expression db from ('Grouped bys) params (nullity int)
1481+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1482bitAndDistinct = unsafeAggregateDistinct "bit_and"
1482bitAndDistinct = unsafeAggregateDistinct "bit_and"
1484-- | >>> :{
1484-- | >>> :{
1486−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1486+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1487-- expression = bitOrDistinct #col
1487-- expression = bitOrDistinct #col
1488-- in printSQL expression
1488-- in printSQL expression
1490-- bit_or(DISTINCT "col")
1490-- bit_or(DISTINCT "col")
1491bitOrDistinct
1491bitOrDistinct
1492 :: int `In` PGIntegral
1492 :: int `In` PGIntegral
1493− => Expression db from 'Ungrouped params (nullity int)
1493+ => Expression commons schemas from 'Ungrouped params (nullity int)
1494 -- ^ what to aggregate
1494 -- ^ what to aggregate
1495− -> Expression db from ('Grouped bys) params (nullity int)
1495+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1496bitOrDistinct = unsafeAggregateDistinct "bit_or"
1496bitOrDistinct = unsafeAggregateDistinct "bit_or"
1498-- | >>> :{
1498-- | >>> :{
1500−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1500+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1501-- expression = boolAnd #col
1501-- expression = boolAnd #col
1502-- in printSQL expression
1502-- in printSQL expression
1504-- bool_and("col")
1504-- bool_and("col")
1506− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1506+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1507 -- ^ what to aggregate
1507 -- ^ what to aggregate
1508− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1508+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1509boolAnd = unsafeAggregate "bool_and"
1509boolAnd = unsafeAggregate "bool_and"
1511-- | >>> :{
1511-- | >>> :{
1513−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1513+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1514-- expression = boolOr #col
1514-- expression = boolOr #col
1515-- in printSQL expression
1515-- in printSQL expression
1517-- bool_or("col")
1517-- bool_or("col")
1519− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1519+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1520 -- ^ what to aggregate
1520 -- ^ what to aggregate
1521− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1521+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1522boolOr = unsafeAggregate "bool_or"
1522boolOr = unsafeAggregate "bool_or"
1524-- | >>> :{
1524-- | >>> :{
1526−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1526+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1527-- expression = boolAndDistinct #col
1527-- expression = boolAndDistinct #col
1528-- in printSQL expression
1528-- in printSQL expression
1530-- bool_and(DISTINCT "col")
1530-- bool_and(DISTINCT "col")
1531boolAndDistinct
1531boolAndDistinct
1532− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1532+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1533 -- ^ what to aggregate
1533 -- ^ what to aggregate
1534− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1534+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1535boolAndDistinct = unsafeAggregateDistinct "bool_and"
1535boolAndDistinct = unsafeAggregateDistinct "bool_and"
1537-- | >>> :{
1537-- | >>> :{
1539−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1539+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1540-- expression = boolOrDistinct #col
1540-- expression = boolOrDistinct #col
1541-- in printSQL expression
1541-- in printSQL expression
1543-- bool_or(DISTINCT "col")
1543-- bool_or(DISTINCT "col")
1544boolOrDistinct
1544boolOrDistinct
1545− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1545+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1546 -- ^ what to aggregate
1546 -- ^ what to aggregate
1547− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1547+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1548boolOrDistinct = unsafeAggregateDistinct "bool_or"
1548boolOrDistinct = unsafeAggregateDistinct "bool_or"
1550-- | A special aggregation that does not require an input
1550-- | A special aggregation that does not require an input
@@ -1552,70 +1552,70 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1552-- >>> printSQL countStar
1552-- >>> printSQL countStar
1553-- count(*)
1553-- count(*)
1554countStar
1554countStar
1555− :: Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1555+ :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1556countStar = UnsafeExpression $ "count(*)"
1556countStar = UnsafeExpression $ "count(*)"
1558-- | >>> :{
1558-- | >>> :{
1560−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1560+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1561-- expression = count #col
1561-- expression = count #col
1562-- in printSQL expression
1562-- in printSQL expression
1564-- count("col")
1564-- count("col")
1566− :: Expression db from 'Ungrouped params ty
1566+ :: Expression commons schemas from 'Ungrouped params ty
1567 -- ^ what to count
1567 -- ^ what to count
1568− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1568+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1569count = unsafeAggregate "count"
1569count = unsafeAggregate "count"
1571-- | >>> :{
1571-- | >>> :{
1573−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1573+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1574-- expression = countDistinct #col
1574-- expression = countDistinct #col
1575-- in printSQL expression
1575-- in printSQL expression
1577-- count(DISTINCT "col")
1577-- count(DISTINCT "col")
1578countDistinct
1578countDistinct
1579− :: Expression db from 'Ungrouped params ty
1579+ :: Expression commons schemas from 'Ungrouped params ty
1580 -- ^ what to count
1580 -- ^ what to count
1581− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1581+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1582countDistinct = unsafeAggregateDistinct "count"
1582countDistinct = unsafeAggregateDistinct "count"
1584-- | synonym for `boolAnd`
1584-- | synonym for `boolAnd`
1586-- >>> :{
1586-- >>> :{
1588−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1588+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1589-- expression = every #col
1589-- expression = every #col
1590-- in printSQL expression
1590-- in printSQL expression
1592-- every("col")
1592-- every("col")
1594− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1594+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1595 -- ^ what to aggregate
1595 -- ^ what to aggregate
1596− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1596+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1597every = unsafeAggregate "every"
1597every = unsafeAggregate "every"
1599-- | synonym for `boolAndDistinct`
1599-- | synonym for `boolAndDistinct`
1601-- >>> :{
1601-- >>> :{
1603−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1603+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1604-- expression = everyDistinct #col
1604-- expression = everyDistinct #col
1605-- in printSQL expression
1605-- in printSQL expression
1607-- every(DISTINCT "col")
1607-- every(DISTINCT "col")
1608everyDistinct
1608everyDistinct
1609− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1609+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1610 -- ^ what to aggregate
1610 -- ^ what to aggregate
1611− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1611+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1612everyDistinct = unsafeAggregateDistinct "every"
1612everyDistinct = unsafeAggregateDistinct "every"
1614-- | minimum and maximum aggregation
1614-- | minimum and maximum aggregation
1615max_, min_, maxDistinct, minDistinct
1615max_, min_, maxDistinct, minDistinct
1616− :: Expression db from 'Ungrouped params (nullity ty)
1616+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
1617 -- ^ what to aggregate
1617 -- ^ what to aggregate
1618− -> Expression db from ('Grouped bys) params (nullity ty)
1618+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1619max_ = unsafeAggregate "max"
1619max_ = unsafeAggregate "max"
1620min_ = unsafeAggregate "min"
1620min_ = unsafeAggregate "min"
1621maxDistinct = unsafeAggregateDistinct "max"
1621maxDistinct = unsafeAggregateDistinct "max"