@@ -218,7 +218,8 @@ values from primitive expression using arithmetic, logical,
218218and other operations.
219219-}
220220newtype Expression
221− (db :: DBType)
221+ (commons :: FromType)
222+ (schemas :: SchemasType)
222223 (params :: [NullityType])
223224 (grp :: Grouping)
224225 (from :: FromType)
@@ -226,7 +227,7 @@ newtype Expression
226227 = UnsafeExpression { renderExpression :: ByteString }
227228 deriving (GHC.Generic,Show,Eq,Ord,NFData)
228229
229−instance RenderSQL (Expression db params grp from ty) where
230+instance RenderSQL (Expression commons schemas params grp from ty) where
230231 renderSQL = renderExpression
231232
232233{- | A `HasParameter` constraint is used to indicate a value that is
@@ -244,12 +245,12 @@ class KnownNat n => HasParameter
244245 | n params -> ty where
245246 -- | `parameter` takes a `Nat` using type application and a `TypeExpression`.
246247 --
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)
248249 -- >>> printSQL expr
249250 -- ($1 :: int4)
250251 parameter
251252 :: TypeExpression schemas ty
252− -> Expression (commons :=> schemas) params grp from ty
253+ -> Expression commons schemas params grp from ty
253254 parameter ty = UnsafeExpression $ parenthesized $
254255 "$" <> renderNat @n <+> "::"
255256 <+> renderSQL ty
@@ -260,38 +261,38 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
260261-- | `param` takes a `Nat` using type application and for basic types,
261262-- infers a `TypeExpression`.
262263--
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)
264265-- >>> printSQL expr
265266-- ($1 :: int4)
266267param
267− :: forall n db commons schemas params from grp ty
268− . (db ~ (commons :=> schemas), PGTyped schemas ty, HasParameter n params ty)
269− => Expression db params grp from ty -- ^ param
268+ :: forall n commons schemas params from grp ty
269+ . (PGTyped schemas ty, HasParameter n params ty)
270+ => Expression commons schemas params grp from ty -- ^ param
270271param = parameter @n (pgtype @schemas)
271272
272273instance (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
274275 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
275276instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
276277 => IsLabel col
277− (Aliased (Expression db params 'Ungrouped from) column) where
278+ (Aliased (Expression commons schemas params 'Ungrouped from) column) where
278279 fromLabel = fromLabel @col `As` Alias
279280instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
280281 => IsLabel col
281− (NP (Aliased (Expression db params 'Ungrouped from)) columns) where
282+ (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
282283 fromLabel = fromLabel @col :* Nil
283284
284285instance (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
286287 tab ! col = UnsafeExpression $
287288 renderSQL tab <> "." <> renderSQL col
288289instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
289290 => IsQualified tab col
290− (Aliased (Expression db params 'Ungrouped from) column) where
291+ (Aliased (Expression commons schemas params 'Ungrouped from) column) where
291292 tab ! col = tab ! col `As` col
292293instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
293294 => IsQualified tab col
294− (NP (Aliased (Expression db params 'Ungrouped from)) columns) where
295+ (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
295296 tab ! col = tab ! col :* Nil
296297
297298instance
@@ -299,7 +300,7 @@ instance
299300 , Has col row ty
300301 , GroupedBy tab col bys
301302 ) => IsLabel col
302− (Expression db params ('Grouped bys) from ty) where
303+ (Expression commons schemas params ('Grouped bys) from ty) where
303304 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
304305instance
305306 ( HasUnique tab from row
@@ -307,7 +308,7 @@ instance
307308 , GroupedBy tab col bys
308309 , column ~ (col ::: ty)
309310 ) => IsLabel col
310− (Aliased (Expression db params ('Grouped bys) from) column) where
311+ (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
311312 fromLabel = fromLabel @col `As` Alias
312313instance
313314 ( HasUnique tab from row
@@ -315,7 +316,7 @@ instance
315316 , GroupedBy tab col bys
316317 , columns ~ '[col ::: ty]
317318 ) => 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
319320 fromLabel = fromLabel @col :* Nil
320321
321322instance
@@ -323,7 +324,7 @@ instance
323324 , Has col row ty
324325 , GroupedBy tab col bys
325326 ) => IsQualified tab col
326− (Expression db params ('Grouped bys) from ty) where
327+ (Expression commons schemas params ('Grouped bys) from ty) where
327328 tab ! col = UnsafeExpression $
328329 renderSQL tab <> "." <> renderSQL col
329330instance
@@ -332,7 +333,7 @@ instance
332333 , GroupedBy tab col bys
333334 , column ~ (col ::: ty)
334335 ) => IsQualified tab col
335− (Aliased (Expression db params ('Grouped bys) from) column) where
336+ (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
336337 tab ! col = tab ! col `As` col
337338instance
338339 ( Has tab from row
@@ -340,14 +341,14 @@ instance
340341 , GroupedBy tab col bys
341342 , columns ~ '[col ::: ty]
342343 ) => 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
344345 tab ! col = tab ! col :* Nil
345346
346347-- | analagous to `Nothing`
347348--
348349-- >>> printSQL null_
349350-- NULL
350−null_ :: Expression db rels grouping params ('Null ty)
351+null_ :: Expression commons schemas rels grouping params ('Null ty)
351352null_ = UnsafeExpression "NULL"
352353
353354-- | analagous to `Just`
@@ -355,8 +356,8 @@ null_ = UnsafeExpression "NULL"
355356-- >>> printSQL $ notNull true
356357-- TRUE
357358notNull
358− :: Expression db rels grouping params ('NotNull ty)
359− -> Expression db rels grouping params ('Null ty)
359+ :: Expression commons schemas rels grouping params ('NotNull ty)
360+ -> Expression commons schemas rels grouping params ('Null ty)
360361notNull = UnsafeExpression . renderSQL
361362
362363-- | return the leftmost value which is not NULL
@@ -364,11 +365,11 @@ notNull = UnsafeExpression . renderSQL
364365-- >>> printSQL $ coalesce [null_, true] false
365366-- COALESCE(NULL, TRUE, FALSE)
366367coalesce
367− :: [Expression db params grp from ('Null ty)]
368+ :: [Expression commons schemas params grp from ('Null ty)]
368369 -- ^ @NULL@s may be present
369− -> Expression db params grp from ('NotNull ty)
370+ -> Expression commons schemas params grp from ('NotNull ty)
370371 -- ^ @NULL@ is absent
371− -> Expression db params grp from ('NotNull ty)
372+ -> Expression commons schemas params grp from ('NotNull ty)
372373coalesce nullxs notNullx = UnsafeExpression $
373374 "COALESCE" <> parenthesized (commaSeparated
374375 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
@@ -378,26 +379,26 @@ coalesce nullxs notNullx = UnsafeExpression $
378379-- >>> printSQL $ fromNull true null_
379380-- COALESCE(NULL, TRUE)
380381fromNull
381− :: Expression db params grp from ('NotNull ty)
382+ :: Expression commons schemas params grp from ('NotNull ty)
382383 -- ^ what to convert @NULL@ to
383− -> Expression db params grp from ('Null ty)
384− -> Expression db params grp from ('NotNull ty)
384+ -> Expression commons schemas params grp from ('Null ty)
385+ -> Expression commons schemas params grp from ('NotNull ty)
385386fromNull notNullx nullx = coalesce [nullx] notNullx
386387
387388-- | >>> printSQL $ null_ & isNull
388389-- NULL IS NULL
389390isNull
390− :: Expression db params grp from ('Null ty)
391+ :: Expression commons schemas params grp from ('Null ty)
391392 -- ^ possibly @NULL@
392− -> Condition db params grp from
393+ -> Condition commons schemas params grp from
393394isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
394395
395396-- | >>> printSQL $ null_ & isNotNull
396397-- NULL IS NOT NULL
397398isNotNull
398− :: Expression db params grp from ('Null ty)
399+ :: Expression commons schemas params grp from ('Null ty)
399400 -- ^ possibly @NULL@
400− -> Condition db params grp from
401+ -> Condition commons schemas params grp from
401402isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
402403
403404-- | analagous to `maybe` using @IS NULL@
@@ -405,13 +406,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
405406-- >>> printSQL $ matchNull true not_ null_
406407-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
407408matchNull
408− :: Expression db params grp from (nullty)
409+ :: Expression commons schemas params grp from (nullty)
409410 -- ^ what to convert @NULL@ to
410− -> ( Expression db params grp from ('NotNull ty)
411− -> Expression db params grp from (nullty) )
411+ -> ( Expression commons schemas params grp from ('NotNull ty)
412+ -> Expression commons schemas params grp from (nullty) )
412413 -- ^ function to perform when @NULL@ is absent
413− -> Expression db params grp from ('Null ty)
414− -> Expression db params grp from (nullty)
414+ -> Expression commons schemas params grp from ('Null ty)
415+ -> Expression commons schemas params grp from (nullty)
415416matchNull y f x = ifThenElse (isNull x) y
416417 (f (UnsafeExpression (renderSQL x)))
417418
@@ -419,25 +420,25 @@ matchNull y f x = ifThenElse (isNull x) y
419420`nullIf` gives @NULL@.
420421
421422>>> :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)
423424>>> printSQL expr
424425NULL IF (FALSE, ($1 :: bool))
425426-}
426427nullIf
427− :: Expression db params grp from ('NotNull ty)
428+ :: Expression commons schemas params grp from ('NotNull ty)
428429 -- ^ @NULL@ is absent
429− -> Expression db params grp from ('NotNull ty)
430+ -> Expression commons schemas params grp from ('NotNull ty)
430431 -- ^ @NULL@ is absent
431− -> Expression db params grp from ('Null ty)
432+ -> Expression commons schemas params grp from ('Null ty)
432433nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433434 (renderSQL x <> ", " <> renderSQL y)
434435
435436-- | >>> printSQL $ array [null_, false, true]
436437-- ARRAY[NULL, FALSE, TRUE]
437438array
438− :: [Expression db params grp from ty]
439+ :: [Expression commons schemas params grp from ty]
439440 -- ^ array elements
440− -> Expression db params grp from (nullity ('PGvararray ty))
441+ -> Expression commons schemas params grp from (nullity ('PGvararray ty))
441442array xs = UnsafeExpression $
442443 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
443444
@@ -445,13 +446,13 @@ array xs = UnsafeExpression $
445446-- (ARRAY[NULL, FALSE, TRUE])[2]
446447index
447448 :: Word64 -- ^ index
448− -> Expression db params grp from (nullity ('PGvararray ty)) -- ^ array
449− -> Expression db params grp from (NullifyType ty)
449+ -> Expression commons schemas params grp from (nullity ('PGvararray ty)) -- ^ array
450+ -> Expression commons schemas params grp from (NullifyType ty)
450451index n expr = UnsafeExpression $
451452 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
452453
453454instance (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
455456 label = UnsafeExpression $ renderSQL (PGlabel @label)
456457
457458-- | A row constructor is an expression that builds a row value
@@ -463,14 +464,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
463464-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
464465-- :}
465466--
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)
467468-- >>> printSQL i
468469-- ROW(0, 1)
469470row
470471 :: SListI row
471− => NP (Aliased (Expression db params grp from)) row
472+ => NP (Aliased (Expression commons schemas params grp from)) row
472473 -- ^ 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))
474475row exprs = UnsafeExpression $ "ROW" <> parenthesized
475476 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
476477
@@ -479,10 +480,9 @@ row exprs = UnsafeExpression $ "ROW" <> parenthesized
479480-- '[ "real" ::: 'NotNull 'PGfloat8
480481-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
481482-- type Schema = '["complex" ::: 'Typedef Complex]
482−-- type DB = DBof (Public Schema)
483483-- :}
484484--
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)
486486-- >>> printSQL $ i & field #complex #imaginary
487487-- (ROW(0, 1)::"complex")."imaginary"
488488field
@@ -491,41 +491,41 @@ field
491491 , Has field row ty)
492492 => QualifiedAlias sch tydef -- ^ row type
493493 -> Alias field -- ^ field name
494− -> Expression (commons :=> schemas) params grp from ('NotNull ('PGcomposite row))
495− -> Expression (commons :=> schemas) params grp from ty
494+ -> Expression commons schemas params grp from ('NotNull ('PGcomposite row))
495+ -> Expression commons schemas params grp from ty
496496field td fld expr = UnsafeExpression $
497497 parenthesized (renderSQL expr <> "::" <> renderSQL td)
498498 <> "." <> renderSQL fld
499499
500500instance Semigroup
501− (Expression db params grp from (nullity ('PGvararray ty))) where
501+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
502502 (<>) = unsafeBinaryOp "||"
503503
504504instance Monoid
505− (Expression db params grp from (nullity ('PGvararray ty))) where
505+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
506506 mempty = array []
507507 mappend = (<>)
508508
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)
510510-- >>> printSQL expr
511511-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
512512greatest
513− :: Expression db params grp from (nullty)
513+ :: Expression commons schemas params grp from (nullty)
514514 -- ^ needs at least 1 argument
515− -> [Expression db params grp from (nullty)]
515+ -> [Expression commons schemas params grp from (nullty)]
516516 -- ^ or more
517− -> Expression db params grp from (nullty)
517+ -> Expression commons schemas params grp from (nullty)
518518greatest x xs = UnsafeExpression $ "GREATEST("
519519 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
520520
521521-- | >>> printSQL $ least currentTimestamp [null_]
522522-- LEAST(CURRENT_TIMESTAMP, NULL)
523523least
524− :: Expression db params grp from (nullty)
524+ :: Expression commons schemas params grp from (nullty)
525525 -- ^ needs at least 1 argument
526− -> [Expression db params grp from (nullty)]
526+ -> [Expression commons schemas params grp from (nullty)]
527527 -- ^ or more
528− -> Expression db params grp from (nullty)
528+ -> Expression commons schemas params grp from (nullty)
529529least x xs = UnsafeExpression $ "LEAST("
530530 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
531531
@@ -534,9 +534,9 @@ least x xs = UnsafeExpression $ "LEAST("
534534unsafeBinaryOp
535535 :: ByteString
536536 -- ^ operator
537− -> Expression db params grp from (ty0)
538− -> Expression db params grp from (ty1)
539− -> Expression db params grp from (ty2)
537+ -> Expression commons schemas params grp from (ty0)
538+ -> Expression commons schemas params grp from (ty1)
539+ -> Expression commons schemas params grp from (ty2)
540540unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541541 renderSQL x <+> op <+> renderSQL y
542542
@@ -545,8 +545,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
545545unsafeUnaryOp
546546 :: ByteString
547547 -- ^ operator
548− -> Expression db params grp from (ty0)
549− -> Expression db params grp from (ty1)
548+ -> Expression commons schemas params grp from (ty0)
549+ -> Expression commons schemas params grp from (ty1)
550550unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551551 op <+> renderSQL x
552552
@@ -555,8 +555,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
555555unsafeFunction
556556 :: ByteString
557557 -- ^ function
558− -> Expression db params grp from (xty)
559− -> Expression db params grp from (yty)
558+ -> Expression commons schemas params grp from (xty)
559+ -> Expression commons schemas params grp from (yty)
560560unsafeFunction fun x = UnsafeExpression $
561561 fun <> parenthesized (renderSQL x)
562562
@@ -565,13 +565,13 @@ unsafeVariadicFunction
565565 :: SListI elems
566566 => ByteString
567567 -- ^ function
568− -> NP (Expression db params grp from) elems
569− -> Expression db params grp from ret
568+ -> NP (Expression commons schemas params grp from) elems
569+ -> Expression commons schemas params grp from ret
570570unsafeVariadicFunction fun x = UnsafeExpression $
571571 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
572572
573573instance ty `In` PGNum
574− => Num (Expression db params grp from (nullity ty)) where
574+ => Num (Expression commons schemas params grp from (nullity ty)) where
575575 (+) = unsafeBinaryOp "+"
576576 (-) = unsafeBinaryOp "-"
577577 (*) = unsafeBinaryOp "*"
@@ -583,12 +583,12 @@ instance ty `In` PGNum
583583 . show
584584
585585instance (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
587587 (/) = unsafeBinaryOp "/"
588588 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
589589
590590instance (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
592592 pi = UnsafeExpression "pi()"
593593 exp = unsafeFunction "exp"
594594 log = unsafeFunction "ln"
@@ -611,18 +611,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
611611
612612-- | >>> :{
613613-- let
614−-- expression :: Expression db params grp from (nullity 'PGfloat4)
614+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
615615-- expression = atan2_ pi 2
616616-- in printSQL expression
617617-- :}
618618-- atan2(pi(), 2)
619619atan2_
620620 :: float `In` PGFloating
621− => Expression db params grp from (nullity float)
621+ => Expression commons schemas params grp from (nullity float)
622622 -- ^ numerator
623− -> Expression db params grp from (nullity float)
623+ -> Expression commons schemas params grp from (nullity float)
624624 -- ^ denominator
625− -> Expression db params grp from (nullity float)
625+ -> Expression commons schemas params grp from (nullity float)
626626atan2_ y x = UnsafeExpression $
627627 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
628628
@@ -635,9 +635,9 @@ atan2_ y x = UnsafeExpression $
635635cast
636636 :: TypeExpression schemas ty1
637637 -- ^ type to cast as
638− -> Expression (commons :=> schemas) params grp from ty0
638+ -> Expression commons schemas params grp from ty0
639639 -- ^ value to convert
640− -> Expression (commons :=> schemas) params grp from ty1
640+ -> Expression commons schemas params grp from ty1
641641cast ty x = UnsafeExpression $ parenthesized $
642642 renderSQL x <+> "::" <+> renderSQL ty
643643
@@ -645,136 +645,136 @@ cast ty x = UnsafeExpression $ parenthesized $
645645--
646646-- >>> :{
647647-- let
648−-- expression :: Expression db params grp from (nullity 'PGint2)
648+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
649649-- expression = 5 `quot_` 2
650650-- in printSQL expression
651651-- :}
652652-- (5 / 2)
653653quot_
654654 :: int `In` PGIntegral
655− => Expression db params grp from (nullity int)
655+ => Expression commons schemas params grp from (nullity int)
656656 -- ^ numerator
657− -> Expression db params grp from (nullity int)
657+ -> Expression commons schemas params grp from (nullity int)
658658 -- ^ denominator
659− -> Expression db params grp from (nullity int)
659+ -> Expression commons schemas params grp from (nullity int)
660660quot_ = unsafeBinaryOp "/"
661661
662662-- | remainder upon integer division
663663--
664664-- >>> :{
665665-- let
666−-- expression :: Expression db params grp from (nullity 'PGint2)
666+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
667667-- expression = 5 `rem_` 2
668668-- in printSQL expression
669669-- :}
670670-- (5 % 2)
671671rem_
672672 :: int `In` PGIntegral
673− => Expression db params grp from (nullity int)
673+ => Expression commons schemas params grp from (nullity int)
674674 -- ^ numerator
675− -> Expression db params grp from (nullity int)
675+ -> Expression commons schemas params grp from (nullity int)
676676 -- ^ denominator
677− -> Expression db params grp from (nullity int)
677+ -> Expression commons schemas params grp from (nullity int)
678678rem_ = unsafeBinaryOp "%"
679679
680680-- | >>> :{
681681-- let
682−-- expression :: Expression db params grp from (nullity 'PGfloat4)
682+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
683683-- expression = trunc pi
684684-- in printSQL expression
685685-- :}
686686-- trunc(pi())
687687trunc
688688 :: frac `In` PGFloating
689− => Expression db params grp from (nullity frac)
689+ => Expression commons schemas params grp from (nullity frac)
690690 -- ^ fractional number
691− -> Expression db params grp from (nullity frac)
691+ -> Expression commons schemas params grp from (nullity frac)
692692trunc = unsafeFunction "trunc"
693693
694694-- | >>> :{
695695-- let
696−-- expression :: Expression db params grp from (nullity 'PGfloat4)
696+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
697697-- expression = round_ pi
698698-- in printSQL expression
699699-- :}
700700-- round(pi())
701701round_
702702 :: frac `In` PGFloating
703− => Expression db params grp from (nullity frac)
703+ => Expression commons schemas params grp from (nullity frac)
704704 -- ^ fractional number
705− -> Expression db params grp from (nullity frac)
705+ -> Expression commons schemas params grp from (nullity frac)
706706round_ = unsafeFunction "round"
707707
708708-- | >>> :{
709709-- let
710−-- expression :: Expression db params grp from (nullity 'PGfloat4)
710+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
711711-- expression = ceiling_ pi
712712-- in printSQL expression
713713-- :}
714714-- ceiling(pi())
715715ceiling_
716716 :: frac `In` PGFloating
717− => Expression db params grp from (nullity frac)
717+ => Expression commons schemas params grp from (nullity frac)
718718 -- ^ fractional number
719− -> Expression db params grp from (nullity frac)
719+ -> Expression commons schemas params grp from (nullity frac)
720720ceiling_ = unsafeFunction "ceiling"
721721
722722-- | A `Condition` is an `Expression`, which can evaluate
723723-- to `true`, `false` or `null_`. This is because SQL uses
724724-- a three valued logic.
725−type Condition db params grp from =
726− Expression db params grp from ('Null 'PGbool)
725+type Condition commons schemas params grp from =
726+ Expression commons schemas params grp from ('Null 'PGbool)
727727
728728-- | >>> printSQL true
729729-- TRUE
730−true :: Expression db params grp from (nullity 'PGbool)
730+true :: Expression commons schemas params grp from (nullity 'PGbool)
731731true = UnsafeExpression "TRUE"
732732
733733-- | >>> printSQL false
734734-- FALSE
735−false :: Expression db params grp from (nullity 'PGbool)
735+false :: Expression commons schemas params grp from (nullity 'PGbool)
736736false = UnsafeExpression "FALSE"
737737
738738-- | >>> printSQL $ not_ true
739739-- (NOT TRUE)
740740not_
741− :: Expression db params grp from (nullity 'PGbool)
742− -> Expression db params grp from (nullity 'PGbool)
741+ :: Expression commons schemas params grp from (nullity 'PGbool)
742+ -> Expression commons schemas params grp from (nullity 'PGbool)
743743not_ = unsafeUnaryOp "NOT"
744744
745745-- | >>> printSQL $ true .&& false
746746-- (TRUE AND FALSE)
747747(.&&)
748− :: Expression db params grp from (nullity 'PGbool)
749− -> Expression db params grp from (nullity 'PGbool)
750− -> Expression db params grp from (nullity 'PGbool)
748+ :: Expression commons schemas params grp from (nullity 'PGbool)
749+ -> Expression commons schemas params grp from (nullity 'PGbool)
750+ -> Expression commons schemas params grp from (nullity 'PGbool)
751751infixr 3 .&&
752752(.&&) = unsafeBinaryOp "AND"
753753
754754-- | >>> printSQL $ true .|| false
755755-- (TRUE OR FALSE)
756756(.||)
757− :: Expression db params grp from (nullity 'PGbool)
758− -> Expression db params grp from (nullity 'PGbool)
759− -> Expression db params grp from (nullity 'PGbool)
757+ :: Expression commons schemas params grp from (nullity 'PGbool)
758+ -> Expression commons schemas params grp from (nullity 'PGbool)
759+ -> Expression commons schemas params grp from (nullity 'PGbool)
760760infixr 2 .||
761761(.||) = unsafeBinaryOp "OR"
762762
763763-- | >>> :{
764764-- let
765−-- expression :: Expression db params grp from (nullity 'PGint2)
765+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
766766-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
767767-- in printSQL expression
768768-- :}
769769-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
770770caseWhenThenElse
771− :: [ ( Condition db params grp from
772− , Expression db params grp from ty
771+ :: [ ( Condition commons schemas params grp from
772+ , Expression commons schemas params grp from ty
773773 ) ]
774774 -- ^ whens and thens
775− -> Expression db params grp from ty
775+ -> Expression commons schemas params grp from ty
776776 -- ^ else
777− -> Expression db params grp from ty
777+ -> Expression commons schemas params grp from ty
778778caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
779779 [ "CASE"
780780 , mconcat
@@ -790,16 +790,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
790790
791791-- | >>> :{
792792-- let
793−-- expression :: Expression db params grp from (nullity 'PGint2)
793+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
794794-- expression = ifThenElse true 1 0
795795-- in printSQL expression
796796-- :}
797797-- CASE WHEN TRUE THEN 1 ELSE 0 END
798798ifThenElse
799− :: Condition db params grp from
800− -> Expression db params grp from ty -- ^ then
801− -> Expression db params grp from ty -- ^ else
802− -> Expression db params grp from ty
799+ :: Condition commons schemas params grp from
800+ -> Expression commons schemas params grp from ty -- ^ then
801+ -> Expression commons schemas params grp from ty -- ^ else
802+ -> Expression commons schemas params grp from ty
803803ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
804804
805805-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -808,85 +808,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
808808-- >>> printSQL $ true .== null_
809809-- (TRUE = NULL)
810810(.==)
811− :: Expression db params grp from (nullity0 ty) -- ^ lhs
812− -> Expression db params grp from (nullity1 ty) -- ^ rhs
813− -> Condition db params grp from
811+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
812+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
813+ -> Condition commons schemas params grp from
814814(.==) = unsafeBinaryOp "="
815815infix 4 .==
816816
817817-- | >>> printSQL $ true ./= null_
818818-- (TRUE <> NULL)
819819(./=)
820− :: Expression db params grp from (nullity0 ty) -- ^ lhs
821− -> Expression db params grp from (nullity1 ty) -- ^ rhs
822− -> Condition db params grp from
820+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
821+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
822+ -> Condition commons schemas params grp from
823823(./=) = unsafeBinaryOp "<>"
824824infix 4 ./=
825825
826826-- | >>> printSQL $ true .>= null_
827827-- (TRUE >= NULL)
828828(.>=)
829− :: Expression db params grp from (nullity0 ty) -- ^ lhs
830− -> Expression db params grp from (nullity1 ty) -- ^ rhs
831− -> Condition db params grp from
829+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
830+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
831+ -> Condition commons schemas params grp from
832832(.>=) = unsafeBinaryOp ">="
833833infix 4 .>=
834834
835835-- | >>> printSQL $ true .< null_
836836-- (TRUE < NULL)
837837(.<)
838− :: Expression db params grp from (nullity0 ty) -- ^ lhs
839− -> Expression db params grp from (nullity1 ty) -- ^ rhs
840− -> Condition db params grp from
838+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
839+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
840+ -> Condition commons schemas params grp from
841841(.<) = unsafeBinaryOp "<"
842842infix 4 .<
843843
844844-- | >>> printSQL $ true .<= null_
845845-- (TRUE <= NULL)
846846(.<=)
847− :: Expression db params grp from (nullity0 ty) -- ^ lhs
848− -> Expression db params grp from (nullity1 ty) -- ^ rhs
849− -> Condition db params grp from
847+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
848+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
849+ -> Condition commons schemas params grp from
850850(.<=) = unsafeBinaryOp "<="
851851infix 4 .<=
852852
853853-- | >>> printSQL $ true .> null_
854854-- (TRUE > NULL)
855855(.>)
856− :: Expression db params grp from (nullity0 ty) -- ^ lhs
857− -> Expression db params grp from (nullity1 ty) -- ^ rhs
858− -> Condition db params grp from
856+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
857+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
858+ -> Condition commons schemas params grp from
859859(.>) = unsafeBinaryOp ">"
860860infix 4 .>
861861
862862-- | >>> printSQL currentDate
863863-- CURRENT_DATE
864864currentDate
865− :: Expression db params grp from (nullity 'PGdate)
865+ :: Expression commons schemas params grp from (nullity 'PGdate)
866866currentDate = UnsafeExpression "CURRENT_DATE"
867867
868868-- | >>> printSQL currentTime
869869-- CURRENT_TIME
870870currentTime
871− :: Expression db params grp from (nullity 'PGtimetz)
871+ :: Expression commons schemas params grp from (nullity 'PGtimetz)
872872currentTime = UnsafeExpression "CURRENT_TIME"
873873
874874-- | >>> printSQL currentTimestamp
875875-- CURRENT_TIMESTAMP
876876currentTimestamp
877− :: Expression db params grp from (nullity 'PGtimestamptz)
877+ :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
878878currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
879879
880880-- | >>> printSQL localTime
881881-- LOCALTIME
882882localTime
883− :: Expression db params grp from (nullity 'PGtime)
883+ :: Expression commons schemas params grp from (nullity 'PGtime)
884884localTime = UnsafeExpression "LOCALTIME"
885885
886886-- | >>> printSQL localTimestamp
887887-- LOCALTIMESTAMP
888888localTimestamp
889− :: Expression db params grp from (nullity 'PGtimestamp)
889+ :: Expression commons schemas params grp from (nullity 'PGtimestamp)
890890localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
891891
892892{-----------------------------------------
@@ -894,7 +894,7 @@ text
894894-----------------------------------------}
895895
896896instance IsString
897− (Expression db params grp from (nullity 'PGtext)) where
897+ (Expression commons schemas params grp from (nullity 'PGtext)) where
898898 fromString str = UnsafeExpression $
899899 "E\'" <> fromString (escape =<< str) <> "\'"
900900 where
@@ -910,36 +910,36 @@ instance IsString
910910 c -> [c]
911911
912912instance Semigroup
913− (Expression db params grp from (nullity 'PGtext)) where
913+ (Expression commons schemas params grp from (nullity 'PGtext)) where
914914 (<>) = unsafeBinaryOp "||"
915915
916916instance Monoid
917− (Expression db params grp from (nullity 'PGtext)) where
917+ (Expression commons schemas params grp from (nullity 'PGtext)) where
918918 mempty = fromString ""
919919 mappend = (<>)
920920
921921-- | >>> printSQL $ lower "ARRRGGG"
922922-- lower(E'ARRRGGG')
923923lower
924− :: Expression db params grp from (nullity 'PGtext)
924+ :: Expression commons schemas params grp from (nullity 'PGtext)
925925 -- ^ string to lower case
926− -> Expression db params grp from (nullity 'PGtext)
926+ -> Expression commons schemas params grp from (nullity 'PGtext)
927927lower = unsafeFunction "lower"
928928
929929-- | >>> printSQL $ upper "eeee"
930930-- upper(E'eeee')
931931upper
932− :: Expression db params grp from (nullity 'PGtext)
932+ :: Expression commons schemas params grp from (nullity 'PGtext)
933933 -- ^ string to upper case
934− -> Expression db params grp from (nullity 'PGtext)
934+ -> Expression commons schemas params grp from (nullity 'PGtext)
935935upper = unsafeFunction "upper"
936936
937937-- | >>> printSQL $ charLength "four"
938938-- char_length(E'four')
939939charLength
940− :: Expression db params grp from (nullity 'PGtext)
940+ :: Expression commons schemas params grp from (nullity 'PGtext)
941941 -- ^ string to measure
942− -> Expression db params grp from (nullity 'PGint4)
942+ -> Expression commons schemas params grp from (nullity 'PGint4)
943943charLength = unsafeFunction "char_length"
944944
945945-- | The `like` expression returns true if the @string@ matches
@@ -952,11 +952,11 @@ charLength = unsafeFunction "char_length"
952952-- >>> printSQL $ "abc" `like` "a%"
953953-- (E'abc' LIKE E'a%')
954954like
955− :: Expression db params grp from (nullity 'PGtext)
955+ :: Expression commons schemas params grp from (nullity 'PGtext)
956956 -- ^ string
957− -> Expression db params grp from (nullity 'PGtext)
957+ -> Expression commons schemas params grp from (nullity 'PGtext)
958958 -- ^ pattern
959− -> Expression db params grp from (nullity 'PGbool)
959+ -> Expression commons schemas params grp from (nullity 'PGbool)
960960like = unsafeBinaryOp "LIKE"
961961
962962-- | The key word ILIKE can be used instead of LIKE to make the
@@ -965,11 +965,11 @@ like = unsafeBinaryOp "LIKE"
965965-- >>> printSQL $ "abc" `ilike` "a%"
966966-- (E'abc' ILIKE E'a%')
967967ilike
968− :: Expression db params grp from (nullity 'PGtext)
968+ :: Expression commons schemas params grp from (nullity 'PGtext)
969969 -- ^ string
970− -> Expression db params grp from (nullity 'PGtext)
970+ -> Expression commons schemas params grp from (nullity 'PGtext)
971971 -- ^ pattern
972− -> Expression db params grp from (nullity 'PGbool)
972+ -> Expression commons schemas params grp from (nullity 'PGbool)
973973ilike = unsafeBinaryOp "ILIKE"
974974
975975{-----------------------------------------
@@ -984,36 +984,36 @@ Table 9.44: json and jsonb operators
984984-- | Get JSON value (object field or array element) at a key.
985985(.->)
986986 :: (json `In` PGJsonType, key `In` PGJsonKey)
987− => Expression db params grp from (nullity json)
988− -> Expression db params grp from (nullity key)
989− -> Expression db params grp from ('Null json)
987+ => Expression commons schemas params grp from (nullity json)
988+ -> Expression commons schemas params grp from (nullity key)
989+ -> Expression commons schemas params grp from ('Null json)
990990infixl 8 .->
991991(.->) = unsafeBinaryOp "->"
992992
993993-- | Get JSON value (object field or array element) at a key, as text.
994994(.->>)
995995 :: (json `In` PGJsonType, key `In` PGJsonKey)
996− => Expression db params grp from (nullity json)
997− -> Expression db params grp from (nullity key)
998− -> Expression db params grp from ('Null 'PGtext)
996+ => Expression commons schemas params grp from (nullity json)
997+ -> Expression commons schemas params grp from (nullity key)
998+ -> Expression commons schemas params grp from ('Null 'PGtext)
999999infixl 8 .->>
10001000(.->>) = unsafeBinaryOp "->>"
10011001
10021002-- | Get JSON value at a specified path.
10031003(.#>)
10041004 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1005− => Expression db params grp from (nullity json)
1006− -> Expression db params grp from (nullity path)
1007− -> Expression db params grp from ('Null json)
1005+ => Expression commons schemas params grp from (nullity json)
1006+ -> Expression commons schemas params grp from (nullity path)
1007+ -> Expression commons schemas params grp from ('Null json)
10081008infixl 8 .#>
10091009(.#>) = unsafeBinaryOp "#>"
10101010
10111011-- | Get JSON value at a specified path as text.
10121012(.#>>)
10131013 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1014− => Expression db params grp from (nullity json)
1015− -> Expression db params grp from (nullity path)
1016− -> Expression db params grp from ('Null 'PGtext)
1014+ => Expression commons schemas params grp from (nullity json)
1015+ -> Expression commons schemas params grp from (nullity path)
1016+ -> Expression commons schemas params grp from ('Null 'PGtext)
10171017infixl 8 .#>>
10181018(.#>>) = unsafeBinaryOp "#>>"
10191019
@@ -1022,48 +1022,48 @@ infixl 8 .#>>
10221022-- | Does the left JSON value contain the right JSON path/value entries at the
10231023-- top level?
10241024(.@>)
1025− :: Expression db params grp from (nullity 'PGjsonb)
1026− -> Expression db params grp from (nullity 'PGjsonb)
1027− -> Condition db params grp from
1025+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1026+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1027+ -> Condition commons schemas params grp from
10281028infixl 9 .@>
10291029(.@>) = unsafeBinaryOp "@>"
10301030
10311031-- | Are the left JSON path/value entries contained at the top level within the
10321032-- right JSON value?
10331033(.<@)
1034− :: Expression db params grp from (nullity 'PGjsonb)
1035− -> Expression db params grp from (nullity 'PGjsonb)
1036− -> Condition db params grp from
1034+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1035+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1036+ -> Condition commons schemas params grp from
10371037infixl 9 .<@
10381038(.<@) = unsafeBinaryOp "<@"
10391039
10401040-- | Does the string exist as a top-level key within the JSON value?
10411041(.?)
1042− :: Expression db params grp from (nullity 'PGjsonb)
1043− -> Expression db params grp from (nullity 'PGtext)
1044− -> Condition db params grp from
1042+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1043+ -> Expression commons schemas params grp from (nullity 'PGtext)
1044+ -> Condition commons schemas params grp from
10451045infixl 9 .?
10461046(.?) = unsafeBinaryOp "?"
10471047
10481048-- | Do any of these array strings exist as top-level keys?
10491049(.?|)
1050− :: Expression db params grp from (nullity 'PGjsonb)
1051− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1052− -> Condition db params grp from
1050+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1051+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1052+ -> Condition commons schemas params grp from
10531053infixl 9 .?|
10541054(.?|) = unsafeBinaryOp "?|"
10551055
10561056-- | Do all of these array strings exist as top-level keys?
10571057(.?&)
1058− :: Expression db params grp from (nullity 'PGjsonb)
1059− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1060− -> Condition db params grp from
1058+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1059+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1060+ -> Condition commons schemas params grp from
10611061infixl 9 .?&
10621062(.?&) = unsafeBinaryOp "?&"
10631063
10641064-- | Concatenate two jsonb values into a new jsonb value.
10651065instance
1066− Semigroup (Expression db from grouping param (nullity 'PGjsonb)) where
1066+ Semigroup (Expression commons schemas from grouping param (nullity 'PGjsonb)) where
10671067 (<>) = unsafeBinaryOp "||"
10681068
10691069-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1080,9 +1080,9 @@ instance
10801080-- count from the end). Throws an error if top level container is not an array.
10811081(.-.)
10821082 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1083− => Expression db params grp from (nullity 'PGjsonb)
1084− -> Expression db params grp from (nullity key)
1085− -> Expression db params grp from (nullity 'PGjsonb)
1083+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1084+ -> Expression commons schemas params grp from (nullity key)
1085+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
10861086infixl 6 .-.
10871087(.-.) = unsafeBinaryOp "-"
10881088
@@ -1090,9 +1090,9 @@ infixl 6 .-.
10901090-- integers count from the end)
10911091(#-.)
10921092 :: PGTextArray "(#-.)" arrayty
1093− => Expression db params grp from (nullity 'PGjsonb)
1094− -> Expression db params grp from (nullity arrayty)
1095− -> Expression db params grp from (nullity 'PGjsonb)
1093+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1094+ -> Expression commons schemas params grp from (nullity arrayty)
1095+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
10961096infixl 6 #-.
10971097(#-.) = unsafeBinaryOp "#-"
10981098
@@ -1103,14 +1103,14 @@ Table 9.45: JSON creation functions
11031103-- | Literal binary JSON
11041104jsonbLit
11051105 :: JSON.ToJSON x
1106− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjsonb)
1106+ => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
11071107jsonbLit = cast jsonb . UnsafeExpression
11081108 . singleQuotedUtf8 . toStrict . JSON.encode
11091109
11101110-- | Literal JSON
11111111jsonLit
11121112 :: JSON.ToJSON x
1113− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjson)
1113+ => x -> Expression commons schemas params grp from (nullity 'PGjson)
11141114jsonLit = cast json . UnsafeExpression
11151115 . singleQuotedUtf8 . toStrict . JSON.encode
11161116
@@ -1121,8 +1121,8 @@ jsonLit = cast json . UnsafeExpression
11211121-- number, a Boolean, or a null value, the text representation will be used, in
11221122-- such a fashion that it is a valid json value.
11231123toJson
1124− :: Expression db params grp from (nullity ty)
1125− -> Expression db params grp from (nullity 'PGjson)
1124+ :: Expression commons schemas params grp from (nullity ty)
1125+ -> Expression commons schemas params grp from (nullity 'PGjson)
11261126toJson = unsafeFunction "to_json"
11271127
11281128-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1132,43 +1132,43 @@ toJson = unsafeFunction "to_json"
11321132-- number, a Boolean, or a null value, the text representation will be used, in
11331133-- such a fashion that it is a valid jsonb value.
11341134toJsonb
1135− :: Expression db params grp from (nullity ty)
1136− -> Expression db params grp from (nullity 'PGjsonb)
1135+ :: Expression commons schemas params grp from (nullity ty)
1136+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
11371137toJsonb = unsafeFunction "to_jsonb"
11381138
11391139-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
11401140-- becomes a JSON array of arrays.
11411141arrayToJson
11421142 :: PGArray "arrayToJson" arr
1143− => Expression db params grp from (nullity arr)
1144− -> Expression db params grp from (nullity 'PGjson)
1143+ => Expression commons schemas params grp from (nullity arr)
1144+ -> Expression commons schemas params grp from (nullity 'PGjson)
11451145arrayToJson = unsafeFunction "array_to_json"
11461146
11471147-- | Returns the row as a JSON object.
11481148rowToJson
1149− :: Expression db params grp from (nullity ('PGcomposite ty))
1150− -> Expression db params grp from (nullity 'PGjson)
1149+ :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1150+ -> Expression commons schemas params grp from (nullity 'PGjson)
11511151rowToJson = unsafeFunction "row_to_json"
11521152
11531153-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
11541154-- argument list.
11551155jsonBuildArray
11561156 :: SListI elems
1157− => NP (Expression db params grp from) elems
1158− -> Expression db params grp from (nullity 'PGjson)
1157+ => NP (Expression commons schemas params grp from) elems
1158+ -> Expression commons schemas params grp from (nullity 'PGjson)
11591159jsonBuildArray = unsafeVariadicFunction "json_build_array"
11601160
11611161-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
11621162-- variadic argument list.
11631163jsonbBuildArray
11641164 :: SListI elems
1165− => NP (Expression db params grp from) elems
1166− -> Expression db params grp from (nullity 'PGjsonb)
1165+ => NP (Expression commons schemas params grp from) elems
1166+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
11671167jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
11681168
11691169unsafeRowFunction
11701170 :: All Top elems
1171− => NP (Aliased (Expression db params grp from)) elems
1171+ => NP (Aliased (Expression commons schemas params grp from)) elems
11721172 -> [ByteString]
11731173unsafeRowFunction =
11741174 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1183,8 +1183,8 @@ unsafeRowFunction =
11831183-- and values.
11841184jsonBuildObject
11851185 :: All Top elems
1186− => NP (Aliased (Expression db params grp from)) elems
1187− -> Expression db params grp from (nullity 'PGjson)
1186+ => NP (Aliased (Expression commons schemas params grp from)) elems
1187+ -> Expression commons schemas params grp from (nullity 'PGjson)
11881188jsonBuildObject
11891189 = unsafeFunction "json_build_object"
11901190 . UnsafeExpression
@@ -1196,8 +1196,8 @@ jsonBuildObject
11961196-- between text and values.
11971197jsonbBuildObject
11981198 :: All Top elems
1199− => NP (Aliased (Expression db params grp from)) elems
1200− -> Expression db params grp from (nullity 'PGjsonb)
1199+ => NP (Aliased (Expression commons schemas params grp from)) elems
1200+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12011201jsonbBuildObject
12021202 = unsafeFunction "jsonb_build_object"
12031203 . UnsafeExpression
@@ -1210,8 +1210,8 @@ jsonbBuildObject
12101210-- array has exactly two elements, which are taken as a key/value pair.
12111211jsonObject
12121212 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1213− => Expression db params grp from (nullity arr)
1214− -> Expression db params grp from (nullity 'PGjson)
1213+ => Expression commons schemas params grp from (nullity arr)
1214+ -> Expression commons schemas params grp from (nullity 'PGjson)
12151215jsonObject = unsafeFunction "json_object"
12161216
12171217-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1220,8 +1220,8 @@ jsonObject = unsafeFunction "json_object"
12201220-- array has exactly two elements, which are taken as a key/value pair.
12211221jsonbObject
12221222 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1223− => Expression db params grp from (nullity arr)
1224− -> Expression db params grp from (nullity 'PGjsonb)
1223+ => Expression commons schemas params grp from (nullity arr)
1224+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12251225jsonbObject = unsafeFunction "jsonb_object"
12261226
12271227-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1229,9 +1229,9 @@ jsonbObject = unsafeFunction "jsonb_object"
12291229jsonZipObject
12301230 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
12311231 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1232− => Expression db params grp from (nullity keysArray)
1233− -> Expression db params grp from (nullity valuesArray)
1234− -> Expression db params grp from (nullity 'PGjson)
1232+ => Expression commons schemas params grp from (nullity keysArray)
1233+ -> Expression commons schemas params grp from (nullity valuesArray)
1234+ -> Expression commons schemas params grp from (nullity 'PGjson)
12351235jsonZipObject ks vs =
12361236 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
12371237
@@ -1241,9 +1241,9 @@ jsonZipObject ks vs =
12411241jsonbZipObject
12421242 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
12431243 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1244− => Expression db params grp from (nullity keysArray)
1245− -> Expression db params grp from (nullity valuesArray)
1246− -> Expression db params grp from (nullity 'PGjsonb)
1244+ => Expression commons schemas params grp from (nullity keysArray)
1245+ -> Expression commons schemas params grp from (nullity valuesArray)
1246+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12471247jsonbZipObject ks vs =
12481248 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
12491249
@@ -1253,23 +1253,23 @@ Table 9.46: JSON processing functions
12531253
12541254-- | Returns the number of elements in the outermost JSON array.
12551255jsonArrayLength
1256− :: Expression db params grp from (nullity 'PGjson)
1257− -> Expression db params grp from (nullity 'PGint4)
1256+ :: Expression commons schemas params grp from (nullity 'PGjson)
1257+ -> Expression commons schemas params grp from (nullity 'PGint4)
12581258jsonArrayLength = unsafeFunction "json_array_length"
12591259
12601260-- | Returns the number of elements in the outermost binary JSON array.
12611261jsonbArrayLength
1262− :: Expression db params grp from (nullity 'PGjsonb)
1263− -> Expression db params grp from (nullity 'PGint4)
1262+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1263+ -> Expression commons schemas params grp from (nullity 'PGint4)
12641264jsonbArrayLength = unsafeFunction "jsonb_array_length"
12651265
12661266-- | Returns JSON value pointed to by the given path (equivalent to #>
12671267-- operator).
12681268jsonExtractPath
12691269 :: SListI elems
1270− => Expression db params grp from (nullity 'PGjson)
1271− -> NP (Expression db params grp from) elems
1272− -> Expression db params grp from (nullity 'PGjsonb)
1270+ => Expression commons schemas params grp from (nullity 'PGjson)
1271+ -> NP (Expression commons schemas params grp from) elems
1272+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12731273jsonExtractPath x xs =
12741274 unsafeVariadicFunction "json_extract_path" (x :* xs)
12751275
@@ -1277,9 +1277,9 @@ jsonExtractPath x xs =
12771277-- operator).
12781278jsonbExtractPath
12791279 :: SListI elems
1280− => Expression db params grp from (nullity 'PGjsonb)
1281− -> NP (Expression db params grp from) elems
1282− -> Expression db params grp from (nullity 'PGjsonb)
1280+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1281+ -> NP (Expression commons schemas params grp from) elems
1282+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12831283jsonbExtractPath x xs =
12841284 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
12851285
@@ -1287,9 +1287,9 @@ jsonbExtractPath x xs =
12871287-- operator), as text.
12881288jsonExtractPathAsText
12891289 :: SListI elems
1290− => Expression db params grp from (nullity 'PGjson)
1291− -> NP (Expression db params grp from) elems
1292− -> Expression db params grp from (nullity 'PGjson)
1290+ => Expression commons schemas params grp from (nullity 'PGjson)
1291+ -> NP (Expression commons schemas params grp from) elems
1292+ -> Expression commons schemas params grp from (nullity 'PGjson)
12931293jsonExtractPathAsText x xs =
12941294 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
12951295
@@ -1297,38 +1297,38 @@ jsonExtractPathAsText x xs =
12971297-- operator), as text.
12981298jsonbExtractPathAsText
12991299 :: SListI elems
1300− => Expression db params grp from (nullity 'PGjsonb)
1301− -> NP (Expression db params grp from) elems
1302− -> Expression db params grp from (nullity 'PGjsonb)
1300+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1301+ -> NP (Expression commons schemas params grp from) elems
1302+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13031303jsonbExtractPathAsText x xs =
13041304 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
13051305
13061306-- | Returns the type of the outermost JSON value as a text string. Possible
13071307-- types are object, array, string, number, boolean, and null.
13081308jsonTypeof
1309− :: Expression db params grp from (nullity 'PGjson)
1310− -> Expression db params grp from (nullity 'PGtext)
1309+ :: Expression commons schemas params grp from (nullity 'PGjson)
1310+ -> Expression commons schemas params grp from (nullity 'PGtext)
13111311jsonTypeof = unsafeFunction "json_typeof"
13121312
13131313-- | Returns the type of the outermost binary JSON value as a text string.
13141314-- Possible types are object, array, string, number, boolean, and null.
13151315jsonbTypeof
1316− :: Expression db params grp from (nullity 'PGjsonb)
1317− -> Expression db params grp from (nullity 'PGtext)
1316+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1317+ -> Expression commons schemas params grp from (nullity 'PGtext)
13181318jsonbTypeof = unsafeFunction "jsonb_typeof"
13191319
13201320-- | Returns its argument with all object fields that have null values omitted.
13211321-- Other null values are untouched.
13221322jsonStripNulls
1323− :: Expression db params grp from (nullity 'PGjson)
1324− -> Expression db params grp from (nullity 'PGjson)
1323+ :: Expression commons schemas params grp from (nullity 'PGjson)
1324+ -> Expression commons schemas params grp from (nullity 'PGjson)
13251325jsonStripNulls = unsafeFunction "json_strip_nulls"
13261326
13271327-- | Returns its argument with all object fields that have null values omitted.
13281328-- Other null values are untouched.
13291329jsonbStripNulls
1330− :: Expression db params grp from (nullity 'PGjsonb)
1331− -> Expression db params grp from (nullity 'PGjsonb)
1330+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1331+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13321332jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
13331333
13341334-- | @ jsonbSet target path new_value create_missing @
@@ -1340,11 +1340,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
13401340-- arrays.
13411341jsonbSet
13421342 :: PGTextArray "jsonbSet" arr
1343− => Expression db params grp from (nullity 'PGjsonb)
1344− -> Expression db params grp from (nullity arr)
1345− -> Expression db params grp from (nullity 'PGjsonb)
1346− -> Maybe (Expression db params grp from (nullity 'PGbool))
1347− -> Expression db params grp from (nullity 'PGjsonb)
1343+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1344+ -> Expression commons schemas params grp from (nullity arr)
1345+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1346+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1347+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13481348jsonbSet tgt path val createMissing = case createMissing of
13491349 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
13501350 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1359,19 +1359,19 @@ jsonbSet tgt path val createMissing = case createMissing of
13591359-- in path count from the end of JSON arrays.
13601360jsonbInsert
13611361 :: PGTextArray "jsonbInsert" arr
1362− => Expression db params grp from (nullity 'PGjsonb)
1363− -> Expression db params grp from (nullity arr)
1364− -> Expression db params grp from (nullity 'PGjsonb)
1365− -> Maybe (Expression db params grp from (nullity 'PGbool))
1366− -> Expression db params grp from (nullity 'PGjsonb)
1362+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1363+ -> Expression commons schemas params grp from (nullity arr)
1364+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1365+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1366+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13671367jsonbInsert tgt path val insertAfter = case insertAfter of
13681368 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
13691369 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
13701370
13711371-- | Returns its argument as indented JSON text.
13721372jsonbPretty
1373− :: Expression db params grp from (nullity 'PGjsonb)
1374− -> Expression db params grp from (nullity 'PGtext)
1373+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1374+ -> Expression commons schemas params grp from (nullity 'PGtext)
13751375jsonbPretty = unsafeFunction "jsonb_pretty"
13761376
13771377{-----------------------------------------
@@ -1381,54 +1381,54 @@ aggregation
13811381-- | escape hatch to define aggregate functions
13821382unsafeAggregate
13831383 :: ByteString -- ^ aggregate function
1384− -> Expression db from 'Ungrouped params (xty)
1385− -> Expression db from ('Grouped bys) params (yty)
1384+ -> Expression commons schemas from 'Ungrouped params (xty)
1385+ -> Expression commons schemas from ('Grouped bys) params (yty)
13861386unsafeAggregate fun x = UnsafeExpression $ mconcat
13871387 [fun, "(", renderSQL x, ")"]
13881388
13891389-- | escape hatch to define aggregate functions over distinct values
13901390unsafeAggregateDistinct
13911391 :: ByteString -- ^ aggregate function
1392− -> Expression db from 'Ungrouped params (xty)
1393− -> Expression db from ('Grouped bys) params (yty)
1392+ -> Expression commons schemas from 'Ungrouped params (xty)
1393+ -> Expression commons schemas from ('Grouped bys) params (yty)
13941394unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
13951395 [fun, "(DISTINCT ", renderSQL x, ")"]
13961396
13971397-- | >>> :{
13981398-- let
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)
14001400-- expression = sum_ #col
14011401-- in printSQL expression
14021402-- :}
14031403-- sum("col")
14041404sum_
14051405 :: ty `In` PGNum
1406− => Expression db from 'Ungrouped params (nullity ty)
1406+ => Expression commons schemas from 'Ungrouped params (nullity ty)
14071407 -- ^ what to sum
1408− -> Expression db from ('Grouped bys) params (nullity ty)
1408+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
14091409sum_ = unsafeAggregate "sum"
14101410
14111411-- | >>> :{
14121412-- let
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)
14141414-- expression = sumDistinct #col
14151415-- in printSQL expression
14161416-- :}
14171417-- sum(DISTINCT "col")
14181418sumDistinct
14191419 :: ty `In` PGNum
1420− => Expression db from 'Ungrouped params (nullity ty)
1420+ => Expression commons schemas from 'Ungrouped params (nullity ty)
14211421 -- ^ what to sum
1422− -> Expression db from ('Grouped bys) params (nullity ty)
1422+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
14231423sumDistinct = unsafeAggregateDistinct "sum"
14241424
14251425-- | A constraint for `PGType`s that you can take averages of and the resulting
14261426-- `PGType`.
14271427class PGAvg ty avg | ty -> avg where
14281428 avg, avgDistinct
1429− :: Expression db from 'Ungrouped params (nullity ty)
1429+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
14301430 -- ^ what to average
1431− -> Expression db from ('Grouped bys) params (nullity avg)
1431+ -> Expression commons schemas from ('Grouped bys) params (nullity avg)
14321432 avg = unsafeAggregate "avg"
14331433 avgDistinct = unsafeAggregateDistinct "avg"
14341434instance PGAvg 'PGint2 'PGnumeric
@@ -1441,110 +1441,110 @@ instance PGAvg 'PGinterval 'PGinterval
14411441
14421442-- | >>> :{
14431443-- let
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)
14451445-- expression = bitAnd #col
14461446-- in printSQL expression
14471447-- :}
14481448-- bit_and("col")
14491449bitAnd
14501450 :: int `In` PGIntegral
1451− => Expression db from 'Ungrouped params (nullity int)
1451+ => Expression commons schemas from 'Ungrouped params (nullity int)
14521452 -- ^ what to aggregate
1453− -> Expression db from ('Grouped bys) params (nullity int)
1453+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14541454bitAnd = unsafeAggregate "bit_and"
14551455
14561456-- | >>> :{
14571457-- let
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)
14591459-- expression = bitOr #col
14601460-- in printSQL expression
14611461-- :}
14621462-- bit_or("col")
14631463bitOr
14641464 :: int `In` PGIntegral
1465− => Expression db from 'Ungrouped params (nullity int)
1465+ => Expression commons schemas from 'Ungrouped params (nullity int)
14661466 -- ^ what to aggregate
1467− -> Expression db from ('Grouped bys) params (nullity int)
1467+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14681468bitOr = unsafeAggregate "bit_or"
14691469
14701470-- | >>> :{
14711471-- let
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)
14731473-- expression = bitAndDistinct #col
14741474-- in printSQL expression
14751475-- :}
14761476-- bit_and(DISTINCT "col")
14771477bitAndDistinct
14781478 :: int `In` PGIntegral
1479− => Expression db from 'Ungrouped params (nullity int)
1479+ => Expression commons schemas from 'Ungrouped params (nullity int)
14801480 -- ^ what to aggregate
1481− -> Expression db from ('Grouped bys) params (nullity int)
1481+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14821482bitAndDistinct = unsafeAggregateDistinct "bit_and"
14831483
14841484-- | >>> :{
14851485-- let
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)
14871487-- expression = bitOrDistinct #col
14881488-- in printSQL expression
14891489-- :}
14901490-- bit_or(DISTINCT "col")
14911491bitOrDistinct
14921492 :: int `In` PGIntegral
1493− => Expression db from 'Ungrouped params (nullity int)
1493+ => Expression commons schemas from 'Ungrouped params (nullity int)
14941494 -- ^ what to aggregate
1495− -> Expression db from ('Grouped bys) params (nullity int)
1495+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14961496bitOrDistinct = unsafeAggregateDistinct "bit_or"
14971497
14981498-- | >>> :{
14991499-- let
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)
15011501-- expression = boolAnd #col
15021502-- in printSQL expression
15031503-- :}
15041504-- bool_and("col")
15051505boolAnd
1506− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1506+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15071507 -- ^ what to aggregate
1508− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1508+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15091509boolAnd = unsafeAggregate "bool_and"
15101510
15111511-- | >>> :{
15121512-- let
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)
15141514-- expression = boolOr #col
15151515-- in printSQL expression
15161516-- :}
15171517-- bool_or("col")
15181518boolOr
1519− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1519+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15201520 -- ^ what to aggregate
1521− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1521+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15221522boolOr = unsafeAggregate "bool_or"
15231523
15241524-- | >>> :{
15251525-- let
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)
15271527-- expression = boolAndDistinct #col
15281528-- in printSQL expression
15291529-- :}
15301530-- bool_and(DISTINCT "col")
15311531boolAndDistinct
1532− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1532+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15331533 -- ^ what to aggregate
1534− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1534+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15351535boolAndDistinct = unsafeAggregateDistinct "bool_and"
15361536
15371537-- | >>> :{
15381538-- let
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)
15401540-- expression = boolOrDistinct #col
15411541-- in printSQL expression
15421542-- :}
15431543-- bool_or(DISTINCT "col")
15441544boolOrDistinct
1545− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1545+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15461546 -- ^ what to aggregate
1547− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1547+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15481548boolOrDistinct = unsafeAggregateDistinct "bool_or"
15491549
15501550-- | A special aggregation that does not require an input
@@ -1552,70 +1552,70 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
15521552-- >>> printSQL countStar
15531553-- count(*)
15541554countStar
1555− :: Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1555+ :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
15561556countStar = UnsafeExpression $ "count(*)"
15571557
15581558-- | >>> :{
15591559-- let
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)
15611561-- expression = count #col
15621562-- in printSQL expression
15631563-- :}
15641564-- count("col")
15651565count
1566− :: Expression db from 'Ungrouped params ty
1566+ :: Expression commons schemas from 'Ungrouped params ty
15671567 -- ^ what to count
1568− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1568+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
15691569count = unsafeAggregate "count"
15701570
15711571-- | >>> :{
15721572-- let
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)
15741574-- expression = countDistinct #col
15751575-- in printSQL expression
15761576-- :}
15771577-- count(DISTINCT "col")
15781578countDistinct
1579− :: Expression db from 'Ungrouped params ty
1579+ :: Expression commons schemas from 'Ungrouped params ty
15801580 -- ^ what to count
1581− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1581+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
15821582countDistinct = unsafeAggregateDistinct "count"
15831583
15841584-- | synonym for `boolAnd`
15851585--
15861586-- >>> :{
15871587-- let
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)
15891589-- expression = every #col
15901590-- in printSQL expression
15911591-- :}
15921592-- every("col")
15931593every
1594− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1594+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15951595 -- ^ what to aggregate
1596− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1596+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15971597every = unsafeAggregate "every"
15981598
15991599-- | synonym for `boolAndDistinct`
16001600--
16011601-- >>> :{
16021602-- let
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)
16041604-- expression = everyDistinct #col
16051605-- in printSQL expression
16061606-- :}
16071607-- every(DISTINCT "col")
16081608everyDistinct
1609− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1609+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
16101610 -- ^ what to aggregate
1611− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1611+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
16121612everyDistinct = unsafeAggregateDistinct "every"
16131613
16141614-- | minimum and maximum aggregation
16151615max_, min_, maxDistinct, minDistinct
1616− :: Expression db from 'Ungrouped params (nullity ty)
1616+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
16171617 -- ^ what to aggregate
1618− -> Expression db from ('Grouped bys) params (nullity ty)
1618+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
16191619max_ = unsafeAggregate "max"
16201620min_ = unsafeAggregate "min"
16211621maxDistinct = unsafeAggregateDistinct "max"