@@ -217,14 +217,14 @@ and other operations.
217217-}
218218newtype Expression
219219 (schema :: SchemaType)
220− (relations :: RelationsType)
220+ (from :: FromType)
221221 (grouping :: Grouping)
222222 (params :: [NullityType])
223223 (ty :: NullityType)
224224 = UnsafeExpression { renderExpression :: ByteString }
225225 deriving (GHC.Generic,Show,Eq,Ord,NFData)
226226
227−instance RenderSQL (Expression schema relations grouping params ty) where
227+instance RenderSQL (Expression schema from grouping params ty) where
228228 renderSQL = renderExpression
229229
230230{- | A `HasParameter` constraint is used to indicate a value that is
@@ -248,7 +248,7 @@ class KnownNat n => HasParameter
248248 -- ($1 :: int4)
249249 parameter
250250 :: TypeExpression schema ty
251− -> Expression schema relations grouping params ty
251+ -> Expression schema from grouping params ty
252252 parameter ty = UnsafeExpression $ parenthesized $
253253 "$" <> renderNat @n <+> "::"
254254 <+> renderTypeExpression ty
@@ -263,82 +263,82 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
263263-- >>> printSQL expr
264264-- ($1 :: int4)
265265param
266− :: forall n schema params relations grouping ty
266+ :: forall n schema params from grouping ty
267267 . (PGTyped schema ty, HasParameter n schema params ty)
268− => Expression schema relations grouping params ty -- ^ param
268+ => Expression schema from grouping params ty -- ^ param
269269param = parameter @n pgtype
270270
271−instance (HasUnique relation relations columns, Has column columns ty)
272− => IsLabel column (Expression schema relations 'Ungrouped params ty) where
271+instance (HasUnique relation from columns, Has column columns ty)
272+ => IsLabel column (Expression schema from 'Ungrouped params ty) where
273273 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
274−instance (HasUnique relation relations columns, Has column columns ty)
274+instance (HasUnique relation from columns, Has column columns ty)
275275 => IsLabel column
276− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
276+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
277277 fromLabel = fromLabel @column `As` Alias @column
278−instance (HasUnique relation relations columns, Has column columns ty)
278+instance (HasUnique relation from columns, Has column columns ty)
279279 => IsLabel column
280− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
280+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
281281 fromLabel = fromLabel @column :* Nil
282282
283−instance (Has relation relations columns, Has column columns ty)
284− => IsQualified relation column (Expression schema relations 'Ungrouped params ty) where
283+instance (Has relation from columns, Has column columns ty)
284+ => IsQualified relation column (Expression schema from 'Ungrouped params ty) where
285285 relation ! column = UnsafeExpression $
286286 renderAlias relation <> "." <> renderAlias column
287−instance (Has relation relations columns, Has column columns ty)
287+instance (Has relation from columns, Has column columns ty)
288288 => IsQualified relation column
289− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
289+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
290290 relation ! column = relation ! column `As` column
291−instance (Has relation relations columns, Has column columns ty)
291+instance (Has relation from columns, Has column columns ty)
292292 => IsQualified relation column
293− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
293+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
294294 relation ! column = relation ! column :* Nil
295295
296296instance
297− ( HasUnique relation relations columns
297+ ( HasUnique relation from columns
298298 , Has column columns ty
299299 , GroupedBy relation column bys
300300 ) => IsLabel column
301− (Expression schema relations ('Grouped bys) params ty) where
301+ (Expression schema from ('Grouped bys) params ty) where
302302 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
303303instance
304− ( HasUnique relation relations columns
304+ ( HasUnique relation from columns
305305 , Has column columns ty
306306 , GroupedBy relation column bys
307307 ) => IsLabel column
308− ( Aliased (Expression schema relations ('Grouped bys) params)
308+ ( Aliased (Expression schema from ('Grouped bys) params)
309309 (column ::: ty) ) where
310310 fromLabel = fromLabel @column `As` Alias @column
311311instance
312− ( HasUnique relation relations columns
312+ ( HasUnique relation from columns
313313 , Has column columns ty
314314 , GroupedBy relation column bys
315315 ) => IsLabel column
316− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
316+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
317317 '[column ::: ty] ) where
318318 fromLabel = fromLabel @column :* Nil
319319
320320instance
321− ( Has relation relations columns
321+ ( Has relation from columns
322322 , Has column columns ty
323323 , GroupedBy relation column bys
324324 ) => IsQualified relation column
325− (Expression schema relations ('Grouped bys) params ty) where
325+ (Expression schema from ('Grouped bys) params ty) where
326326 relation ! column = UnsafeExpression $
327327 renderAlias relation <> "." <> renderAlias column
328328instance
329− ( Has relation relations columns
329+ ( Has relation from columns
330330 , Has column columns ty
331331 , GroupedBy relation column bys
332332 ) => IsQualified relation column
333− (Aliased (Expression schema relations ('Grouped bys) params)
333+ (Aliased (Expression schema from ('Grouped bys) params)
334334 (column ::: ty)) where
335335 relation ! column = relation ! column `As` column
336336instance
337− ( Has relation relations columns
337+ ( Has relation from columns
338338 , Has column columns ty
339339 , GroupedBy relation column bys
340340 ) => IsQualified relation column
341− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
341+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
342342 '[column ::: ty]) where
343343 relation ! column = relation ! column :* Nil
344344
@@ -363,11 +363,11 @@ notNull = UnsafeExpression . renderExpression
363363-- >>> printSQL $ coalesce [null_, true] false
364364-- COALESCE(NULL, TRUE, FALSE)
365365coalesce
366− :: [Expression schema relations grouping params ('Null ty)]
366+ :: [Expression schema from grouping params ('Null ty)]
367367 -- ^ @NULL@s may be present
368− -> Expression schema relations grouping params ('NotNull ty)
368+ -> Expression schema from grouping params ('NotNull ty)
369369 -- ^ @NULL@ is absent
370− -> Expression schema relations grouping params ('NotNull ty)
370+ -> Expression schema from grouping params ('NotNull ty)
371371coalesce nullxs notNullx = UnsafeExpression $
372372 "COALESCE" <> parenthesized (commaSeparated
373373 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -377,26 +377,26 @@ coalesce nullxs notNullx = UnsafeExpression $
377377-- >>> printSQL $ fromNull true null_
378378-- COALESCE(NULL, TRUE)
379379fromNull
380− :: Expression schema relations grouping params ('NotNull ty)
380+ :: Expression schema from grouping params ('NotNull ty)
381381 -- ^ what to convert @NULL@ to
382− -> Expression schema relations grouping params ('Null ty)
383− -> Expression schema relations grouping params ('NotNull ty)
382+ -> Expression schema from grouping params ('Null ty)
383+ -> Expression schema from grouping params ('NotNull ty)
384384fromNull notNullx nullx = coalesce [nullx] notNullx
385385
386386-- | >>> printSQL $ null_ & isNull
387387-- NULL IS NULL
388388isNull
389− :: Expression schema relations grouping params ('Null ty)
389+ :: Expression schema from grouping params ('Null ty)
390390 -- ^ possibly @NULL@
391− -> Condition schema relations grouping params
391+ -> Condition schema from grouping params
392392isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
393393
394394-- | >>> printSQL $ null_ & isNotNull
395395-- NULL IS NOT NULL
396396isNotNull
397− :: Expression schema relations grouping params ('Null ty)
397+ :: Expression schema from grouping params ('Null ty)
398398 -- ^ possibly @NULL@
399− -> Condition schema relations grouping params
399+ -> Condition schema from grouping params
400400isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
401401
402402-- | analagous to `maybe` using @IS NULL@
@@ -404,13 +404,13 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
404404-- >>> printSQL $ matchNull true not_ null_
405405-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
406406matchNull
407− :: Expression schema relations grouping params (nullty)
407+ :: Expression schema from grouping params (nullty)
408408 -- ^ what to convert @NULL@ to
409− -> ( Expression schema relations grouping params ('NotNull ty)
410− -> Expression schema relations grouping params (nullty) )
409+ -> ( Expression schema from grouping params ('NotNull ty)
410+ -> Expression schema from grouping params (nullty) )
411411 -- ^ function to perform when @NULL@ is absent
412− -> Expression schema relations grouping params ('Null ty)
413− -> Expression schema relations grouping params (nullty)
412+ -> Expression schema from grouping params ('Null ty)
413+ -> Expression schema from grouping params (nullty)
414414matchNull y f x = ifThenElse (isNull x) y
415415 (f (UnsafeExpression (renderExpression x)))
416416
@@ -423,25 +423,25 @@ matchNull y f x = ifThenElse (isNull x) y
423423NULL IF (FALSE, ($1 :: bool))
424424-}
425425nullIf
426− :: Expression schema relations grouping params ('NotNull ty)
426+ :: Expression schema from grouping params ('NotNull ty)
427427 -- ^ @NULL@ is absent
428− -> Expression schema relations grouping params ('NotNull ty)
428+ -> Expression schema from grouping params ('NotNull ty)
429429 -- ^ @NULL@ is absent
430− -> Expression schema relations grouping params ('Null ty)
430+ -> Expression schema from grouping params ('Null ty)
431431nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
432432 (renderExpression x <> ", " <> renderExpression y)
433433
434434-- | >>> printSQL $ array [null_, false, true]
435435-- ARRAY[NULL, FALSE, TRUE]
436436array
437− :: [Expression schema relations grouping params ty]
437+ :: [Expression schema from grouping params ty]
438438 -- ^ array elements
439− -> Expression schema relations grouping params (nullity ('PGvararray ty))
439+ -> Expression schema from grouping params (nullity ('PGvararray ty))
440440array xs = UnsafeExpression $
441441 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
442442
443443instance (KnownSymbol label, label `In` labels) => IsPGlabel label
444− (Expression schema relations grouping params (nullity ('PGenum labels))) where
444+ (Expression schema from grouping params (nullity ('PGenum labels))) where
445445 label = UnsafeExpression $ renderLabel (PGlabel @label)
446446
447447-- | A row constructor is an expression that builds a row value
@@ -458,9 +458,9 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
458458-- ROW(0, 1)
459459row
460460 :: SListI fields
461− => NP (Aliased (Expression schema relations grouping params)) fields
461+ => NP (Aliased (Expression schema from grouping params)) fields
462462 -- ^ zero or more expressions for the row field values
463− -> Expression schema relations grouping params (nullity ('PGcomposite fields))
463+ -> Expression schema from grouping params (nullity ('PGcomposite fields))
464464row exprs = UnsafeExpression $ "ROW" <> parenthesized
465465 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
466466
@@ -472,11 +472,11 @@ instance Has field fields ty => IsLabel field
472472 renderSymbol @field
473473
474474instance Semigroup
475− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
475+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
476476 (<>) = unsafeBinaryOp "||"
477477
478478instance Monoid
479− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
479+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
480480 mempty = array []
481481 mappend = (<>)
482482
@@ -484,22 +484,22 @@ instance Monoid
484484-- >>> printSQL expr
485485-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
486486greatest
487− :: Expression schema relations grouping params (nullty)
487+ :: Expression schema from grouping params (nullty)
488488 -- ^ needs at least 1 argument
489− -> [Expression schema relations grouping params (nullty)]
489+ -> [Expression schema from grouping params (nullty)]
490490 -- ^ or more
491− -> Expression schema relations grouping params (nullty)
491+ -> Expression schema from grouping params (nullty)
492492greatest x xs = UnsafeExpression $ "GREATEST("
493493 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
494494
495495-- | >>> printSQL $ least currentTimestamp [null_]
496496-- LEAST(CURRENT_TIMESTAMP, NULL)
497497least
498− :: Expression schema relations grouping params (nullty)
498+ :: Expression schema from grouping params (nullty)
499499 -- ^ needs at least 1 argument
500− -> [Expression schema relations grouping params (nullty)]
500+ -> [Expression schema from grouping params (nullty)]
501501 -- ^ or more
502− -> Expression schema relations grouping params (nullty)
502+ -> Expression schema from grouping params (nullty)
503503least x xs = UnsafeExpression $ "LEAST("
504504 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
505505
@@ -508,9 +508,9 @@ least x xs = UnsafeExpression $ "LEAST("
508508unsafeBinaryOp
509509 :: ByteString
510510 -- ^ operator
511− -> Expression schema relations grouping params (ty0)
512− -> Expression schema relations grouping params (ty1)
513− -> Expression schema relations grouping params (ty2)
511+ -> Expression schema from grouping params (ty0)
512+ -> Expression schema from grouping params (ty1)
513+ -> Expression schema from grouping params (ty2)
514514unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
515515 renderExpression x <+> op <+> renderExpression y
516516
@@ -519,8 +519,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
519519unsafeUnaryOp
520520 :: ByteString
521521 -- ^ operator
522− -> Expression schema relations grouping params (ty0)
523− -> Expression schema relations grouping params (ty1)
522+ -> Expression schema from grouping params (ty0)
523+ -> Expression schema from grouping params (ty1)
524524unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
525525 op <+> renderExpression x
526526
@@ -529,8 +529,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
529529unsafeFunction
530530 :: ByteString
531531 -- ^ function
532− -> Expression schema relations grouping params (xty)
533− -> Expression schema relations grouping params (yty)
532+ -> Expression schema from grouping params (xty)
533+ -> Expression schema from grouping params (yty)
534534unsafeFunction fun x = UnsafeExpression $
535535 fun <> parenthesized (renderExpression x)
536536
@@ -539,13 +539,13 @@ unsafeVariadicFunction
539539 :: SListI elems
540540 => ByteString
541541 -- ^ function
542− -> NP (Expression schema relations grouping params) elems
543− -> Expression schema relations grouping params ret
542+ -> NP (Expression schema from grouping params) elems
543+ -> Expression schema from grouping params ret
544544unsafeVariadicFunction fun x = UnsafeExpression $
545545 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
546546
547547instance PGNum ty
548− => Num (Expression schema relations grouping params (nullity ty)) where
548+ => Num (Expression schema from grouping params (nullity ty)) where
549549 (+) = unsafeBinaryOp "+"
550550 (-) = unsafeBinaryOp "-"
551551 (*) = unsafeBinaryOp "*"
@@ -557,12 +557,12 @@ instance PGNum ty
557557 . show
558558
559559instance (PGNum ty, PGFloating ty) => Fractional
560− (Expression schema relations grouping params (nullity ty)) where
560+ (Expression schema from grouping params (nullity ty)) where
561561 (/) = unsafeBinaryOp "/"
562562 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
563563
564564instance (PGNum ty, PGFloating ty) => Floating
565− (Expression schema relations grouping params (nullity ty)) where
565+ (Expression schema from grouping params (nullity ty)) where
566566 pi = UnsafeExpression "pi()"
567567 exp = unsafeFunction "exp"
568568 log = unsafeFunction "ln"
@@ -585,18 +585,18 @@ instance (PGNum ty, PGFloating ty) => Floating
585585
586586-- | >>> :{
587587-- let
588−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
588+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
589589-- expression = atan2_ pi 2
590590-- in printSQL expression
591591-- :}
592592-- atan2(pi(), 2)
593593atan2_
594594 :: PGFloating float
595− => Expression schema relations grouping params (nullity float)
595+ => Expression schema from grouping params (nullity float)
596596 -- ^ numerator
597− -> Expression schema relations grouping params (nullity float)
597+ -> Expression schema from grouping params (nullity float)
598598 -- ^ denominator
599− -> Expression schema relations grouping params (nullity float)
599+ -> Expression schema from grouping params (nullity float)
600600atan2_ y x = UnsafeExpression $
601601 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
602602
@@ -609,9 +609,9 @@ atan2_ y x = UnsafeExpression $
609609cast
610610 :: TypeExpression schema ty1
611611 -- ^ type to cast as
612− -> Expression schema relations grouping params ty0
612+ -> Expression schema from grouping params ty0
613613 -- ^ value to convert
614− -> Expression schema relations grouping params ty1
614+ -> Expression schema from grouping params ty1
615615cast ty x = UnsafeExpression $ parenthesized $
616616 renderExpression x <+> "::" <+> renderTypeExpression ty
617617
@@ -619,134 +619,134 @@ cast ty x = UnsafeExpression $ parenthesized $
619619--
620620-- >>> :{
621621-- let
622−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
622+-- expression :: Expression schema from grouping params (nullity 'PGint2)
623623-- expression = 5 `quot_` 2
624624-- in printSQL expression
625625-- :}
626626-- (5 / 2)
627627quot_
628628 :: PGIntegral int
629− => Expression schema relations grouping params (nullity int)
629+ => Expression schema from grouping params (nullity int)
630630 -- ^ numerator
631− -> Expression schema relations grouping params (nullity int)
631+ -> Expression schema from grouping params (nullity int)
632632 -- ^ denominator
633− -> Expression schema relations grouping params (nullity int)
633+ -> Expression schema from grouping params (nullity int)
634634quot_ = unsafeBinaryOp "/"
635635
636636-- | remainder upon integer division
637637--
638638-- >>> :{
639639-- let
640−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
640+-- expression :: Expression schema from grouping params (nullity 'PGint2)
641641-- expression = 5 `rem_` 2
642642-- in printSQL expression
643643-- :}
644644-- (5 % 2)
645645rem_
646646 :: PGIntegral int
647− => Expression schema relations grouping params (nullity int)
647+ => Expression schema from grouping params (nullity int)
648648 -- ^ numerator
649− -> Expression schema relations grouping params (nullity int)
649+ -> Expression schema from grouping params (nullity int)
650650 -- ^ denominator
651− -> Expression schema relations grouping params (nullity int)
651+ -> Expression schema from grouping params (nullity int)
652652rem_ = unsafeBinaryOp "%"
653653
654654-- | >>> :{
655655-- let
656−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
656+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
657657-- expression = trunc pi
658658-- in printSQL expression
659659-- :}
660660-- trunc(pi())
661661trunc
662662 :: PGFloating frac
663− => Expression schema relations grouping params (nullity frac)
663+ => Expression schema from grouping params (nullity frac)
664664 -- ^ fractional number
665− -> Expression schema relations grouping params (nullity frac)
665+ -> Expression schema from grouping params (nullity frac)
666666trunc = unsafeFunction "trunc"
667667
668668-- | >>> :{
669669-- let
670−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
670+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
671671-- expression = round_ pi
672672-- in printSQL expression
673673-- :}
674674-- round(pi())
675675round_
676676 :: PGFloating frac
677− => Expression schema relations grouping params (nullity frac)
677+ => Expression schema from grouping params (nullity frac)
678678 -- ^ fractional number
679− -> Expression schema relations grouping params (nullity frac)
679+ -> Expression schema from grouping params (nullity frac)
680680round_ = unsafeFunction "round"
681681
682682-- | >>> :{
683683-- let
684−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
684+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
685685-- expression = ceiling_ pi
686686-- in printSQL expression
687687-- :}
688688-- ceiling(pi())
689689ceiling_
690690 :: PGFloating frac
691− => Expression schema relations grouping params (nullity frac)
691+ => Expression schema from grouping params (nullity frac)
692692 -- ^ fractional number
693− -> Expression schema relations grouping params (nullity frac)
693+ -> Expression schema from grouping params (nullity frac)
694694ceiling_ = unsafeFunction "ceiling"
695695
696696-- | A `Condition` is an `Expression`, which can evaluate
697697-- to `TRUE`, `FALSE` or `NULL`. This is because SQL uses
698698-- a three valued logic.
699−type Condition schema relations grouping params =
700− Expression schema relations grouping params ('Null 'PGbool)
699+type Condition schema from grouping params =
700+ Expression schema from grouping params ('Null 'PGbool)
701701
702702-- | >>> printSQL true
703703-- TRUE
704−true :: Expression schema relations grouping params (nullity 'PGbool)
704+true :: Expression schema from grouping params (nullity 'PGbool)
705705true = UnsafeExpression "TRUE"
706706
707707-- | >>> printSQL false
708708-- FALSE
709−false :: Expression schema relations grouping params (nullity 'PGbool)
709+false :: Expression schema from grouping params (nullity 'PGbool)
710710false = UnsafeExpression "FALSE"
711711
712712-- | >>> printSQL $ not_ true
713713-- (NOT TRUE)
714714not_
715− :: Expression schema relations grouping params (nullity 'PGbool)
716− -> Expression schema relations grouping params (nullity 'PGbool)
715+ :: Expression schema from grouping params (nullity 'PGbool)
716+ -> Expression schema from grouping params (nullity 'PGbool)
717717not_ = unsafeUnaryOp "NOT"
718718
719719-- | >>> printSQL $ true .&& false
720720-- (TRUE AND FALSE)
721721(.&&)
722− :: Condition schema relations grouping params
723− -> Condition schema relations grouping params
724− -> Condition schema relations grouping params
722+ :: Condition schema from grouping params
723+ -> Condition schema from grouping params
724+ -> Condition schema from grouping params
725725(.&&) = unsafeBinaryOp "AND"
726726
727727-- | >>> printSQL $ true .|| false
728728-- (TRUE OR FALSE)
729729(.||)
730− :: Condition schema relations grouping params
731− -> Condition schema relations grouping params
732− -> Condition schema relations grouping params
730+ :: Condition schema from grouping params
731+ -> Condition schema from grouping params
732+ -> Condition schema from grouping params
733733(.||) = unsafeBinaryOp "OR"
734734
735735-- | >>> :{
736736-- let
737−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
737+-- expression :: Expression schema from grouping params (nullity 'PGint2)
738738-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
739739-- in printSQL expression
740740-- :}
741741-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
742742caseWhenThenElse
743− :: [ ( Condition schema relations grouping params
744− , Expression schema relations grouping params ty
743+ :: [ ( Condition schema from grouping params
744+ , Expression schema from grouping params ty
745745 ) ]
746746 -- ^ whens and thens
747− -> Expression schema relations grouping params ty
747+ -> Expression schema from grouping params ty
748748 -- ^ else
749− -> Expression schema relations grouping params ty
749+ -> Expression schema from grouping params ty
750750caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
751751 [ "CASE"
752752 , mconcat
@@ -762,16 +762,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
762762
763763-- | >>> :{
764764-- let
765−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
765+-- expression :: Expression schema from grouping params (nullity 'PGint2)
766766-- expression = ifThenElse true 1 0
767767-- in printSQL expression
768768-- :}
769769-- CASE WHEN TRUE THEN 1 ELSE 0 END
770770ifThenElse
771− :: Condition schema relations grouping params
772− -> Expression schema relations grouping params ty -- ^ then
773− -> Expression schema relations grouping params ty -- ^ else
774− -> Expression schema relations grouping params ty
771+ :: Condition schema from grouping params
772+ -> Expression schema from grouping params ty -- ^ then
773+ -> Expression schema from grouping params ty -- ^ else
774+ -> Expression schema from grouping params ty
775775ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
776776
777777-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -780,85 +780,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
780780-- >>> printSQL $ true .== null_
781781-- (TRUE = NULL)
782782(.==)
783− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
784− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
785− -> Condition schema relations grouping params
783+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
784+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
785+ -> Condition schema from grouping params
786786(.==) = unsafeBinaryOp "="
787787infix 4 .==
788788
789789-- | >>> printSQL $ true ./= null_
790790-- (TRUE <> NULL)
791791(./=)
792− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
793− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
794− -> Condition schema relations grouping params
792+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
793+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
794+ -> Condition schema from grouping params
795795(./=) = unsafeBinaryOp "<>"
796796infix 4 ./=
797797
798798-- | >>> printSQL $ true .>= null_
799799-- (TRUE >= NULL)
800800(.>=)
801− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
802− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
803− -> Condition schema relations grouping params
801+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
802+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
803+ -> Condition schema from grouping params
804804(.>=) = unsafeBinaryOp ">="
805805infix 4 .>=
806806
807807-- | >>> printSQL $ true .< null_
808808-- (TRUE < NULL)
809809(.<)
810− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
811− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
812− -> Condition schema relations grouping params
810+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
811+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
812+ -> Condition schema from grouping params
813813(.<) = unsafeBinaryOp "<"
814814infix 4 .<
815815
816816-- | >>> printSQL $ true .<= null_
817817-- (TRUE <= NULL)
818818(.<=)
819− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
820− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
821− -> Condition schema relations grouping params
819+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
820+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
821+ -> Condition schema from grouping params
822822(.<=) = unsafeBinaryOp "<="
823823infix 4 .<=
824824
825825-- | >>> printSQL $ true .> null_
826826-- (TRUE > NULL)
827827(.>)
828− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
829− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
830− -> Condition schema relations grouping params
828+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
829+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
830+ -> Condition schema from grouping params
831831(.>) = unsafeBinaryOp ">"
832832infix 4 .>
833833
834834-- | >>> printSQL currentDate
835835-- CURRENT_DATE
836836currentDate
837− :: Expression schema relations grouping params (nullity 'PGdate)
837+ :: Expression schema from grouping params (nullity 'PGdate)
838838currentDate = UnsafeExpression "CURRENT_DATE"
839839
840840-- | >>> printSQL currentTime
841841-- CURRENT_TIME
842842currentTime
843− :: Expression schema relations grouping params (nullity 'PGtimetz)
843+ :: Expression schema from grouping params (nullity 'PGtimetz)
844844currentTime = UnsafeExpression "CURRENT_TIME"
845845
846846-- | >>> printSQL currentTimestamp
847847-- CURRENT_TIMESTAMP
848848currentTimestamp
849− :: Expression schema relations grouping params (nullity 'PGtimestamptz)
849+ :: Expression schema from grouping params (nullity 'PGtimestamptz)
850850currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
851851
852852-- | >>> printSQL localTime
853853-- LOCALTIME
854854localTime
855− :: Expression schema relations grouping params (nullity 'PGtime)
855+ :: Expression schema from grouping params (nullity 'PGtime)
856856localTime = UnsafeExpression "LOCALTIME"
857857
858858-- | >>> printSQL localTimestamp
859859-- LOCALTIMESTAMP
860860localTimestamp
861− :: Expression schema relations grouping params (nullity 'PGtimestamp)
861+ :: Expression schema from grouping params (nullity 'PGtimestamp)
862862localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
863863
864864{-----------------------------------------
@@ -866,7 +866,7 @@ text
866866-----------------------------------------}
867867
868868instance IsString
869− (Expression schema relations grouping params (nullity 'PGtext)) where
869+ (Expression schema from grouping params (nullity 'PGtext)) where
870870 fromString str = UnsafeExpression $
871871 "E\'" <> fromString (escape =<< str) <> "\'"
872872 where
@@ -882,36 +882,36 @@ instance IsString
882882 c -> [c]
883883
884884instance Semigroup
885− (Expression schema relations grouping params (nullity 'PGtext)) where
885+ (Expression schema from grouping params (nullity 'PGtext)) where
886886 (<>) = unsafeBinaryOp "||"
887887
888888instance Monoid
889− (Expression schema relations grouping params (nullity 'PGtext)) where
889+ (Expression schema from grouping params (nullity 'PGtext)) where
890890 mempty = fromString ""
891891 mappend = (<>)
892892
893893-- | >>> printSQL $ lower "ARRRGGG"
894894-- lower(E'ARRRGGG')
895895lower
896− :: Expression schema relations grouping params (nullity 'PGtext)
896+ :: Expression schema from grouping params (nullity 'PGtext)
897897 -- ^ string to lower case
898− -> Expression schema relations grouping params (nullity 'PGtext)
898+ -> Expression schema from grouping params (nullity 'PGtext)
899899lower = unsafeFunction "lower"
900900
901901-- | >>> printSQL $ upper "eeee"
902902-- upper(E'eeee')
903903upper
904− :: Expression schema relations grouping params (nullity 'PGtext)
904+ :: Expression schema from grouping params (nullity 'PGtext)
905905 -- ^ string to upper case
906− -> Expression schema relations grouping params (nullity 'PGtext)
906+ -> Expression schema from grouping params (nullity 'PGtext)
907907upper = unsafeFunction "upper"
908908
909909-- | >>> printSQL $ charLength "four"
910910-- char_length(E'four')
911911charLength
912− :: Expression schema relations grouping params (nullity 'PGtext)
912+ :: Expression schema from grouping params (nullity 'PGtext)
913913 -- ^ string to measure
914− -> Expression schema relations grouping params (nullity 'PGint4)
914+ -> Expression schema from grouping params (nullity 'PGint4)
915915charLength = unsafeFunction "char_length"
916916
917917-- | The `like` expression returns true if the @string@ matches
@@ -924,11 +924,11 @@ charLength = unsafeFunction "char_length"
924924-- >>> printSQL $ "abc" `like` "a%"
925925-- (E'abc' LIKE E'a%')
926926like
927− :: Expression schema relations grouping params (nullity 'PGtext)
927+ :: Expression schema from grouping params (nullity 'PGtext)
928928 -- ^ string
929− -> Expression schema relations grouping params (nullity 'PGtext)
929+ -> Expression schema from grouping params (nullity 'PGtext)
930930 -- ^ pattern
931− -> Expression schema relations grouping params (nullity 'PGbool)
931+ -> Expression schema from grouping params (nullity 'PGbool)
932932like = unsafeBinaryOp "LIKE"
933933
934934{-----------------------------------------
@@ -943,33 +943,33 @@ Table 9.44: json and jsonb operators
943943-- | Get JSON value (object field or array element) at a key.
944944(.->)
945945 :: (PGjson_ json, PGjsonKey key)
946− => Expression schema relations grouping params (nullity json)
947− -> Expression schema relations grouping params (nullity key)
948− -> Expression schema relations grouping params ('Null json)
946+ => Expression schema from grouping params (nullity json)
947+ -> Expression schema from grouping params (nullity key)
948+ -> Expression schema from grouping params ('Null json)
949949(.->) = unsafeBinaryOp "->"
950950
951951-- | Get JSON value (object field or array element) at a key, as text.
952952(.->>)
953953 :: (PGjson_ json, PGjsonKey key)
954− => Expression schema relations grouping params (nullity json)
955− -> Expression schema relations grouping params (nullity key)
956− -> Expression schema relations grouping params ('Null 'PGtext)
954+ => Expression schema from grouping params (nullity json)
955+ -> Expression schema from grouping params (nullity key)
956+ -> Expression schema from grouping params ('Null 'PGtext)
957957(.->>) = unsafeBinaryOp "->>"
958958
959959-- | Get JSON value at a specified path.
960960(.#>)
961961 :: (PGjson_ json, PGtextArray "(.#>)" path)
962− => Expression schema relations grouping params (nullity json)
963− -> Expression schema relations grouping params (nullity path)
964− -> Expression schema relations grouping params ('Null json)
962+ => Expression schema from grouping params (nullity json)
963+ -> Expression schema from grouping params (nullity path)
964+ -> Expression schema from grouping params ('Null json)
965965(.#>) = unsafeBinaryOp "#>"
966966
967967-- | Get JSON value at a specified path as text.
968968(.#>>)
969969 :: (PGjson_ json, PGtextArray "(.#>>)" path)
970− => Expression schema relations grouping params (nullity json)
971− -> Expression schema relations grouping params (nullity path)
972− -> Expression schema relations grouping params ('Null 'PGtext)
970+ => Expression schema from grouping params (nullity json)
971+ -> Expression schema from grouping params (nullity path)
972+ -> Expression schema from grouping params ('Null 'PGtext)
973973(.#>>) = unsafeBinaryOp "#>>"
974974
975975-- Additional jsonb operators
@@ -977,43 +977,43 @@ Table 9.44: json and jsonb operators
977977-- | Does the left JSON value contain the right JSON path/value entries at the
978978-- top level?
979979(.@>)
980− :: Expression schema relations grouping params (nullity 'PGjsonb)
981− -> Expression schema relations grouping params (nullity 'PGjsonb)
982− -> Condition schema relations grouping params
980+ :: Expression schema from grouping params (nullity 'PGjsonb)
981+ -> Expression schema from grouping params (nullity 'PGjsonb)
982+ -> Condition schema from grouping params
983983(.@>) = unsafeBinaryOp "@>"
984984
985985-- | Are the left JSON path/value entries contained at the top level within the
986986-- right JSON value?
987987(.<@)
988− :: Expression schema relations grouping params (nullity 'PGjsonb)
989− -> Expression schema relations grouping params (nullity 'PGjsonb)
990− -> Condition schema relations grouping params
988+ :: Expression schema from grouping params (nullity 'PGjsonb)
989+ -> Expression schema from grouping params (nullity 'PGjsonb)
990+ -> Condition schema from grouping params
991991(.<@) = unsafeBinaryOp "<@"
992992
993993-- | Does the string exist as a top-level key within the JSON value?
994994(.?)
995− :: Expression schema relations grouping params (nullity 'PGjsonb)
996− -> Expression schema relations grouping params (nullity 'PGtext)
997− -> Condition schema relations grouping params
995+ :: Expression schema from grouping params (nullity 'PGjsonb)
996+ -> Expression schema from grouping params (nullity 'PGtext)
997+ -> Condition schema from grouping params
998998(.?) = unsafeBinaryOp "?"
999999
10001000-- | Do any of these array strings exist as top-level keys?
10011001(.?|)
1002− :: Expression schema relations grouping params (nullity 'PGjsonb)
1003− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1004− -> Condition schema relations grouping params
1002+ :: Expression schema from grouping params (nullity 'PGjsonb)
1003+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1004+ -> Condition schema from grouping params
10051005(.?|) = unsafeBinaryOp "?|"
10061006
10071007-- | Do all of these array strings exist as top-level keys?
10081008(.?&)
1009− :: Expression schema relations grouping params (nullity 'PGjsonb)
1010− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1011− -> Condition schema relations grouping params
1009+ :: Expression schema from grouping params (nullity 'PGjsonb)
1010+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1011+ -> Condition schema from grouping params
10121012(.?&) = unsafeBinaryOp "?&"
10131013
10141014-- | Concatenate two jsonb values into a new jsonb value.
10151015instance
1016− Semigroup (Expression schema relations grouping param (nullity 'PGjsonb)) where
1016+ Semigroup (Expression schema from grouping param (nullity 'PGjsonb)) where
10171017 (<>) = unsafeBinaryOp "||"
10181018
10191019-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1030,18 +1030,18 @@ instance
10301030-- count from the end). Throws an error if top level container is not an array.
10311031(.-.)
10321032 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1033− => Expression schema relations grouping params (nullity 'PGjsonb)
1034− -> Expression schema relations grouping params (nullity key)
1035− -> Expression schema relations grouping params (nullity 'PGjsonb)
1033+ => Expression schema from grouping params (nullity 'PGjsonb)
1034+ -> Expression schema from grouping params (nullity key)
1035+ -> Expression schema from grouping params (nullity 'PGjsonb)
10361036(.-.) = unsafeBinaryOp "-"
10371037
10381038-- | Delete the field or element with specified path (for JSON arrays, negative
10391039-- integers count from the end)
10401040(#-.)
10411041 :: PGtextArray "(#-.)" arrayty
1042− => Expression schema relations grouping params (nullity 'PGjsonb)
1043− -> Expression schema relations grouping params (nullity arrayty)
1044− -> Expression schema relations grouping params (nullity 'PGjsonb)
1042+ => Expression schema from grouping params (nullity 'PGjsonb)
1043+ -> Expression schema from grouping params (nullity arrayty)
1044+ -> Expression schema from grouping params (nullity 'PGjsonb)
10451045(#-.) = unsafeBinaryOp "#-"
10461046
10471047{-----------------------------------------
@@ -1049,11 +1049,11 @@ Table 9.45: JSON creation functions
10491049-----------------------------------------}
10501050
10511051-- | Literal binary JSON
1052−jsonbLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjsonb)
1052+jsonbLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjsonb)
10531053jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
10541054
10551055-- | Literal JSON
1056−jsonLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjson)
1056+jsonLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjson)
10571057jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
10581058
10591059-- | Returns the value as json. Arrays and composites are converted
@@ -1063,8 +1063,8 @@ jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.enco
10631063-- number, a Boolean, or a null value, the text representation will be used, in
10641064-- such a fashion that it is a valid json value.
10651065toJson
1066− :: Expression schema relations grouping params (nullity ty)
1067− -> Expression schema relations grouping params (nullity 'PGjson)
1066+ :: Expression schema from grouping params (nullity ty)
1067+ -> Expression schema from grouping params (nullity 'PGjson)
10681068toJson = unsafeFunction "to_json"
10691069
10701070-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1074,43 +1074,43 @@ toJson = unsafeFunction "to_json"
10741074-- number, a Boolean, or a null value, the text representation will be used, in
10751075-- such a fashion that it is a valid jsonb value.
10761076toJsonb
1077− :: Expression schema relations grouping params (nullity ty)
1078− -> Expression schema relations grouping params (nullity 'PGjsonb)
1077+ :: Expression schema from grouping params (nullity ty)
1078+ -> Expression schema from grouping params (nullity 'PGjsonb)
10791079toJsonb = unsafeFunction "to_jsonb"
10801080
10811081-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
10821082-- becomes a JSON array of arrays.
10831083arrayToJson
10841084 :: PGarray "arrayToJson" arr
1085− => Expression schema relations grouping params (nullity arr)
1086− -> Expression schema relations grouping params (nullity 'PGjson)
1085+ => Expression schema from grouping params (nullity arr)
1086+ -> Expression schema from grouping params (nullity 'PGjson)
10871087arrayToJson = unsafeFunction "array_to_json"
10881088
10891089-- | Returns the row as a JSON object.
10901090rowToJson
1091− :: Expression schema relations grouping params (nullity ('PGcomposite ty))
1092− -> Expression schema relations grouping params (nullity 'PGjson)
1091+ :: Expression schema from grouping params (nullity ('PGcomposite ty))
1092+ -> Expression schema from grouping params (nullity 'PGjson)
10931093rowToJson = unsafeFunction "row_to_json"
10941094
10951095-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
10961096-- argument list.
10971097jsonBuildArray
10981098 :: SListI elems
1099− => NP (Expression schema relations grouping params) elems
1100− -> Expression schema relations grouping params (nullity 'PGjson)
1099+ => NP (Expression schema from grouping params) elems
1100+ -> Expression schema from grouping params (nullity 'PGjson)
11011101jsonBuildArray = unsafeVariadicFunction "json_build_array"
11021102
11031103-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
11041104-- variadic argument list.
11051105jsonbBuildArray
11061106 :: SListI elems
1107− => NP (Expression schema relations grouping params) elems
1108− -> Expression schema relations grouping params (nullity 'PGjsonb)
1107+ => NP (Expression schema from grouping params) elems
1108+ -> Expression schema from grouping params (nullity 'PGjsonb)
11091109jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
11101110
11111111unsafeRowFunction
11121112 :: All Top elems
1113− => NP (Aliased (Expression schema relations grouping params)) elems
1113+ => NP (Aliased (Expression schema from grouping params)) elems
11141114 -> [ByteString]
11151115unsafeRowFunction =
11161116 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1122,8 +1122,8 @@ unsafeRowFunction =
11221122-- and values.
11231123jsonBuildObject
11241124 :: All Top elems
1125− => NP (Aliased (Expression schema relations grouping params)) elems
1126− -> Expression schema relations grouping params (nullity 'PGjson)
1125+ => NP (Aliased (Expression schema from grouping params)) elems
1126+ -> Expression schema from grouping params (nullity 'PGjson)
11271127jsonBuildObject
11281128 = unsafeFunction "json_build_object"
11291129 . UnsafeExpression
@@ -1135,8 +1135,8 @@ jsonBuildObject
11351135-- between text and values.
11361136jsonbBuildObject
11371137 :: All Top elems
1138− => NP (Aliased (Expression schema relations grouping params)) elems
1139− -> Expression schema relations grouping params (nullity 'PGjsonb)
1138+ => NP (Aliased (Expression schema from grouping params)) elems
1139+ -> Expression schema from grouping params (nullity 'PGjsonb)
11401140jsonbBuildObject
11411141 = unsafeFunction "jsonb_build_object"
11421142 . UnsafeExpression
@@ -1149,8 +1149,8 @@ jsonbBuildObject
11491149-- array has exactly two elements, which are taken as a key/value pair.
11501150jsonObject
11511151 :: PGarrayOf "jsonObject" arr ('NotNull 'PGtext)
1152− => Expression schema relations grouping params (nullity arr)
1153− -> Expression schema relations grouping params (nullity 'PGjson)
1152+ => Expression schema from grouping params (nullity arr)
1153+ -> Expression schema from grouping params (nullity 'PGjson)
11541154jsonObject = unsafeFunction "json_object"
11551155
11561156-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1159,8 +1159,8 @@ jsonObject = unsafeFunction "json_object"
11591159-- array has exactly two elements, which are taken as a key/value pair.
11601160jsonbObject
11611161 :: PGarrayOf "jsonbObject" arr ('NotNull 'PGtext)
1162− => Expression schema relations grouping params (nullity arr)
1163− -> Expression schema relations grouping params (nullity 'PGjsonb)
1162+ => Expression schema from grouping params (nullity arr)
1163+ -> Expression schema from grouping params (nullity 'PGjsonb)
11641164jsonbObject = unsafeFunction "jsonb_object"
11651165
11661166-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1168,9 +1168,9 @@ jsonbObject = unsafeFunction "jsonb_object"
11681168jsonZipObject
11691169 :: ( PGarrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
11701170 , PGarrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1171− => Expression schema relations grouping params (nullity keysArray)
1172− -> Expression schema relations grouping params (nullity valuesArray)
1173− -> Expression schema relations grouping params (nullity 'PGjson)
1171+ => Expression schema from grouping params (nullity keysArray)
1172+ -> Expression schema from grouping params (nullity valuesArray)
1173+ -> Expression schema from grouping params (nullity 'PGjson)
11741174jsonZipObject ks vs =
11751175 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
11761176
@@ -1180,9 +1180,9 @@ jsonZipObject ks vs =
11801180jsonbZipObject
11811181 :: ( PGarrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
11821182 , PGarrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1183− => Expression schema relations grouping params (nullity keysArray)
1184− -> Expression schema relations grouping params (nullity valuesArray)
1185− -> Expression schema relations grouping params (nullity 'PGjsonb)
1183+ => Expression schema from grouping params (nullity keysArray)
1184+ -> Expression schema from grouping params (nullity valuesArray)
1185+ -> Expression schema from grouping params (nullity 'PGjsonb)
11861186jsonbZipObject ks vs =
11871187 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
11881188
@@ -1192,23 +1192,23 @@ Table 9.46: JSON processing functions
11921192
11931193-- | Returns the number of elements in the outermost JSON array.
11941194jsonArrayLength
1195− :: Expression schema relations grouping params (nullity 'PGjson)
1196− -> Expression schema relations grouping params (nullity 'PGint4)
1195+ :: Expression schema from grouping params (nullity 'PGjson)
1196+ -> Expression schema from grouping params (nullity 'PGint4)
11971197jsonArrayLength = unsafeFunction "json_array_length"
11981198
11991199-- | Returns the number of elements in the outermost binary JSON array.
12001200jsonbArrayLength
1201− :: Expression schema relations grouping params (nullity 'PGjsonb)
1202− -> Expression schema relations grouping params (nullity 'PGint4)
1201+ :: Expression schema from grouping params (nullity 'PGjsonb)
1202+ -> Expression schema from grouping params (nullity 'PGint4)
12031203jsonbArrayLength = unsafeFunction "jsonb_array_length"
12041204
12051205-- | Returns JSON value pointed to by the given path (equivalent to #>
12061206-- operator).
12071207jsonExtractPath
12081208 :: SListI elems
1209− => Expression schema relations grouping params (nullity 'PGjson)
1210− -> NP (Expression schema relations grouping params) elems
1211− -> Expression schema relations grouping params (nullity 'PGjsonb)
1209+ => Expression schema from grouping params (nullity 'PGjson)
1210+ -> NP (Expression schema from grouping params) elems
1211+ -> Expression schema from grouping params (nullity 'PGjsonb)
12121212jsonExtractPath x xs =
12131213 unsafeVariadicFunction "json_extract_path" (x :* xs)
12141214
@@ -1216,9 +1216,9 @@ jsonExtractPath x xs =
12161216-- operator).
12171217jsonbExtractPath
12181218 :: SListI elems
1219− => Expression schema relations grouping params (nullity 'PGjsonb)
1220− -> NP (Expression schema relations grouping params) elems
1221− -> Expression schema relations grouping params (nullity 'PGjsonb)
1219+ => Expression schema from grouping params (nullity 'PGjsonb)
1220+ -> NP (Expression schema from grouping params) elems
1221+ -> Expression schema from grouping params (nullity 'PGjsonb)
12221222jsonbExtractPath x xs =
12231223 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
12241224
@@ -1226,9 +1226,9 @@ jsonbExtractPath x xs =
12261226-- operator), as text.
12271227jsonExtractPathAsText
12281228 :: SListI elems
1229− => Expression schema relations grouping params (nullity 'PGjson)
1230− -> NP (Expression schema relations grouping params) elems
1231− -> Expression schema relations grouping params (nullity 'PGjson)
1229+ => Expression schema from grouping params (nullity 'PGjson)
1230+ -> NP (Expression schema from grouping params) elems
1231+ -> Expression schema from grouping params (nullity 'PGjson)
12321232jsonExtractPathAsText x xs =
12331233 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
12341234
@@ -1236,50 +1236,50 @@ jsonExtractPathAsText x xs =
12361236-- operator), as text.
12371237jsonbExtractPathAsText
12381238 :: SListI elems
1239− => Expression schema relations grouping params (nullity 'PGjsonb)
1240− -> NP (Expression schema relations grouping params) elems
1241− -> Expression schema relations grouping params (nullity 'PGjsonb)
1239+ => Expression schema from grouping params (nullity 'PGjsonb)
1240+ -> NP (Expression schema from grouping params) elems
1241+ -> Expression schema from grouping params (nullity 'PGjsonb)
12421242jsonbExtractPathAsText x xs =
12431243 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
12441244
12451245-- | Returns set of keys in the outermost JSON object.
12461246jsonObjectKeys
1247− :: Expression schema relations grouping params (nullity 'PGjson)
1248− -> Expression schema relations grouping params (nullity 'PGtext)
1247+ :: Expression schema from grouping params (nullity 'PGjson)
1248+ -> Expression schema from grouping params (nullity 'PGtext)
12491249jsonObjectKeys = unsafeFunction "json_object_keys"
12501250
12511251-- | Returns set of keys in the outermost JSON object.
12521252jsonbObjectKeys
1253− :: Expression schema relations grouping params (nullity 'PGjsonb)
1254− -> Expression schema relations grouping params (nullity 'PGtext)
1253+ :: Expression schema from grouping params (nullity 'PGjsonb)
1254+ -> Expression schema from grouping params (nullity 'PGtext)
12551255jsonbObjectKeys = unsafeFunction "jsonb_object_keys"
12561256
12571257-- | Returns the type of the outermost JSON value as a text string. Possible
12581258-- types are object, array, string, number, boolean, and null.
12591259jsonTypeof
1260− :: Expression schema relations grouping params (nullity 'PGjson)
1261− -> Expression schema relations grouping params (nullity 'PGtext)
1260+ :: Expression schema from grouping params (nullity 'PGjson)
1261+ -> Expression schema from grouping params (nullity 'PGtext)
12621262jsonTypeof = unsafeFunction "json_typeof"
12631263
12641264-- | Returns the type of the outermost binary JSON value as a text string.
12651265-- Possible types are object, array, string, number, boolean, and null.
12661266jsonbTypeof
1267− :: Expression schema relations grouping params (nullity 'PGjsonb)
1268− -> Expression schema relations grouping params (nullity 'PGtext)
1267+ :: Expression schema from grouping params (nullity 'PGjsonb)
1268+ -> Expression schema from grouping params (nullity 'PGtext)
12691269jsonbTypeof = unsafeFunction "jsonb_typeof"
12701270
12711271-- | Returns its argument with all object fields that have null values omitted.
12721272-- Other null values are untouched.
12731273jsonStripNulls
1274− :: Expression schema relations grouping params (nullity 'PGjson)
1275− -> Expression schema relations grouping params (nullity 'PGjson)
1274+ :: Expression schema from grouping params (nullity 'PGjson)
1275+ -> Expression schema from grouping params (nullity 'PGjson)
12761276jsonStripNulls = unsafeFunction "json_strip_nulls"
12771277
12781278-- | Returns its argument with all object fields that have null values omitted.
12791279-- Other null values are untouched.
12801280jsonbStripNulls
1281− :: Expression schema relations grouping params (nullity 'PGjsonb)
1282− -> Expression schema relations grouping params (nullity 'PGjsonb)
1281+ :: Expression schema from grouping params (nullity 'PGjsonb)
1282+ -> Expression schema from grouping params (nullity 'PGjsonb)
12831283jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
12841284
12851285-- | @ jsonbSet target path new_value create_missing @
@@ -1291,11 +1291,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
12911291-- arrays.
12921292jsonbSet
12931293 :: PGtextArray "jsonbSet" arr
1294− => Expression schema relations grouping params (nullity 'PGjsonb)
1295− -> Expression schema relations grouping params (nullity arr)
1296− -> Expression schema relations grouping params (nullity 'PGjsonb)
1297− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1298− -> Expression schema relations grouping params (nullity 'PGjsonb)
1294+ => Expression schema from grouping params (nullity 'PGjsonb)
1295+ -> Expression schema from grouping params (nullity arr)
1296+ -> Expression schema from grouping params (nullity 'PGjsonb)
1297+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1298+ -> Expression schema from grouping params (nullity 'PGjsonb)
12991299jsonbSet tgt path val createMissing = case createMissing of
13001300 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
13011301 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1310,19 +1310,19 @@ jsonbSet tgt path val createMissing = case createMissing of
13101310-- in path count from the end of JSON arrays.
13111311jsonbInsert
13121312 :: PGtextArray "jsonbInsert" arr
1313− => Expression schema relations grouping params (nullity 'PGjsonb)
1314− -> Expression schema relations grouping params (nullity arr)
1315− -> Expression schema relations grouping params (nullity 'PGjsonb)
1316− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1317− -> Expression schema relations grouping params (nullity 'PGjsonb)
1313+ => Expression schema from grouping params (nullity 'PGjsonb)
1314+ -> Expression schema from grouping params (nullity arr)
1315+ -> Expression schema from grouping params (nullity 'PGjsonb)
1316+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1317+ -> Expression schema from grouping params (nullity 'PGjsonb)
13181318jsonbInsert tgt path val insertAfter = case insertAfter of
13191319 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
13201320 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
13211321
13221322-- | Returns its argument as indented JSON text.
13231323jsonbPretty
1324− :: Expression schema relations grouping params (nullity 'PGjsonb)
1325− -> Expression schema relations grouping params (nullity 'PGtext)
1324+ :: Expression schema from grouping params (nullity 'PGjsonb)
1325+ -> Expression schema from grouping params (nullity 'PGtext)
13261326jsonbPretty = unsafeFunction "jsonb_pretty"
13271327
13281328{-----------------------------------------
@@ -1332,16 +1332,16 @@ aggregation
13321332-- | escape hatch to define aggregate functions
13331333unsafeAggregate
13341334 :: ByteString -- ^ aggregate function
1335− -> Expression schema relations 'Ungrouped params (xty)
1336− -> Expression schema relations ('Grouped bys) params (yty)
1335+ -> Expression schema from 'Ungrouped params (xty)
1336+ -> Expression schema from ('Grouped bys) params (yty)
13371337unsafeAggregate fun x = UnsafeExpression $ mconcat
13381338 [fun, "(", renderExpression x, ")"]
13391339
13401340-- | escape hatch to define aggregate functions over distinct values
13411341unsafeAggregateDistinct
13421342 :: ByteString -- ^ aggregate function
1343− -> Expression schema relations 'Ungrouped params (xty)
1344− -> Expression schema relations ('Grouped bys) params (yty)
1343+ -> Expression schema from 'Ungrouped params (xty)
1344+ -> Expression schema from ('Grouped bys) params (yty)
13451345unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
13461346 [fun, "(DISTINCT ", renderExpression x, ")"]
13471347
@@ -1354,9 +1354,9 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
13541354-- sum("col")
13551355sum_
13561356 :: PGNum ty
1357− => Expression schema relations 'Ungrouped params (nullity ty)
1357+ => Expression schema from 'Ungrouped params (nullity ty)
13581358 -- ^ what to sum
1359− -> Expression schema relations ('Grouped bys) params (nullity ty)
1359+ -> Expression schema from ('Grouped bys) params (nullity ty)
13601360sum_ = unsafeAggregate "sum"
13611361
13621362-- | >>> :{
@@ -1368,18 +1368,18 @@ sum_ = unsafeAggregate "sum"
13681368-- sum(DISTINCT "col")
13691369sumDistinct
13701370 :: PGNum ty
1371− => Expression schema relations 'Ungrouped params (nullity ty)
1371+ => Expression schema from 'Ungrouped params (nullity ty)
13721372 -- ^ what to sum
1373− -> Expression schema relations ('Grouped bys) params (nullity ty)
1373+ -> Expression schema from ('Grouped bys) params (nullity ty)
13741374sumDistinct = unsafeAggregateDistinct "sum"
13751375
13761376-- | A constraint for `PGType`s that you can take averages of and the resulting
13771377-- `PGType`.
13781378class PGAvg ty avg | ty -> avg where
13791379 avg, avgDistinct
1380− :: Expression schema relations 'Ungrouped params (nullity ty)
1380+ :: Expression schema from 'Ungrouped params (nullity ty)
13811381 -- ^ what to average
1382− -> Expression schema relations ('Grouped bys) params (nullity avg)
1382+ -> Expression schema from ('Grouped bys) params (nullity avg)
13831383 avg = unsafeAggregate "avg"
13841384 avgDistinct = unsafeAggregateDistinct "avg"
13851385instance PGAvg 'PGint2 'PGnumeric
@@ -1399,9 +1399,9 @@ instance PGAvg 'PGinterval 'PGinterval
13991399-- bit_and("col")
14001400bitAnd
14011401 :: PGIntegral int
1402− => Expression schema relations 'Ungrouped params (nullity int)
1402+ => Expression schema from 'Ungrouped params (nullity int)
14031403 -- ^ what to aggregate
1404− -> Expression schema relations ('Grouped bys) params (nullity int)
1404+ -> Expression schema from ('Grouped bys) params (nullity int)
14051405bitAnd = unsafeAggregate "bit_and"
14061406
14071407-- | >>> :{
@@ -1413,9 +1413,9 @@ bitAnd = unsafeAggregate "bit_and"
14131413-- bit_or("col")
14141414bitOr
14151415 :: PGIntegral int
1416− => Expression schema relations 'Ungrouped params (nullity int)
1416+ => Expression schema from 'Ungrouped params (nullity int)
14171417 -- ^ what to aggregate
1418− -> Expression schema relations ('Grouped bys) params (nullity int)
1418+ -> Expression schema from ('Grouped bys) params (nullity int)
14191419bitOr = unsafeAggregate "bit_or"
14201420
14211421-- | >>> :{
@@ -1427,9 +1427,9 @@ bitOr = unsafeAggregate "bit_or"
14271427-- bit_and(DISTINCT "col")
14281428bitAndDistinct
14291429 :: PGIntegral int
1430− => Expression schema relations 'Ungrouped params (nullity int)
1430+ => Expression schema from 'Ungrouped params (nullity int)
14311431 -- ^ what to aggregate
1432− -> Expression schema relations ('Grouped bys) params (nullity int)
1432+ -> Expression schema from ('Grouped bys) params (nullity int)
14331433bitAndDistinct = unsafeAggregateDistinct "bit_and"
14341434
14351435-- | >>> :{
@@ -1441,9 +1441,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
14411441-- bit_or(DISTINCT "col")
14421442bitOrDistinct
14431443 :: PGIntegral int
1444− => Expression schema relations 'Ungrouped params (nullity int)
1444+ => Expression schema from 'Ungrouped params (nullity int)
14451445 -- ^ what to aggregate
1446− -> Expression schema relations ('Grouped bys) params (nullity int)
1446+ -> Expression schema from ('Grouped bys) params (nullity int)
14471447bitOrDistinct = unsafeAggregateDistinct "bit_or"
14481448
14491449-- | >>> :{
@@ -1454,9 +1454,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
14541454-- :}
14551455-- bool_and("col")
14561456boolAnd
1457− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1457+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14581458 -- ^ what to aggregate
1459− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1459+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14601460boolAnd = unsafeAggregate "bool_and"
14611461
14621462-- | >>> :{
@@ -1467,9 +1467,9 @@ boolAnd = unsafeAggregate "bool_and"
14671467-- :}
14681468-- bool_or("col")
14691469boolOr
1470− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1470+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14711471 -- ^ what to aggregate
1472− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1472+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14731473boolOr = unsafeAggregate "bool_or"
14741474
14751475-- | >>> :{
@@ -1480,9 +1480,9 @@ boolOr = unsafeAggregate "bool_or"
14801480-- :}
14811481-- bool_and(DISTINCT "col")
14821482boolAndDistinct
1483− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1483+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14841484 -- ^ what to aggregate
1485− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1485+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14861486boolAndDistinct = unsafeAggregateDistinct "bool_and"
14871487
14881488-- | >>> :{
@@ -1493,9 +1493,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
14931493-- :}
14941494-- bool_or(DISTINCT "col")
14951495boolOrDistinct
1496− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1496+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14971497 -- ^ what to aggregate
1498− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1498+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14991499boolOrDistinct = unsafeAggregateDistinct "bool_or"
15001500
15011501-- | A special aggregation that does not require an input
@@ -1503,7 +1503,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
15031503-- >>> printSQL countStar
15041504-- count(*)
15051505countStar
1506− :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1506+ :: Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
15071507countStar = UnsafeExpression $ "count(*)"
15081508
15091509-- | >>> :{
@@ -1514,9 +1514,9 @@ countStar = UnsafeExpression $ "count(*)"
15141514-- :}
15151515-- count("col")
15161516count
1517− :: Expression schema relations 'Ungrouped params ty
1517+ :: Expression schema from 'Ungrouped params ty
15181518 -- ^ what to count
1519− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1519+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
15201520count = unsafeAggregate "count"
15211521
15221522-- | >>> :{
@@ -1527,9 +1527,9 @@ count = unsafeAggregate "count"
15271527-- :}
15281528-- count(DISTINCT "col")
15291529countDistinct
1530− :: Expression schema relations 'Ungrouped params ty
1530+ :: Expression schema from 'Ungrouped params ty
15311531 -- ^ what to count
1532− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1532+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
15331533countDistinct = unsafeAggregateDistinct "count"
15341534
15351535-- | synonym for `boolAnd`
@@ -1542,9 +1542,9 @@ countDistinct = unsafeAggregateDistinct "count"
15421542-- :}
15431543-- every("col")
15441544every
1545− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1545+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
15461546 -- ^ what to aggregate
1547− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1547+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
15481548every = unsafeAggregate "every"
15491549
15501550-- | synonym for `boolAndDistinct`
@@ -1557,16 +1557,16 @@ every = unsafeAggregate "every"
15571557-- :}
15581558-- every(DISTINCT "col")
15591559everyDistinct
1560− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1560+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
15611561 -- ^ what to aggregate
1562− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1562+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
15631563everyDistinct = unsafeAggregateDistinct "every"
15641564
15651565-- | minimum and maximum aggregation
15661566max_, min_, maxDistinct, minDistinct
1567− :: Expression schema relations 'Ungrouped params (nullity ty)
1567+ :: Expression schema from 'Ungrouped params (nullity ty)
15681568 -- ^ what to aggregate
1569− -> Expression schema relations ('Grouped bys) params (nullity ty)
1569+ -> Expression schema from ('Grouped bys) params (nullity ty)
15701570max_ = unsafeAggregate "max"
15711571min_ = unsafeAggregate "min"
15721572maxDistinct = unsafeAggregateDistinct "max"