@@ -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
@@ -249,7 +250,7 @@ class KnownNat n => HasParameter
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
@@ -424,20 +425,20 @@ matchNull y f x = ifThenElse (isNull x) y
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
@@ -491,41 +492,41 @@ field
491492 , Has field row ty)
492493 => QualifiedAlias sch tydef -- ^ row type
493494 -> Alias field -- ^ field name
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 ('NotNull ('PGcomposite row))
496+ -> Expression commons schemas params grp from ty
496497field td fld expr = UnsafeExpression $
497498 parenthesized (renderSQL expr <> "::" <> renderSQL td)
498499 <> "." <> renderSQL fld
499500
500501instance Semigroup
501− (Expression db params grp from (nullity ('PGvararray ty))) where
502+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
502503 (<>) = unsafeBinaryOp "||"
503504
504505instance Monoid
505− (Expression db params grp from (nullity ('PGvararray ty))) where
506+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
506507 mempty = array []
507508 mappend = (<>)
508509
509−-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression (commons :=> schemas) '[ 'NotNull 'PGtimestamptz] grp from ('NotNull 'PGtimestamptz)
510+-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression commons schemas '[ 'NotNull 'PGtimestamptz] grp from ('NotNull 'PGtimestamptz)
510511-- >>> printSQL expr
511512-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
512513greatest
513− :: Expression db params grp from (nullty)
514+ :: Expression commons schemas params grp from (nullty)
514515 -- ^ needs at least 1 argument
515− -> [Expression db params grp from (nullty)]
516+ -> [Expression commons schemas params grp from (nullty)]
516517 -- ^ or more
517− -> Expression db params grp from (nullty)
518+ -> Expression commons schemas params grp from (nullty)
518519greatest x xs = UnsafeExpression $ "GREATEST("
519520 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
520521
521522-- | >>> printSQL $ least currentTimestamp [null_]
522523-- LEAST(CURRENT_TIMESTAMP, NULL)
523524least
524− :: Expression db params grp from (nullty)
525+ :: Expression commons schemas params grp from (nullty)
525526 -- ^ needs at least 1 argument
526− -> [Expression db params grp from (nullty)]
527+ -> [Expression commons schemas params grp from (nullty)]
527528 -- ^ or more
528− -> Expression db params grp from (nullty)
529+ -> Expression commons schemas params grp from (nullty)
529530least x xs = UnsafeExpression $ "LEAST("
530531 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
531532
@@ -534,9 +535,9 @@ least x xs = UnsafeExpression $ "LEAST("
534535unsafeBinaryOp
535536 :: ByteString
536537 -- ^ operator
537− -> Expression db params grp from (ty0)
538− -> Expression db params grp from (ty1)
539− -> Expression db params grp from (ty2)
538+ -> Expression commons schemas params grp from (ty0)
539+ -> Expression commons schemas params grp from (ty1)
540+ -> Expression commons schemas params grp from (ty2)
540541unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541542 renderSQL x <+> op <+> renderSQL y
542543
@@ -545,8 +546,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
545546unsafeUnaryOp
546547 :: ByteString
547548 -- ^ operator
548− -> Expression db params grp from (ty0)
549− -> Expression db params grp from (ty1)
549+ -> Expression commons schemas params grp from (ty0)
550+ -> Expression commons schemas params grp from (ty1)
550551unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551552 op <+> renderSQL x
552553
@@ -555,8 +556,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
555556unsafeFunction
556557 :: ByteString
557558 -- ^ function
558− -> Expression db params grp from (xty)
559− -> Expression db params grp from (yty)
559+ -> Expression commons schemas params grp from (xty)
560+ -> Expression commons schemas params grp from (yty)
560561unsafeFunction fun x = UnsafeExpression $
561562 fun <> parenthesized (renderSQL x)
562563
@@ -565,13 +566,13 @@ unsafeVariadicFunction
565566 :: SListI elems
566567 => ByteString
567568 -- ^ function
568− -> NP (Expression db params grp from) elems
569− -> Expression db params grp from ret
569+ -> NP (Expression commons schemas params grp from) elems
570+ -> Expression commons schemas params grp from ret
570571unsafeVariadicFunction fun x = UnsafeExpression $
571572 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
572573
573574instance ty `In` PGNum
574− => Num (Expression db params grp from (nullity ty)) where
575+ => Num (Expression commons schemas params grp from (nullity ty)) where
575576 (+) = unsafeBinaryOp "+"
576577 (-) = unsafeBinaryOp "-"
577578 (*) = unsafeBinaryOp "*"
@@ -583,12 +584,12 @@ instance ty `In` PGNum
583584 . show
584585
585586instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
586− (Expression db params grp from (nullity ty)) where
587+ (Expression commons schemas params grp from (nullity ty)) where
587588 (/) = unsafeBinaryOp "/"
588589 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
589590
590591instance (ty `In` PGNum, ty `In` PGFloating) => Floating
591− (Expression db params grp from (nullity ty)) where
592+ (Expression commons schemas params grp from (nullity ty)) where
592593 pi = UnsafeExpression "pi()"
593594 exp = unsafeFunction "exp"
594595 log = unsafeFunction "ln"
@@ -611,18 +612,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
611612
612613-- | >>> :{
613614-- let
614−-- expression :: Expression db params grp from (nullity 'PGfloat4)
615+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
615616-- expression = atan2_ pi 2
616617-- in printSQL expression
617618-- :}
618619-- atan2(pi(), 2)
619620atan2_
620621 :: float `In` PGFloating
621− => Expression db params grp from (nullity float)
622+ => Expression commons schemas params grp from (nullity float)
622623 -- ^ numerator
623− -> Expression db params grp from (nullity float)
624+ -> Expression commons schemas params grp from (nullity float)
624625 -- ^ denominator
625− -> Expression db params grp from (nullity float)
626+ -> Expression commons schemas params grp from (nullity float)
626627atan2_ y x = UnsafeExpression $
627628 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
628629
@@ -635,9 +636,9 @@ atan2_ y x = UnsafeExpression $
635636cast
636637 :: TypeExpression schemas ty1
637638 -- ^ type to cast as
638− -> Expression (commons :=> schemas) params grp from ty0
639+ -> Expression commons schemas params grp from ty0
639640 -- ^ value to convert
640− -> Expression (commons :=> schemas) params grp from ty1
641+ -> Expression commons schemas params grp from ty1
641642cast ty x = UnsafeExpression $ parenthesized $
642643 renderSQL x <+> "::" <+> renderSQL ty
643644
@@ -645,136 +646,136 @@ cast ty x = UnsafeExpression $ parenthesized $
645646--
646647-- >>> :{
647648-- let
648−-- expression :: Expression db params grp from (nullity 'PGint2)
649+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
649650-- expression = 5 `quot_` 2
650651-- in printSQL expression
651652-- :}
652653-- (5 / 2)
653654quot_
654655 :: int `In` PGIntegral
655− => Expression db params grp from (nullity int)
656+ => Expression commons schemas params grp from (nullity int)
656657 -- ^ numerator
657− -> Expression db params grp from (nullity int)
658+ -> Expression commons schemas params grp from (nullity int)
658659 -- ^ denominator
659− -> Expression db params grp from (nullity int)
660+ -> Expression commons schemas params grp from (nullity int)
660661quot_ = unsafeBinaryOp "/"
661662
662663-- | remainder upon integer division
663664--
664665-- >>> :{
665666-- let
666−-- expression :: Expression db params grp from (nullity 'PGint2)
667+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
667668-- expression = 5 `rem_` 2
668669-- in printSQL expression
669670-- :}
670671-- (5 % 2)
671672rem_
672673 :: int `In` PGIntegral
673− => Expression db params grp from (nullity int)
674+ => Expression commons schemas params grp from (nullity int)
674675 -- ^ numerator
675− -> Expression db params grp from (nullity int)
676+ -> Expression commons schemas params grp from (nullity int)
676677 -- ^ denominator
677− -> Expression db params grp from (nullity int)
678+ -> Expression commons schemas params grp from (nullity int)
678679rem_ = unsafeBinaryOp "%"
679680
680681-- | >>> :{
681682-- let
682−-- expression :: Expression db params grp from (nullity 'PGfloat4)
683+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
683684-- expression = trunc pi
684685-- in printSQL expression
685686-- :}
686687-- trunc(pi())
687688trunc
688689 :: frac `In` PGFloating
689− => Expression db params grp from (nullity frac)
690+ => Expression commons schemas params grp from (nullity frac)
690691 -- ^ fractional number
691− -> Expression db params grp from (nullity frac)
692+ -> Expression commons schemas params grp from (nullity frac)
692693trunc = unsafeFunction "trunc"
693694
694695-- | >>> :{
695696-- let
696−-- expression :: Expression db params grp from (nullity 'PGfloat4)
697+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
697698-- expression = round_ pi
698699-- in printSQL expression
699700-- :}
700701-- round(pi())
701702round_
702703 :: frac `In` PGFloating
703− => Expression db params grp from (nullity frac)
704+ => Expression commons schemas params grp from (nullity frac)
704705 -- ^ fractional number
705− -> Expression db params grp from (nullity frac)
706+ -> Expression commons schemas params grp from (nullity frac)
706707round_ = unsafeFunction "round"
707708
708709-- | >>> :{
709710-- let
710−-- expression :: Expression db params grp from (nullity 'PGfloat4)
711+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
711712-- expression = ceiling_ pi
712713-- in printSQL expression
713714-- :}
714715-- ceiling(pi())
715716ceiling_
716717 :: frac `In` PGFloating
717− => Expression db params grp from (nullity frac)
718+ => Expression commons schemas params grp from (nullity frac)
718719 -- ^ fractional number
719− -> Expression db params grp from (nullity frac)
720+ -> Expression commons schemas params grp from (nullity frac)
720721ceiling_ = unsafeFunction "ceiling"
721722
722723-- | A `Condition` is an `Expression`, which can evaluate
723724-- to `true`, `false` or `null_`. This is because SQL uses
724725-- a three valued logic.
725−type Condition db params grp from =
726− Expression db params grp from ('Null 'PGbool)
726+type Condition commons schemas params grp from =
727+ Expression commons schemas params grp from ('Null 'PGbool)
727728
728729-- | >>> printSQL true
729730-- TRUE
730−true :: Expression db params grp from (nullity 'PGbool)
731+true :: Expression commons schemas params grp from (nullity 'PGbool)
731732true = UnsafeExpression "TRUE"
732733
733734-- | >>> printSQL false
734735-- FALSE
735−false :: Expression db params grp from (nullity 'PGbool)
736+false :: Expression commons schemas params grp from (nullity 'PGbool)
736737false = UnsafeExpression "FALSE"
737738
738739-- | >>> printSQL $ not_ true
739740-- (NOT TRUE)
740741not_
741− :: Expression db params grp from (nullity 'PGbool)
742− -> Expression db params grp from (nullity 'PGbool)
742+ :: Expression commons schemas params grp from (nullity 'PGbool)
743+ -> Expression commons schemas params grp from (nullity 'PGbool)
743744not_ = unsafeUnaryOp "NOT"
744745
745746-- | >>> printSQL $ true .&& false
746747-- (TRUE AND FALSE)
747748(.&&)
748− :: Expression db params grp from (nullity 'PGbool)
749− -> Expression db params grp from (nullity 'PGbool)
750− -> Expression db params grp from (nullity 'PGbool)
749+ :: Expression commons schemas params grp from (nullity 'PGbool)
750+ -> Expression commons schemas params grp from (nullity 'PGbool)
751+ -> Expression commons schemas params grp from (nullity 'PGbool)
751752infixr 3 .&&
752753(.&&) = unsafeBinaryOp "AND"
753754
754755-- | >>> printSQL $ true .|| false
755756-- (TRUE OR FALSE)
756757(.||)
757− :: Expression db params grp from (nullity 'PGbool)
758− -> Expression db params grp from (nullity 'PGbool)
759− -> Expression db params grp from (nullity 'PGbool)
758+ :: Expression commons schemas params grp from (nullity 'PGbool)
759+ -> Expression commons schemas params grp from (nullity 'PGbool)
760+ -> Expression commons schemas params grp from (nullity 'PGbool)
760761infixr 2 .||
761762(.||) = unsafeBinaryOp "OR"
762763
763764-- | >>> :{
764765-- let
765−-- expression :: Expression db params grp from (nullity 'PGint2)
766+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
766767-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
767768-- in printSQL expression
768769-- :}
769770-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
770771caseWhenThenElse
771− :: [ ( Condition db params grp from
772− , Expression db params grp from ty
772+ :: [ ( Condition commons schemas params grp from
773+ , Expression commons schemas params grp from ty
773774 ) ]
774775 -- ^ whens and thens
775− -> Expression db params grp from ty
776+ -> Expression commons schemas params grp from ty
776777 -- ^ else
777− -> Expression db params grp from ty
778+ -> Expression commons schemas params grp from ty
778779caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
779780 [ "CASE"
780781 , mconcat
@@ -790,16 +791,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
790791
791792-- | >>> :{
792793-- let
793−-- expression :: Expression db params grp from (nullity 'PGint2)
794+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
794795-- expression = ifThenElse true 1 0
795796-- in printSQL expression
796797-- :}
797798-- CASE WHEN TRUE THEN 1 ELSE 0 END
798799ifThenElse
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
800+ :: Condition commons schemas params grp from
801+ -> Expression commons schemas params grp from ty -- ^ then
802+ -> Expression commons schemas params grp from ty -- ^ else
803+ -> Expression commons schemas params grp from ty
803804ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
804805
805806-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -808,85 +809,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
808809-- >>> printSQL $ true .== null_
809810-- (TRUE = NULL)
810811(.==)
811− :: Expression db params grp from (nullity0 ty) -- ^ lhs
812− -> Expression db params grp from (nullity1 ty) -- ^ rhs
813− -> Condition db params grp from
812+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
813+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
814+ -> Condition commons schemas params grp from
814815(.==) = unsafeBinaryOp "="
815816infix 4 .==
816817
817818-- | >>> printSQL $ true ./= null_
818819-- (TRUE <> NULL)
819820(./=)
820− :: Expression db params grp from (nullity0 ty) -- ^ lhs
821− -> Expression db params grp from (nullity1 ty) -- ^ rhs
822− -> Condition db params grp from
821+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
822+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
823+ -> Condition commons schemas params grp from
823824(./=) = unsafeBinaryOp "<>"
824825infix 4 ./=
825826
826827-- | >>> printSQL $ true .>= null_
827828-- (TRUE >= NULL)
828829(.>=)
829− :: Expression db params grp from (nullity0 ty) -- ^ lhs
830− -> Expression db params grp from (nullity1 ty) -- ^ rhs
831− -> Condition db params grp from
830+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
831+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
832+ -> Condition commons schemas params grp from
832833(.>=) = unsafeBinaryOp ">="
833834infix 4 .>=
834835
835836-- | >>> printSQL $ true .< null_
836837-- (TRUE < NULL)
837838(.<)
838− :: Expression db params grp from (nullity0 ty) -- ^ lhs
839− -> Expression db params grp from (nullity1 ty) -- ^ rhs
840− -> Condition db params grp from
839+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
840+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
841+ -> Condition commons schemas params grp from
841842(.<) = unsafeBinaryOp "<"
842843infix 4 .<
843844
844845-- | >>> printSQL $ true .<= null_
845846-- (TRUE <= NULL)
846847(.<=)
847− :: Expression db params grp from (nullity0 ty) -- ^ lhs
848− -> Expression db params grp from (nullity1 ty) -- ^ rhs
849− -> Condition db params grp from
848+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
849+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
850+ -> Condition commons schemas params grp from
850851(.<=) = unsafeBinaryOp "<="
851852infix 4 .<=
852853
853854-- | >>> printSQL $ true .> null_
854855-- (TRUE > NULL)
855856(.>)
856− :: Expression db params grp from (nullity0 ty) -- ^ lhs
857− -> Expression db params grp from (nullity1 ty) -- ^ rhs
858− -> Condition db params grp from
857+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
858+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
859+ -> Condition commons schemas params grp from
859860(.>) = unsafeBinaryOp ">"
860861infix 4 .>
861862
862863-- | >>> printSQL currentDate
863864-- CURRENT_DATE
864865currentDate
865− :: Expression db params grp from (nullity 'PGdate)
866+ :: Expression commons schemas params grp from (nullity 'PGdate)
866867currentDate = UnsafeExpression "CURRENT_DATE"
867868
868869-- | >>> printSQL currentTime
869870-- CURRENT_TIME
870871currentTime
871− :: Expression db params grp from (nullity 'PGtimetz)
872+ :: Expression commons schemas params grp from (nullity 'PGtimetz)
872873currentTime = UnsafeExpression "CURRENT_TIME"
873874
874875-- | >>> printSQL currentTimestamp
875876-- CURRENT_TIMESTAMP
876877currentTimestamp
877− :: Expression db params grp from (nullity 'PGtimestamptz)
878+ :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
878879currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
879880
880881-- | >>> printSQL localTime
881882-- LOCALTIME
882883localTime
883− :: Expression db params grp from (nullity 'PGtime)
884+ :: Expression commons schemas params grp from (nullity 'PGtime)
884885localTime = UnsafeExpression "LOCALTIME"
885886
886887-- | >>> printSQL localTimestamp
887888-- LOCALTIMESTAMP
888889localTimestamp
889− :: Expression db params grp from (nullity 'PGtimestamp)
890+ :: Expression commons schemas params grp from (nullity 'PGtimestamp)
890891localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
891892
892893{-----------------------------------------
@@ -894,7 +895,7 @@ text
894895-----------------------------------------}
895896
896897instance IsString
897− (Expression db params grp from (nullity 'PGtext)) where
898+ (Expression commons schemas params grp from (nullity 'PGtext)) where
898899 fromString str = UnsafeExpression $
899900 "E\'" <> fromString (escape =<< str) <> "\'"
900901 where
@@ -910,36 +911,36 @@ instance IsString
910911 c -> [c]
911912
912913instance Semigroup
913− (Expression db params grp from (nullity 'PGtext)) where
914+ (Expression commons schemas params grp from (nullity 'PGtext)) where
914915 (<>) = unsafeBinaryOp "||"
915916
916917instance Monoid
917− (Expression db params grp from (nullity 'PGtext)) where
918+ (Expression commons schemas params grp from (nullity 'PGtext)) where
918919 mempty = fromString ""
919920 mappend = (<>)
920921
921922-- | >>> printSQL $ lower "ARRRGGG"
922923-- lower(E'ARRRGGG')
923924lower
924− :: Expression db params grp from (nullity 'PGtext)
925+ :: Expression commons schemas params grp from (nullity 'PGtext)
925926 -- ^ string to lower case
926− -> Expression db params grp from (nullity 'PGtext)
927+ -> Expression commons schemas params grp from (nullity 'PGtext)
927928lower = unsafeFunction "lower"
928929
929930-- | >>> printSQL $ upper "eeee"
930931-- upper(E'eeee')
931932upper
932− :: Expression db params grp from (nullity 'PGtext)
933+ :: Expression commons schemas params grp from (nullity 'PGtext)
933934 -- ^ string to upper case
934− -> Expression db params grp from (nullity 'PGtext)
935+ -> Expression commons schemas params grp from (nullity 'PGtext)
935936upper = unsafeFunction "upper"
936937
937938-- | >>> printSQL $ charLength "four"
938939-- char_length(E'four')
939940charLength
940− :: Expression db params grp from (nullity 'PGtext)
941+ :: Expression commons schemas params grp from (nullity 'PGtext)
941942 -- ^ string to measure
942− -> Expression db params grp from (nullity 'PGint4)
943+ -> Expression commons schemas params grp from (nullity 'PGint4)
943944charLength = unsafeFunction "char_length"
944945
945946-- | The `like` expression returns true if the @string@ matches
@@ -952,11 +953,11 @@ charLength = unsafeFunction "char_length"
952953-- >>> printSQL $ "abc" `like` "a%"
953954-- (E'abc' LIKE E'a%')
954955like
955− :: Expression db params grp from (nullity 'PGtext)
956+ :: Expression commons schemas params grp from (nullity 'PGtext)
956957 -- ^ string
957− -> Expression db params grp from (nullity 'PGtext)
958+ -> Expression commons schemas params grp from (nullity 'PGtext)
958959 -- ^ pattern
959− -> Expression db params grp from (nullity 'PGbool)
960+ -> Expression commons schemas params grp from (nullity 'PGbool)
960961like = unsafeBinaryOp "LIKE"
961962
962963-- | The key word ILIKE can be used instead of LIKE to make the
@@ -965,11 +966,11 @@ like = unsafeBinaryOp "LIKE"
965966-- >>> printSQL $ "abc" `ilike` "a%"
966967-- (E'abc' ILIKE E'a%')
967968ilike
968− :: Expression db params grp from (nullity 'PGtext)
969+ :: Expression commons schemas params grp from (nullity 'PGtext)
969970 -- ^ string
970− -> Expression db params grp from (nullity 'PGtext)
971+ -> Expression commons schemas params grp from (nullity 'PGtext)
971972 -- ^ pattern
972− -> Expression db params grp from (nullity 'PGbool)
973+ -> Expression commons schemas params grp from (nullity 'PGbool)
973974ilike = unsafeBinaryOp "ILIKE"
974975
975976{-----------------------------------------
@@ -984,36 +985,36 @@ Table 9.44: json and jsonb operators
984985-- | Get JSON value (object field or array element) at a key.
985986(.->)
986987 :: (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)
988+ => Expression commons schemas params grp from (nullity json)
989+ -> Expression commons schemas params grp from (nullity key)
990+ -> Expression commons schemas params grp from ('Null json)
990991infixl 8 .->
991992(.->) = unsafeBinaryOp "->"
992993
993994-- | Get JSON value (object field or array element) at a key, as text.
994995(.->>)
995996 :: (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)
997+ => Expression commons schemas params grp from (nullity json)
998+ -> Expression commons schemas params grp from (nullity key)
999+ -> Expression commons schemas params grp from ('Null 'PGtext)
9991000infixl 8 .->>
10001001(.->>) = unsafeBinaryOp "->>"
10011002
10021003-- | Get JSON value at a specified path.
10031004(.#>)
10041005 :: (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)
1006+ => Expression commons schemas params grp from (nullity json)
1007+ -> Expression commons schemas params grp from (nullity path)
1008+ -> Expression commons schemas params grp from ('Null json)
10081009infixl 8 .#>
10091010(.#>) = unsafeBinaryOp "#>"
10101011
10111012-- | Get JSON value at a specified path as text.
10121013(.#>>)
10131014 :: (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)
1015+ => Expression commons schemas params grp from (nullity json)
1016+ -> Expression commons schemas params grp from (nullity path)
1017+ -> Expression commons schemas params grp from ('Null 'PGtext)
10171018infixl 8 .#>>
10181019(.#>>) = unsafeBinaryOp "#>>"
10191020
@@ -1022,48 +1023,48 @@ infixl 8 .#>>
10221023-- | Does the left JSON value contain the right JSON path/value entries at the
10231024-- top level?
10241025(.@>)
1025− :: Expression db params grp from (nullity 'PGjsonb)
1026− -> Expression db params grp from (nullity 'PGjsonb)
1027− -> Condition db params grp from
1026+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1027+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1028+ -> Condition commons schemas params grp from
10281029infixl 9 .@>
10291030(.@>) = unsafeBinaryOp "@>"
10301031
10311032-- | Are the left JSON path/value entries contained at the top level within the
10321033-- right JSON value?
10331034(.<@)
1034− :: Expression db params grp from (nullity 'PGjsonb)
1035− -> Expression db params grp from (nullity 'PGjsonb)
1036− -> Condition db params grp from
1035+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1036+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1037+ -> Condition commons schemas params grp from
10371038infixl 9 .<@
10381039(.<@) = unsafeBinaryOp "<@"
10391040
10401041-- | Does the string exist as a top-level key within the JSON value?
10411042(.?)
1042− :: Expression db params grp from (nullity 'PGjsonb)
1043− -> Expression db params grp from (nullity 'PGtext)
1044− -> Condition db params grp from
1043+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1044+ -> Expression commons schemas params grp from (nullity 'PGtext)
1045+ -> Condition commons schemas params grp from
10451046infixl 9 .?
10461047(.?) = unsafeBinaryOp "?"
10471048
10481049-- | Do any of these array strings exist as top-level keys?
10491050(.?|)
1050− :: Expression db params grp from (nullity 'PGjsonb)
1051− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1052− -> Condition db params grp from
1051+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1052+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1053+ -> Condition commons schemas params grp from
10531054infixl 9 .?|
10541055(.?|) = unsafeBinaryOp "?|"
10551056
10561057-- | Do all of these array strings exist as top-level keys?
10571058(.?&)
1058− :: Expression db params grp from (nullity 'PGjsonb)
1059− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1060− -> Condition db params grp from
1059+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1060+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1061+ -> Condition commons schemas params grp from
10611062infixl 9 .?&
10621063(.?&) = unsafeBinaryOp "?&"
10631064
10641065-- | Concatenate two jsonb values into a new jsonb value.
10651066instance
1066− Semigroup (Expression db from grouping param (nullity 'PGjsonb)) where
1067+ Semigroup (Expression commons schemas from grouping param (nullity 'PGjsonb)) where
10671068 (<>) = unsafeBinaryOp "||"
10681069
10691070-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1080,9 +1081,9 @@ instance
10801081-- count from the end). Throws an error if top level container is not an array.
10811082(.-.)
10821083 :: (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)
1084+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1085+ -> Expression commons schemas params grp from (nullity key)
1086+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
10861087infixl 6 .-.
10871088(.-.) = unsafeBinaryOp "-"
10881089
@@ -1090,9 +1091,9 @@ infixl 6 .-.
10901091-- integers count from the end)
10911092(#-.)
10921093 :: 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)
1094+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1095+ -> Expression commons schemas params grp from (nullity arrayty)
1096+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
10961097infixl 6 #-.
10971098(#-.) = unsafeBinaryOp "#-"
10981099
@@ -1103,14 +1104,14 @@ Table 9.45: JSON creation functions
11031104-- | Literal binary JSON
11041105jsonbLit
11051106 :: JSON.ToJSON x
1106− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjsonb)
1107+ => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
11071108jsonbLit = cast jsonb . UnsafeExpression
11081109 . singleQuotedUtf8 . toStrict . JSON.encode
11091110
11101111-- | Literal JSON
11111112jsonLit
11121113 :: JSON.ToJSON x
1113− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjson)
1114+ => x -> Expression commons schemas params grp from (nullity 'PGjson)
11141115jsonLit = cast json . UnsafeExpression
11151116 . singleQuotedUtf8 . toStrict . JSON.encode
11161117
@@ -1121,8 +1122,8 @@ jsonLit = cast json . UnsafeExpression
11211122-- number, a Boolean, or a null value, the text representation will be used, in
11221123-- such a fashion that it is a valid json value.
11231124toJson
1124− :: Expression db params grp from (nullity ty)
1125− -> Expression db params grp from (nullity 'PGjson)
1125+ :: Expression commons schemas params grp from (nullity ty)
1126+ -> Expression commons schemas params grp from (nullity 'PGjson)
11261127toJson = unsafeFunction "to_json"
11271128
11281129-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1132,43 +1133,43 @@ toJson = unsafeFunction "to_json"
11321133-- number, a Boolean, or a null value, the text representation will be used, in
11331134-- such a fashion that it is a valid jsonb value.
11341135toJsonb
1135− :: Expression db params grp from (nullity ty)
1136− -> Expression db params grp from (nullity 'PGjsonb)
1136+ :: Expression commons schemas params grp from (nullity ty)
1137+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
11371138toJsonb = unsafeFunction "to_jsonb"
11381139
11391140-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
11401141-- becomes a JSON array of arrays.
11411142arrayToJson
11421143 :: PGArray "arrayToJson" arr
1143− => Expression db params grp from (nullity arr)
1144− -> Expression db params grp from (nullity 'PGjson)
1144+ => Expression commons schemas params grp from (nullity arr)
1145+ -> Expression commons schemas params grp from (nullity 'PGjson)
11451146arrayToJson = unsafeFunction "array_to_json"
11461147
11471148-- | Returns the row as a JSON object.
11481149rowToJson
1149− :: Expression db params grp from (nullity ('PGcomposite ty))
1150− -> Expression db params grp from (nullity 'PGjson)
1150+ :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1151+ -> Expression commons schemas params grp from (nullity 'PGjson)
11511152rowToJson = unsafeFunction "row_to_json"
11521153
11531154-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
11541155-- argument list.
11551156jsonBuildArray
11561157 :: SListI elems
1157− => NP (Expression db params grp from) elems
1158− -> Expression db params grp from (nullity 'PGjson)
1158+ => NP (Expression commons schemas params grp from) elems
1159+ -> Expression commons schemas params grp from (nullity 'PGjson)
11591160jsonBuildArray = unsafeVariadicFunction "json_build_array"
11601161
11611162-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
11621163-- variadic argument list.
11631164jsonbBuildArray
11641165 :: SListI elems
1165− => NP (Expression db params grp from) elems
1166− -> Expression db params grp from (nullity 'PGjsonb)
1166+ => NP (Expression commons schemas params grp from) elems
1167+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
11671168jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
11681169
11691170unsafeRowFunction
11701171 :: All Top elems
1171− => NP (Aliased (Expression db params grp from)) elems
1172+ => NP (Aliased (Expression commons schemas params grp from)) elems
11721173 -> [ByteString]
11731174unsafeRowFunction =
11741175 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1183,8 +1184,8 @@ unsafeRowFunction =
11831184-- and values.
11841185jsonBuildObject
11851186 :: All Top elems
1186− => NP (Aliased (Expression db params grp from)) elems
1187− -> Expression db params grp from (nullity 'PGjson)
1187+ => NP (Aliased (Expression commons schemas params grp from)) elems
1188+ -> Expression commons schemas params grp from (nullity 'PGjson)
11881189jsonBuildObject
11891190 = unsafeFunction "json_build_object"
11901191 . UnsafeExpression
@@ -1196,8 +1197,8 @@ jsonBuildObject
11961197-- between text and values.
11971198jsonbBuildObject
11981199 :: All Top elems
1199− => NP (Aliased (Expression db params grp from)) elems
1200− -> Expression db params grp from (nullity 'PGjsonb)
1200+ => NP (Aliased (Expression commons schemas params grp from)) elems
1201+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12011202jsonbBuildObject
12021203 = unsafeFunction "jsonb_build_object"
12031204 . UnsafeExpression
@@ -1210,8 +1211,8 @@ jsonbBuildObject
12101211-- array has exactly two elements, which are taken as a key/value pair.
12111212jsonObject
12121213 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1213− => Expression db params grp from (nullity arr)
1214− -> Expression db params grp from (nullity 'PGjson)
1214+ => Expression commons schemas params grp from (nullity arr)
1215+ -> Expression commons schemas params grp from (nullity 'PGjson)
12151216jsonObject = unsafeFunction "json_object"
12161217
12171218-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1220,8 +1221,8 @@ jsonObject = unsafeFunction "json_object"
12201221-- array has exactly two elements, which are taken as a key/value pair.
12211222jsonbObject
12221223 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1223− => Expression db params grp from (nullity arr)
1224− -> Expression db params grp from (nullity 'PGjsonb)
1224+ => Expression commons schemas params grp from (nullity arr)
1225+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12251226jsonbObject = unsafeFunction "jsonb_object"
12261227
12271228-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1229,9 +1230,9 @@ jsonbObject = unsafeFunction "jsonb_object"
12291230jsonZipObject
12301231 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
12311232 , 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)
1233+ => Expression commons schemas params grp from (nullity keysArray)
1234+ -> Expression commons schemas params grp from (nullity valuesArray)
1235+ -> Expression commons schemas params grp from (nullity 'PGjson)
12351236jsonZipObject ks vs =
12361237 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
12371238
@@ -1241,9 +1242,9 @@ jsonZipObject ks vs =
12411242jsonbZipObject
12421243 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
12431244 , 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)
1245+ => Expression commons schemas params grp from (nullity keysArray)
1246+ -> Expression commons schemas params grp from (nullity valuesArray)
1247+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12471248jsonbZipObject ks vs =
12481249 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
12491250
@@ -1253,23 +1254,23 @@ Table 9.46: JSON processing functions
12531254
12541255-- | Returns the number of elements in the outermost JSON array.
12551256jsonArrayLength
1256− :: Expression db params grp from (nullity 'PGjson)
1257− -> Expression db params grp from (nullity 'PGint4)
1257+ :: Expression commons schemas params grp from (nullity 'PGjson)
1258+ -> Expression commons schemas params grp from (nullity 'PGint4)
12581259jsonArrayLength = unsafeFunction "json_array_length"
12591260
12601261-- | Returns the number of elements in the outermost binary JSON array.
12611262jsonbArrayLength
1262− :: Expression db params grp from (nullity 'PGjsonb)
1263− -> Expression db params grp from (nullity 'PGint4)
1263+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1264+ -> Expression commons schemas params grp from (nullity 'PGint4)
12641265jsonbArrayLength = unsafeFunction "jsonb_array_length"
12651266
12661267-- | Returns JSON value pointed to by the given path (equivalent to #>
12671268-- operator).
12681269jsonExtractPath
12691270 :: 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)
1271+ => Expression commons schemas params grp from (nullity 'PGjson)
1272+ -> NP (Expression commons schemas params grp from) elems
1273+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12731274jsonExtractPath x xs =
12741275 unsafeVariadicFunction "json_extract_path" (x :* xs)
12751276
@@ -1277,9 +1278,9 @@ jsonExtractPath x xs =
12771278-- operator).
12781279jsonbExtractPath
12791280 :: 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)
1281+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1282+ -> NP (Expression commons schemas params grp from) elems
1283+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
12831284jsonbExtractPath x xs =
12841285 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
12851286
@@ -1287,9 +1288,9 @@ jsonbExtractPath x xs =
12871288-- operator), as text.
12881289jsonExtractPathAsText
12891290 :: 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)
1291+ => Expression commons schemas params grp from (nullity 'PGjson)
1292+ -> NP (Expression commons schemas params grp from) elems
1293+ -> Expression commons schemas params grp from (nullity 'PGjson)
12931294jsonExtractPathAsText x xs =
12941295 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
12951296
@@ -1297,38 +1298,38 @@ jsonExtractPathAsText x xs =
12971298-- operator), as text.
12981299jsonbExtractPathAsText
12991300 :: 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)
1301+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1302+ -> NP (Expression commons schemas params grp from) elems
1303+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13031304jsonbExtractPathAsText x xs =
13041305 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
13051306
13061307-- | Returns the type of the outermost JSON value as a text string. Possible
13071308-- types are object, array, string, number, boolean, and null.
13081309jsonTypeof
1309− :: Expression db params grp from (nullity 'PGjson)
1310− -> Expression db params grp from (nullity 'PGtext)
1310+ :: Expression commons schemas params grp from (nullity 'PGjson)
1311+ -> Expression commons schemas params grp from (nullity 'PGtext)
13111312jsonTypeof = unsafeFunction "json_typeof"
13121313
13131314-- | Returns the type of the outermost binary JSON value as a text string.
13141315-- Possible types are object, array, string, number, boolean, and null.
13151316jsonbTypeof
1316− :: Expression db params grp from (nullity 'PGjsonb)
1317− -> Expression db params grp from (nullity 'PGtext)
1317+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1318+ -> Expression commons schemas params grp from (nullity 'PGtext)
13181319jsonbTypeof = unsafeFunction "jsonb_typeof"
13191320
13201321-- | Returns its argument with all object fields that have null values omitted.
13211322-- Other null values are untouched.
13221323jsonStripNulls
1323− :: Expression db params grp from (nullity 'PGjson)
1324− -> Expression db params grp from (nullity 'PGjson)
1324+ :: Expression commons schemas params grp from (nullity 'PGjson)
1325+ -> Expression commons schemas params grp from (nullity 'PGjson)
13251326jsonStripNulls = unsafeFunction "json_strip_nulls"
13261327
13271328-- | Returns its argument with all object fields that have null values omitted.
13281329-- Other null values are untouched.
13291330jsonbStripNulls
1330− :: Expression db params grp from (nullity 'PGjsonb)
1331− -> Expression db params grp from (nullity 'PGjsonb)
1331+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1332+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13321333jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
13331334
13341335-- | @ jsonbSet target path new_value create_missing @
@@ -1340,11 +1341,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
13401341-- arrays.
13411342jsonbSet
13421343 :: 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)
1344+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1345+ -> Expression commons schemas params grp from (nullity arr)
1346+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1347+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1348+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13481349jsonbSet tgt path val createMissing = case createMissing of
13491350 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
13501351 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1359,19 +1360,19 @@ jsonbSet tgt path val createMissing = case createMissing of
13591360-- in path count from the end of JSON arrays.
13601361jsonbInsert
13611362 :: 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)
1363+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1364+ -> Expression commons schemas params grp from (nullity arr)
1365+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1366+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1367+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
13671368jsonbInsert tgt path val insertAfter = case insertAfter of
13681369 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
13691370 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
13701371
13711372-- | Returns its argument as indented JSON text.
13721373jsonbPretty
1373− :: Expression db params grp from (nullity 'PGjsonb)
1374− -> Expression db params grp from (nullity 'PGtext)
1374+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1375+ -> Expression commons schemas params grp from (nullity 'PGtext)
13751376jsonbPretty = unsafeFunction "jsonb_pretty"
13761377
13771378{-----------------------------------------
@@ -1381,54 +1382,54 @@ aggregation
13811382-- | escape hatch to define aggregate functions
13821383unsafeAggregate
13831384 :: ByteString -- ^ aggregate function
1384− -> Expression db from 'Ungrouped params (xty)
1385− -> Expression db from ('Grouped bys) params (yty)
1385+ -> Expression commons schemas from 'Ungrouped params (xty)
1386+ -> Expression commons schemas from ('Grouped bys) params (yty)
13861387unsafeAggregate fun x = UnsafeExpression $ mconcat
13871388 [fun, "(", renderSQL x, ")"]
13881389
13891390-- | escape hatch to define aggregate functions over distinct values
13901391unsafeAggregateDistinct
13911392 :: ByteString -- ^ aggregate function
1392− -> Expression db from 'Ungrouped params (xty)
1393− -> Expression db from ('Grouped bys) params (yty)
1393+ -> Expression commons schemas from 'Ungrouped params (xty)
1394+ -> Expression commons schemas from ('Grouped bys) params (yty)
13941395unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
13951396 [fun, "(DISTINCT ", renderSQL x, ")"]
13961397
13971398-- | >>> :{
13981399-- let
1399−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1400+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
14001401-- expression = sum_ #col
14011402-- in printSQL expression
14021403-- :}
14031404-- sum("col")
14041405sum_
14051406 :: ty `In` PGNum
1406− => Expression db from 'Ungrouped params (nullity ty)
1407+ => Expression commons schemas from 'Ungrouped params (nullity ty)
14071408 -- ^ what to sum
1408− -> Expression db from ('Grouped bys) params (nullity ty)
1409+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
14091410sum_ = unsafeAggregate "sum"
14101411
14111412-- | >>> :{
14121413-- let
1413−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1414+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
14141415-- expression = sumDistinct #col
14151416-- in printSQL expression
14161417-- :}
14171418-- sum(DISTINCT "col")
14181419sumDistinct
14191420 :: ty `In` PGNum
1420− => Expression db from 'Ungrouped params (nullity ty)
1421+ => Expression commons schemas from 'Ungrouped params (nullity ty)
14211422 -- ^ what to sum
1422− -> Expression db from ('Grouped bys) params (nullity ty)
1423+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
14231424sumDistinct = unsafeAggregateDistinct "sum"
14241425
14251426-- | A constraint for `PGType`s that you can take averages of and the resulting
14261427-- `PGType`.
14271428class PGAvg ty avg | ty -> avg where
14281429 avg, avgDistinct
1429− :: Expression db from 'Ungrouped params (nullity ty)
1430+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
14301431 -- ^ what to average
1431− -> Expression db from ('Grouped bys) params (nullity avg)
1432+ -> Expression commons schemas from ('Grouped bys) params (nullity avg)
14321433 avg = unsafeAggregate "avg"
14331434 avgDistinct = unsafeAggregateDistinct "avg"
14341435instance PGAvg 'PGint2 'PGnumeric
@@ -1441,110 +1442,110 @@ instance PGAvg 'PGinterval 'PGinterval
14411442
14421443-- | >>> :{
14431444-- let
1444−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1445+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
14451446-- expression = bitAnd #col
14461447-- in printSQL expression
14471448-- :}
14481449-- bit_and("col")
14491450bitAnd
14501451 :: int `In` PGIntegral
1451− => Expression db from 'Ungrouped params (nullity int)
1452+ => Expression commons schemas from 'Ungrouped params (nullity int)
14521453 -- ^ what to aggregate
1453− -> Expression db from ('Grouped bys) params (nullity int)
1454+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14541455bitAnd = unsafeAggregate "bit_and"
14551456
14561457-- | >>> :{
14571458-- let
1458−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1459+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
14591460-- expression = bitOr #col
14601461-- in printSQL expression
14611462-- :}
14621463-- bit_or("col")
14631464bitOr
14641465 :: int `In` PGIntegral
1465− => Expression db from 'Ungrouped params (nullity int)
1466+ => Expression commons schemas from 'Ungrouped params (nullity int)
14661467 -- ^ what to aggregate
1467− -> Expression db from ('Grouped bys) params (nullity int)
1468+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14681469bitOr = unsafeAggregate "bit_or"
14691470
14701471-- | >>> :{
14711472-- let
1472−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1473+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
14731474-- expression = bitAndDistinct #col
14741475-- in printSQL expression
14751476-- :}
14761477-- bit_and(DISTINCT "col")
14771478bitAndDistinct
14781479 :: int `In` PGIntegral
1479− => Expression db from 'Ungrouped params (nullity int)
1480+ => Expression commons schemas from 'Ungrouped params (nullity int)
14801481 -- ^ what to aggregate
1481− -> Expression db from ('Grouped bys) params (nullity int)
1482+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14821483bitAndDistinct = unsafeAggregateDistinct "bit_and"
14831484
14841485-- | >>> :{
14851486-- let
1486−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1487+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
14871488-- expression = bitOrDistinct #col
14881489-- in printSQL expression
14891490-- :}
14901491-- bit_or(DISTINCT "col")
14911492bitOrDistinct
14921493 :: int `In` PGIntegral
1493− => Expression db from 'Ungrouped params (nullity int)
1494+ => Expression commons schemas from 'Ungrouped params (nullity int)
14941495 -- ^ what to aggregate
1495− -> Expression db from ('Grouped bys) params (nullity int)
1496+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
14961497bitOrDistinct = unsafeAggregateDistinct "bit_or"
14971498
14981499-- | >>> :{
14991500-- let
1500−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1501+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
15011502-- expression = boolAnd #col
15021503-- in printSQL expression
15031504-- :}
15041505-- bool_and("col")
15051506boolAnd
1506− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1507+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15071508 -- ^ what to aggregate
1508− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1509+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15091510boolAnd = unsafeAggregate "bool_and"
15101511
15111512-- | >>> :{
15121513-- let
1513−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1514+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
15141515-- expression = boolOr #col
15151516-- in printSQL expression
15161517-- :}
15171518-- bool_or("col")
15181519boolOr
1519− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1520+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15201521 -- ^ what to aggregate
1521− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1522+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15221523boolOr = unsafeAggregate "bool_or"
15231524
15241525-- | >>> :{
15251526-- let
1526−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1527+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
15271528-- expression = boolAndDistinct #col
15281529-- in printSQL expression
15291530-- :}
15301531-- bool_and(DISTINCT "col")
15311532boolAndDistinct
1532− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1533+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15331534 -- ^ what to aggregate
1534− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1535+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15351536boolAndDistinct = unsafeAggregateDistinct "bool_and"
15361537
15371538-- | >>> :{
15381539-- let
1539−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1540+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
15401541-- expression = boolOrDistinct #col
15411542-- in printSQL expression
15421543-- :}
15431544-- bool_or(DISTINCT "col")
15441545boolOrDistinct
1545− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1546+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15461547 -- ^ what to aggregate
1547− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1548+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15481549boolOrDistinct = unsafeAggregateDistinct "bool_or"
15491550
15501551-- | A special aggregation that does not require an input
@@ -1552,70 +1553,70 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
15521553-- >>> printSQL countStar
15531554-- count(*)
15541555countStar
1555− :: Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1556+ :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
15561557countStar = UnsafeExpression $ "count(*)"
15571558
15581559-- | >>> :{
15591560-- let
1560−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1561+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
15611562-- expression = count #col
15621563-- in printSQL expression
15631564-- :}
15641565-- count("col")
15651566count
1566− :: Expression db from 'Ungrouped params ty
1567+ :: Expression commons schemas from 'Ungrouped params ty
15671568 -- ^ what to count
1568− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1569+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
15691570count = unsafeAggregate "count"
15701571
15711572-- | >>> :{
15721573-- let
1573−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1574+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
15741575-- expression = countDistinct #col
15751576-- in printSQL expression
15761577-- :}
15771578-- count(DISTINCT "col")
15781579countDistinct
1579− :: Expression db from 'Ungrouped params ty
1580+ :: Expression commons schemas from 'Ungrouped params ty
15801581 -- ^ what to count
1581− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1582+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
15821583countDistinct = unsafeAggregateDistinct "count"
15831584
15841585-- | synonym for `boolAnd`
15851586--
15861587-- >>> :{
15871588-- let
1588−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1589+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
15891590-- expression = every #col
15901591-- in printSQL expression
15911592-- :}
15921593-- every("col")
15931594every
1594− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1595+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
15951596 -- ^ what to aggregate
1596− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1597+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
15971598every = unsafeAggregate "every"
15981599
15991600-- | synonym for `boolAndDistinct`
16001601--
16011602-- >>> :{
16021603-- let
1603−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1604+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
16041605-- expression = everyDistinct #col
16051606-- in printSQL expression
16061607-- :}
16071608-- every(DISTINCT "col")
16081609everyDistinct
1609− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1610+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
16101611 -- ^ what to aggregate
1611− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1612+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
16121613everyDistinct = unsafeAggregateDistinct "every"
16131614
16141615-- | minimum and maximum aggregation
16151616max_, min_, maxDistinct, minDistinct
1616− :: Expression db from 'Ungrouped params (nullity ty)
1617+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
16171618 -- ^ what to aggregate
1618− -> Expression db from ('Grouped bys) params (nullity ty)
1619+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
16191620max_ = unsafeAggregate "max"
16201621min_ = unsafeAggregate "min"
16211622maxDistinct = unsafeAggregateDistinct "max"