@@ -239,16 +239,16 @@ values from primitive expression using arithmetic, logical,
239239and other operations.
240240-}
241241newtype Expression
242+ (grp :: Grouping)
242243 (commons :: FromType)
243244 (schemas :: SchemasType)
244245 (params :: [NullityType])
245− (grp :: Grouping)
246246 (from :: FromType)
247247 (ty :: NullityType)
248248 = UnsafeExpression { renderExpression :: ByteString }
249249 deriving (GHC.Generic,Show,Eq,Ord,NFData)
250250
251−instance RenderSQL (Expression commons schemas params grp from ty) where
251+instance RenderSQL (Expression grp commons schemas params from ty) where
252252 renderSQL = renderExpression
253253
254254{- | A `HasParameter` constraint is used to indicate a value that is
@@ -271,7 +271,7 @@ class KnownNat n => HasParameter
271271 -- ($1 :: int4)
272272 parameter
273273 :: TypeExpression schemas ty
274− -> Expression commons schemas params grp from ty
274+ -> Expression grp commons schemas params from ty
275275 parameter ty = UnsafeExpression $ parenthesized $
276276 "$" <> renderNat @n <+> "::"
277277 <+> renderSQL ty
@@ -288,32 +288,32 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
288288param
289289 :: forall n commons schemas params from grp ty
290290 . (PGTyped schemas ty, HasParameter n params ty)
291− => Expression commons schemas params grp from ty -- ^ param
291+ => Expression grp commons schemas params from ty -- ^ param
292292param = parameter @n (pgtype @schemas)
293293
294294instance (HasUnique tab from row, Has col row ty)
295− => IsLabel col (Expression commons schemas params 'Ungrouped from ty) where
295+ => IsLabel col (Expression 'Ungrouped commons schemas params from ty) where
296296 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
297297instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
298298 => IsLabel col
299− (Aliased (Expression commons schemas params 'Ungrouped from) column) where
299+ (Aliased (Expression 'Ungrouped commons schemas params from) column) where
300300 fromLabel = fromLabel @col `As` Alias
301301instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
302302 => IsLabel col
303− (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
303+ (NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns) where
304304 fromLabel = fromLabel @col :* Nil
305305
306306instance (Has tab from row, Has col row ty)
307− => IsQualified tab col (Expression commons schemas params 'Ungrouped from ty) where
307+ => IsQualified tab col (Expression 'Ungrouped commons schemas params from ty) where
308308 tab ! col = UnsafeExpression $
309309 renderSQL tab <> "." <> renderSQL col
310310instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
311311 => IsQualified tab col
312− (Aliased (Expression commons schemas params 'Ungrouped from) column) where
312+ (Aliased (Expression 'Ungrouped commons schemas params from) column) where
313313 tab ! col = tab ! col `As` col
314314instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
315315 => IsQualified tab col
316− (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
316+ (NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns) where
317317 tab ! col = tab ! col :* Nil
318318
319319instance
@@ -321,7 +321,7 @@ instance
321321 , Has col row ty
322322 , GroupedBy tab col bys
323323 ) => IsLabel col
324− (Expression commons schemas params ('Grouped bys) from ty) where
324+ (Expression ('Grouped bys) commons schemas params from ty) where
325325 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
326326instance
327327 ( HasUnique tab from row
@@ -329,7 +329,7 @@ instance
329329 , GroupedBy tab col bys
330330 , column ~ (col ::: ty)
331331 ) => IsLabel col
332− (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
332+ (Aliased (Expression ('Grouped bys) commons schemas params from) column) where
333333 fromLabel = fromLabel @col `As` Alias
334334instance
335335 ( HasUnique tab from row
@@ -337,7 +337,7 @@ instance
337337 , GroupedBy tab col bys
338338 , columns ~ '[col ::: ty]
339339 ) => IsLabel col
340− (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
340+ (NP (Aliased (Expression ('Grouped bys) commons schemas params from)) columns) where
341341 fromLabel = fromLabel @col :* Nil
342342
343343instance
@@ -345,7 +345,7 @@ instance
345345 , Has col row ty
346346 , GroupedBy tab col bys
347347 ) => IsQualified tab col
348− (Expression commons schemas params ('Grouped bys) from ty) where
348+ (Expression ('Grouped bys) commons schemas params from ty) where
349349 tab ! col = UnsafeExpression $
350350 renderSQL tab <> "." <> renderSQL col
351351instance
@@ -354,7 +354,7 @@ instance
354354 , GroupedBy tab col bys
355355 , column ~ (col ::: ty)
356356 ) => IsQualified tab col
357− (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
357+ (Aliased (Expression ('Grouped bys) commons schemas params from) column) where
358358 tab ! col = tab ! col `As` col
359359instance
360360 ( Has tab from row
@@ -362,7 +362,7 @@ instance
362362 , GroupedBy tab col bys
363363 , columns ~ '[col ::: ty]
364364 ) => IsQualified tab col
365− (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
365+ (NP (Aliased (Expression ('Grouped bys) commons schemas params from)) columns) where
366366 tab ! col = tab ! col :* Nil
367367
368368-- | analagous to `Nothing`
@@ -386,11 +386,11 @@ notNull = UnsafeExpression . renderSQL
386386-- >>> printSQL $ coalesce [null_, true] false
387387-- COALESCE(NULL, TRUE, FALSE)
388388coalesce
389− :: [Expression commons schemas params grp from ('Null ty)]
389+ :: [Expression grp commons schemas params from ('Null ty)]
390390 -- ^ @NULL@s may be present
391− -> Expression commons schemas params grp from ('NotNull ty)
391+ -> Expression grp commons schemas params from ('NotNull ty)
392392 -- ^ @NULL@ is absent
393− -> Expression commons schemas params grp from ('NotNull ty)
393+ -> Expression grp commons schemas params from ('NotNull ty)
394394coalesce nullxs notNullx = UnsafeExpression $
395395 "COALESCE" <> parenthesized (commaSeparated
396396 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
@@ -400,26 +400,26 @@ coalesce nullxs notNullx = UnsafeExpression $
400400-- >>> printSQL $ fromNull true null_
401401-- COALESCE(NULL, TRUE)
402402fromNull
403− :: Expression commons schemas params grp from ('NotNull ty)
403+ :: Expression grp commons schemas params from ('NotNull ty)
404404 -- ^ what to convert @NULL@ to
405− -> Expression commons schemas params grp from ('Null ty)
406− -> Expression commons schemas params grp from ('NotNull ty)
405+ -> Expression grp commons schemas params from ('Null ty)
406+ -> Expression grp commons schemas params from ('NotNull ty)
407407fromNull notNullx nullx = coalesce [nullx] notNullx
408408
409409-- | >>> printSQL $ null_ & isNull
410410-- NULL IS NULL
411411isNull
412− :: Expression commons schemas params grp from ('Null ty)
412+ :: Expression grp commons schemas params from ('Null ty)
413413 -- ^ possibly @NULL@
414− -> Condition commons schemas params grp from
414+ -> Condition grp commons schemas params from
415415isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
416416
417417-- | >>> printSQL $ null_ & isNotNull
418418-- NULL IS NOT NULL
419419isNotNull
420− :: Expression commons schemas params grp from ('Null ty)
420+ :: Expression grp commons schemas params from ('Null ty)
421421 -- ^ possibly @NULL@
422− -> Condition commons schemas params grp from
422+ -> Condition grp commons schemas params from
423423isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
424424
425425-- | analagous to `maybe` using @IS NULL@
@@ -427,13 +427,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
427427-- >>> printSQL $ matchNull true not_ null_
428428-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
429429matchNull
430− :: Expression commons schemas params grp from (nullty)
430+ :: Expression grp commons schemas params from (nullty)
431431 -- ^ what to convert @NULL@ to
432− -> ( Expression commons schemas params grp from ('NotNull ty)
433− -> Expression commons schemas params grp from (nullty) )
432+ -> ( Expression grp commons schemas params from ('NotNull ty)
433+ -> Expression grp commons schemas params from (nullty) )
434434 -- ^ function to perform when @NULL@ is absent
435− -> Expression commons schemas params grp from ('Null ty)
436− -> Expression commons schemas params grp from (nullty)
435+ -> Expression grp commons schemas params from ('Null ty)
436+ -> Expression grp commons schemas params from (nullty)
437437matchNull y f x = ifThenElse (isNull x) y
438438 (f (UnsafeExpression (renderSQL x)))
439439
@@ -446,20 +446,20 @@ matchNull y f x = ifThenElse (isNull x) y
446446NULL IF (FALSE, ($1 :: bool))
447447-}
448448nullIf
449− :: Expression commons schemas params grp from ('NotNull ty)
449+ :: Expression grp commons schemas params from ('NotNull ty)
450450 -- ^ @NULL@ is absent
451− -> Expression commons schemas params grp from ('NotNull ty)
451+ -> Expression grp commons schemas params from ('NotNull ty)
452452 -- ^ @NULL@ is absent
453− -> Expression commons schemas params grp from ('Null ty)
453+ -> Expression grp commons schemas params from ('Null ty)
454454nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
455455 (renderSQL x <> ", " <> renderSQL y)
456456
457457-- | >>> printSQL $ array [null_, false, true]
458458-- ARRAY[NULL, FALSE, TRUE]
459459array
460− :: [Expression commons schemas params grp from ty]
460+ :: [Expression grp commons schemas params from ty]
461461 -- ^ array elements
462− -> Expression commons schemas params grp from (nullity ('PGvararray ty))
462+ -> Expression grp commons schemas params from (nullity ('PGvararray ty))
463463array xs = UnsafeExpression $
464464 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
465465
@@ -467,13 +467,13 @@ array xs = UnsafeExpression $
467467-- (ARRAY[NULL, FALSE, TRUE])[2]
468468index
469469 :: Word64 -- ^ index
470− -> Expression commons schemas params grp from (nullity ('PGvararray ty)) -- ^ array
471− -> Expression commons schemas params grp from (NullifyType ty)
470+ -> Expression grp commons schemas params from (nullity ('PGvararray ty)) -- ^ array
471+ -> Expression grp commons schemas params from (NullifyType ty)
472472index n expr = UnsafeExpression $
473473 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
474474
475475instance (KnownSymbol label, label `In` labels) => IsPGlabel label
476− (Expression commons schemas params grp from (nullity ('PGenum labels))) where
476+ (Expression grp commons schemas params from (nullity ('PGenum labels))) where
477477 label = UnsafeExpression $ renderSQL (PGlabel @label)
478478
479479-- | A row constructor is an expression that builds a row value
@@ -485,14 +485,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
485485-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
486486-- :}
487487--
488−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression commons schemas from grp params ('NotNull Complex)
488+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression grp commons schemas params from ('NotNull Complex)
489489-- >>> printSQL i
490490-- ROW(0, 1)
491491row
492492 :: SListI row
493− => NP (Aliased (Expression commons schemas params grp from)) row
493+ => NP (Aliased (Expression grp commons schemas params from)) row
494494 -- ^ zero or more expressions for the row field values
495− -> Expression commons schemas params grp from (nullity ('PGcomposite row))
495+ -> Expression grp commons schemas params from (nullity ('PGcomposite row))
496496row exprs = UnsafeExpression $ "ROW" <> parenthesized
497497 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
498498
@@ -512,18 +512,18 @@ field
512512 , Has field row ty)
513513 => QualifiedAlias sch tydef -- ^ row type
514514 -> Alias field -- ^ field name
515− -> Expression commons schemas params grp from ('NotNull ('PGcomposite row))
516− -> Expression commons schemas params grp from ty
515+ -> Expression grp commons schemas params from ('NotNull ('PGcomposite row))
516+ -> Expression grp commons schemas params from ty
517517field td fld expr = UnsafeExpression $
518518 parenthesized (renderSQL expr <> "::" <> renderSQL td)
519519 <> "." <> renderSQL fld
520520
521521instance Semigroup
522− (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
522+ (Expression grp commons schemas params from (nullity ('PGvararray ty))) where
523523 (<>) = unsafeBinaryOp "||"
524524
525525instance Monoid
526− (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
526+ (Expression grp commons schemas params from (nullity ('PGvararray ty))) where
527527 mempty = array []
528528 mappend = (<>)
529529
@@ -531,22 +531,22 @@ instance Monoid
531531-- >>> printSQL expr
532532-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
533533greatest
534− :: Expression commons schemas params grp from (nullty)
534+ :: Expression grp commons schemas params from (nullty)
535535 -- ^ needs at least 1 argument
536− -> [Expression commons schemas params grp from (nullty)]
536+ -> [Expression grp commons schemas params from (nullty)]
537537 -- ^ or more
538− -> Expression commons schemas params grp from (nullty)
538+ -> Expression grp commons schemas params from (nullty)
539539greatest x xs = UnsafeExpression $ "GREATEST("
540540 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
541541
542542-- | >>> printSQL $ least currentTimestamp [null_]
543543-- LEAST(CURRENT_TIMESTAMP, NULL)
544544least
545− :: Expression commons schemas params grp from (nullty)
545+ :: Expression grp commons schemas params from (nullty)
546546 -- ^ needs at least 1 argument
547− -> [Expression commons schemas params grp from (nullty)]
547+ -> [Expression grp commons schemas params from (nullty)]
548548 -- ^ or more
549− -> Expression commons schemas params grp from (nullty)
549+ -> Expression grp commons schemas params from (nullty)
550550least x xs = UnsafeExpression $ "LEAST("
551551 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
552552
@@ -555,9 +555,9 @@ least x xs = UnsafeExpression $ "LEAST("
555555unsafeBinaryOp
556556 :: ByteString
557557 -- ^ operator
558− -> Expression commons schemas params grp from (ty0)
559− -> Expression commons schemas params grp from (ty1)
560− -> Expression commons schemas params grp from (ty2)
558+ -> Expression grp commons schemas params from (ty0)
559+ -> Expression grp commons schemas params from (ty1)
560+ -> Expression grp commons schemas params from (ty2)
561561unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
562562 renderSQL x <+> op <+> renderSQL y
563563
@@ -566,8 +566,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
566566unsafeUnaryOp
567567 :: ByteString
568568 -- ^ operator
569− -> Expression commons schemas params grp from (ty0)
570− -> Expression commons schemas params grp from (ty1)
569+ -> Expression grp commons schemas params from (ty0)
570+ -> Expression grp commons schemas params from (ty1)
571571unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
572572 op <+> renderSQL x
573573
@@ -576,8 +576,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
576576unsafeFunction
577577 :: ByteString
578578 -- ^ function
579− -> Expression commons schemas params grp from (xty)
580− -> Expression commons schemas params grp from (yty)
579+ -> Expression grp commons schemas params from (xty)
580+ -> Expression grp commons schemas params from (yty)
581581unsafeFunction fun x = UnsafeExpression $
582582 fun <> parenthesized (renderSQL x)
583583
@@ -586,13 +586,13 @@ unsafeVariadicFunction
586586 :: SListI elems
587587 => ByteString
588588 -- ^ function
589− -> NP (Expression commons schemas params grp from) elems
590− -> Expression commons schemas params grp from ret
589+ -> NP (Expression grp commons schemas params from) elems
590+ -> Expression grp commons schemas params from ret
591591unsafeVariadicFunction fun x = UnsafeExpression $
592592 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
593593
594594instance ty `In` PGNum
595− => Num (Expression commons schemas params grp from (nullity ty)) where
595+ => Num (Expression grp commons schemas params from (nullity ty)) where
596596 (+) = unsafeBinaryOp "+"
597597 (-) = unsafeBinaryOp "-"
598598 (*) = unsafeBinaryOp "*"
@@ -604,12 +604,12 @@ instance ty `In` PGNum
604604 . show
605605
606606instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
607− (Expression commons schemas params grp from (nullity ty)) where
607+ (Expression grp commons schemas params from (nullity ty)) where
608608 (/) = unsafeBinaryOp "/"
609609 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
610610
611611instance (ty `In` PGNum, ty `In` PGFloating) => Floating
612− (Expression commons schemas params grp from (nullity ty)) where
612+ (Expression grp commons schemas params from (nullity ty)) where
613613 pi = UnsafeExpression "pi()"
614614 exp = unsafeFunction "exp"
615615 log = unsafeFunction "ln"
@@ -632,18 +632,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
632632
633633-- | >>> :{
634634-- let
635−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
635+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
636636-- expression = atan2_ pi 2
637637-- in printSQL expression
638638-- :}
639639-- atan2(pi(), 2)
640640atan2_
641641 :: float `In` PGFloating
642− => Expression commons schemas params grp from (nullity float)
642+ => Expression grp commons schemas params from (nullity float)
643643 -- ^ numerator
644− -> Expression commons schemas params grp from (nullity float)
644+ -> Expression grp commons schemas params from (nullity float)
645645 -- ^ denominator
646− -> Expression commons schemas params grp from (nullity float)
646+ -> Expression grp commons schemas params from (nullity float)
647647atan2_ y x = UnsafeExpression $
648648 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
649649
@@ -656,9 +656,9 @@ atan2_ y x = UnsafeExpression $
656656cast
657657 :: TypeExpression schemas ty1
658658 -- ^ type to cast as
659− -> Expression commons schemas params grp from ty0
659+ -> Expression grp commons schemas params from ty0
660660 -- ^ value to convert
661− -> Expression commons schemas params grp from ty1
661+ -> Expression grp commons schemas params from ty1
662662cast ty x = UnsafeExpression $ parenthesized $
663663 renderSQL x <+> "::" <+> renderSQL ty
664664
@@ -666,136 +666,136 @@ cast ty x = UnsafeExpression $ parenthesized $
666666--
667667-- >>> :{
668668-- let
669−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
669+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
670670-- expression = 5 `quot_` 2
671671-- in printSQL expression
672672-- :}
673673-- (5 / 2)
674674quot_
675675 :: int `In` PGIntegral
676− => Expression commons schemas params grp from (nullity int)
676+ => Expression grp commons schemas params from (nullity int)
677677 -- ^ numerator
678− -> Expression commons schemas params grp from (nullity int)
678+ -> Expression grp commons schemas params from (nullity int)
679679 -- ^ denominator
680− -> Expression commons schemas params grp from (nullity int)
680+ -> Expression grp commons schemas params from (nullity int)
681681quot_ = unsafeBinaryOp "/"
682682
683683-- | remainder upon integer division
684684--
685685-- >>> :{
686686-- let
687−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
687+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
688688-- expression = 5 `rem_` 2
689689-- in printSQL expression
690690-- :}
691691-- (5 % 2)
692692rem_
693693 :: int `In` PGIntegral
694− => Expression commons schemas params grp from (nullity int)
694+ => Expression grp commons schemas params from (nullity int)
695695 -- ^ numerator
696− -> Expression commons schemas params grp from (nullity int)
696+ -> Expression grp commons schemas params from (nullity int)
697697 -- ^ denominator
698− -> Expression commons schemas params grp from (nullity int)
698+ -> Expression grp commons schemas params from (nullity int)
699699rem_ = unsafeBinaryOp "%"
700700
701701-- | >>> :{
702702-- let
703−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
703+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
704704-- expression = trunc pi
705705-- in printSQL expression
706706-- :}
707707-- trunc(pi())
708708trunc
709709 :: frac `In` PGFloating
710− => Expression commons schemas params grp from (nullity frac)
710+ => Expression grp commons schemas params from (nullity frac)
711711 -- ^ fractional number
712− -> Expression commons schemas params grp from (nullity frac)
712+ -> Expression grp commons schemas params from (nullity frac)
713713trunc = unsafeFunction "trunc"
714714
715715-- | >>> :{
716716-- let
717−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
717+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
718718-- expression = round_ pi
719719-- in printSQL expression
720720-- :}
721721-- round(pi())
722722round_
723723 :: frac `In` PGFloating
724− => Expression commons schemas params grp from (nullity frac)
724+ => Expression grp commons schemas params from (nullity frac)
725725 -- ^ fractional number
726− -> Expression commons schemas params grp from (nullity frac)
726+ -> Expression grp commons schemas params from (nullity frac)
727727round_ = unsafeFunction "round"
728728
729729-- | >>> :{
730730-- let
731−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
731+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
732732-- expression = ceiling_ pi
733733-- in printSQL expression
734734-- :}
735735-- ceiling(pi())
736736ceiling_
737737 :: frac `In` PGFloating
738− => Expression commons schemas params grp from (nullity frac)
738+ => Expression grp commons schemas params from (nullity frac)
739739 -- ^ fractional number
740− -> Expression commons schemas params grp from (nullity frac)
740+ -> Expression grp commons schemas params from (nullity frac)
741741ceiling_ = unsafeFunction "ceiling"
742742
743743-- | A `Condition` is an `Expression`, which can evaluate
744744-- to `true`, `false` or `null_`. This is because SQL uses
745745-- a three valued logic.
746−type Condition commons schemas params grp from =
747− Expression commons schemas params grp from ('Null 'PGbool)
746+type Condition grp commons schemas params from =
747+ Expression grp commons schemas params from ('Null 'PGbool)
748748
749749-- | >>> printSQL true
750750-- TRUE
751−true :: Expression commons schemas params grp from (nullity 'PGbool)
751+true :: Expression grp commons schemas params from (nullity 'PGbool)
752752true = UnsafeExpression "TRUE"
753753
754754-- | >>> printSQL false
755755-- FALSE
756−false :: Expression commons schemas params grp from (nullity 'PGbool)
756+false :: Expression grp commons schemas params from (nullity 'PGbool)
757757false = UnsafeExpression "FALSE"
758758
759759-- | >>> printSQL $ not_ true
760760-- (NOT TRUE)
761761not_
762− :: Expression commons schemas params grp from (nullity 'PGbool)
763− -> Expression commons schemas params grp from (nullity 'PGbool)
762+ :: Expression grp commons schemas params from (nullity 'PGbool)
763+ -> Expression grp commons schemas params from (nullity 'PGbool)
764764not_ = unsafeUnaryOp "NOT"
765765
766766-- | >>> printSQL $ true .&& false
767767-- (TRUE AND FALSE)
768768(.&&)
769− :: Expression commons schemas params grp from (nullity 'PGbool)
770− -> Expression commons schemas params grp from (nullity 'PGbool)
771− -> Expression commons schemas params grp from (nullity 'PGbool)
769+ :: Expression grp commons schemas params from (nullity 'PGbool)
770+ -> Expression grp commons schemas params from (nullity 'PGbool)
771+ -> Expression grp commons schemas params from (nullity 'PGbool)
772772infixr 3 .&&
773773(.&&) = unsafeBinaryOp "AND"
774774
775775-- | >>> printSQL $ true .|| false
776776-- (TRUE OR FALSE)
777777(.||)
778− :: Expression commons schemas params grp from (nullity 'PGbool)
779− -> Expression commons schemas params grp from (nullity 'PGbool)
780− -> Expression commons schemas params grp from (nullity 'PGbool)
778+ :: Expression grp commons schemas params from (nullity 'PGbool)
779+ -> Expression grp commons schemas params from (nullity 'PGbool)
780+ -> Expression grp commons schemas params from (nullity 'PGbool)
781781infixr 2 .||
782782(.||) = unsafeBinaryOp "OR"
783783
784784-- | >>> :{
785785-- let
786−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
786+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
787787-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
788788-- in printSQL expression
789789-- :}
790790-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
791791caseWhenThenElse
792− :: [ ( Condition commons schemas params grp from
793− , Expression commons schemas params grp from ty
792+ :: [ ( Condition grp commons schemas params from
793+ , Expression grp commons schemas params from ty
794794 ) ]
795795 -- ^ whens and thens
796− -> Expression commons schemas params grp from ty
796+ -> Expression grp commons schemas params from ty
797797 -- ^ else
798− -> Expression commons schemas params grp from ty
798+ -> Expression grp commons schemas params from ty
799799caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
800800 [ "CASE"
801801 , mconcat
@@ -811,16 +811,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
811811
812812-- | >>> :{
813813-- let
814−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
814+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
815815-- expression = ifThenElse true 1 0
816816-- in printSQL expression
817817-- :}
818818-- CASE WHEN TRUE THEN 1 ELSE 0 END
819819ifThenElse
820− :: Condition commons schemas params grp from
821− -> Expression commons schemas params grp from ty -- ^ then
822− -> Expression commons schemas params grp from ty -- ^ else
823− -> Expression commons schemas params grp from ty
820+ :: Condition grp commons schemas params from
821+ -> Expression grp commons schemas params from ty -- ^ then
822+ -> Expression grp commons schemas params from ty -- ^ else
823+ -> Expression grp commons schemas params from ty
824824ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
825825
826826-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -829,85 +829,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
829829-- >>> printSQL $ true .== null_
830830-- (TRUE = NULL)
831831(.==)
832− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
833− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
834− -> Condition commons schemas params grp from
832+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
833+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
834+ -> Condition grp commons schemas params from
835835(.==) = unsafeBinaryOp "="
836836infix 4 .==
837837
838838-- | >>> printSQL $ true ./= null_
839839-- (TRUE <> NULL)
840840(./=)
841− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
842− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
843− -> Condition commons schemas params grp from
841+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
842+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
843+ -> Condition grp commons schemas params from
844844(./=) = unsafeBinaryOp "<>"
845845infix 4 ./=
846846
847847-- | >>> printSQL $ true .>= null_
848848-- (TRUE >= NULL)
849849(.>=)
850− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
851− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
852− -> Condition commons schemas params grp from
850+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
851+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
852+ -> Condition grp commons schemas params from
853853(.>=) = unsafeBinaryOp ">="
854854infix 4 .>=
855855
856856-- | >>> printSQL $ true .< null_
857857-- (TRUE < NULL)
858858(.<)
859− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
860− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
861− -> Condition commons schemas params grp from
859+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
860+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
861+ -> Condition grp commons schemas params from
862862(.<) = unsafeBinaryOp "<"
863863infix 4 .<
864864
865865-- | >>> printSQL $ true .<= null_
866866-- (TRUE <= NULL)
867867(.<=)
868− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
869− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
870− -> Condition commons schemas params grp from
868+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
869+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
870+ -> Condition grp commons schemas params from
871871(.<=) = unsafeBinaryOp "<="
872872infix 4 .<=
873873
874874-- | >>> printSQL $ true .> null_
875875-- (TRUE > NULL)
876876(.>)
877− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
878− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
879− -> Condition commons schemas params grp from
877+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
878+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
879+ -> Condition grp commons schemas params from
880880(.>) = unsafeBinaryOp ">"
881881infix 4 .>
882882
883883-- | >>> printSQL currentDate
884884-- CURRENT_DATE
885885currentDate
886− :: Expression commons schemas params grp from (nullity 'PGdate)
886+ :: Expression grp commons schemas params from (nullity 'PGdate)
887887currentDate = UnsafeExpression "CURRENT_DATE"
888888
889889-- | >>> printSQL currentTime
890890-- CURRENT_TIME
891891currentTime
892− :: Expression commons schemas params grp from (nullity 'PGtimetz)
892+ :: Expression grp commons schemas params from (nullity 'PGtimetz)
893893currentTime = UnsafeExpression "CURRENT_TIME"
894894
895895-- | >>> printSQL currentTimestamp
896896-- CURRENT_TIMESTAMP
897897currentTimestamp
898− :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
898+ :: Expression grp commons schemas params from (nullity 'PGtimestamptz)
899899currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
900900
901901-- | >>> printSQL localTime
902902-- LOCALTIME
903903localTime
904− :: Expression commons schemas params grp from (nullity 'PGtime)
904+ :: Expression grp commons schemas params from (nullity 'PGtime)
905905localTime = UnsafeExpression "LOCALTIME"
906906
907907-- | >>> printSQL localTimestamp
908908-- LOCALTIMESTAMP
909909localTimestamp
910− :: Expression commons schemas params grp from (nullity 'PGtimestamp)
910+ :: Expression grp commons schemas params from (nullity 'PGtimestamp)
911911localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
912912
913913{-----------------------------------------
@@ -915,7 +915,7 @@ text
915915-----------------------------------------}
916916
917917instance IsString
918− (Expression commons schemas params grp from (nullity 'PGtext)) where
918+ (Expression grp commons schemas params from (nullity 'PGtext)) where
919919 fromString str = UnsafeExpression $
920920 "E\'" <> fromString (escape =<< str) <> "\'"
921921 where
@@ -931,36 +931,36 @@ instance IsString
931931 c -> [c]
932932
933933instance Semigroup
934− (Expression commons schemas params grp from (nullity 'PGtext)) where
934+ (Expression grp commons schemas params from (nullity 'PGtext)) where
935935 (<>) = unsafeBinaryOp "||"
936936
937937instance Monoid
938− (Expression commons schemas params grp from (nullity 'PGtext)) where
938+ (Expression grp commons schemas params from (nullity 'PGtext)) where
939939 mempty = fromString ""
940940 mappend = (<>)
941941
942942-- | >>> printSQL $ lower "ARRRGGG"
943943-- lower(E'ARRRGGG')
944944lower
945− :: Expression commons schemas params grp from (nullity 'PGtext)
945+ :: Expression grp commons schemas params from (nullity 'PGtext)
946946 -- ^ string to lower case
947− -> Expression commons schemas params grp from (nullity 'PGtext)
947+ -> Expression grp commons schemas params from (nullity 'PGtext)
948948lower = unsafeFunction "lower"
949949
950950-- | >>> printSQL $ upper "eeee"
951951-- upper(E'eeee')
952952upper
953− :: Expression commons schemas params grp from (nullity 'PGtext)
953+ :: Expression grp commons schemas params from (nullity 'PGtext)
954954 -- ^ string to upper case
955− -> Expression commons schemas params grp from (nullity 'PGtext)
955+ -> Expression grp commons schemas params from (nullity 'PGtext)
956956upper = unsafeFunction "upper"
957957
958958-- | >>> printSQL $ charLength "four"
959959-- char_length(E'four')
960960charLength
961− :: Expression commons schemas params grp from (nullity 'PGtext)
961+ :: Expression grp commons schemas params from (nullity 'PGtext)
962962 -- ^ string to measure
963− -> Expression commons schemas params grp from (nullity 'PGint4)
963+ -> Expression grp commons schemas params from (nullity 'PGint4)
964964charLength = unsafeFunction "char_length"
965965
966966-- | The `like` expression returns true if the @string@ matches
@@ -973,11 +973,11 @@ charLength = unsafeFunction "char_length"
973973-- >>> printSQL $ "abc" `like` "a%"
974974-- (E'abc' LIKE E'a%')
975975like
976− :: Expression commons schemas params grp from (nullity 'PGtext)
976+ :: Expression grp commons schemas params from (nullity 'PGtext)
977977 -- ^ string
978− -> Expression commons schemas params grp from (nullity 'PGtext)
978+ -> Expression grp commons schemas params from (nullity 'PGtext)
979979 -- ^ pattern
980− -> Expression commons schemas params grp from (nullity 'PGbool)
980+ -> Expression grp commons schemas params from (nullity 'PGbool)
981981like = unsafeBinaryOp "LIKE"
982982
983983-- | The key word ILIKE can be used instead of LIKE to make the
@@ -986,11 +986,11 @@ like = unsafeBinaryOp "LIKE"
986986-- >>> printSQL $ "abc" `ilike` "a%"
987987-- (E'abc' ILIKE E'a%')
988988ilike
989− :: Expression commons schemas params grp from (nullity 'PGtext)
989+ :: Expression grp commons schemas params from (nullity 'PGtext)
990990 -- ^ string
991− -> Expression commons schemas params grp from (nullity 'PGtext)
991+ -> Expression grp commons schemas params from (nullity 'PGtext)
992992 -- ^ pattern
993− -> Expression commons schemas params grp from (nullity 'PGbool)
993+ -> Expression grp commons schemas params from (nullity 'PGbool)
994994ilike = unsafeBinaryOp "ILIKE"
995995
996996{-----------------------------------------
@@ -1005,36 +1005,36 @@ Table 9.44: json and jsonb operators
10051005-- | Get JSON value (object field or array element) at a key.
10061006(.->)
10071007 :: (json `In` PGJsonType, key `In` PGJsonKey)
1008− => Expression commons schemas params grp from (nullity json)
1009− -> Expression commons schemas params grp from (nullity key)
1010− -> Expression commons schemas params grp from ('Null json)
1008+ => Expression grp commons schemas params from (nullity json)
1009+ -> Expression grp commons schemas params from (nullity key)
1010+ -> Expression grp commons schemas params from ('Null json)
10111011infixl 8 .->
10121012(.->) = unsafeBinaryOp "->"
10131013
10141014-- | Get JSON value (object field or array element) at a key, as text.
10151015(.->>)
10161016 :: (json `In` PGJsonType, key `In` PGJsonKey)
1017− => Expression commons schemas params grp from (nullity json)
1018− -> Expression commons schemas params grp from (nullity key)
1019− -> Expression commons schemas params grp from ('Null 'PGtext)
1017+ => Expression grp commons schemas params from (nullity json)
1018+ -> Expression grp commons schemas params from (nullity key)
1019+ -> Expression grp commons schemas params from ('Null 'PGtext)
10201020infixl 8 .->>
10211021(.->>) = unsafeBinaryOp "->>"
10221022
10231023-- | Get JSON value at a specified path.
10241024(.#>)
10251025 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1026− => Expression commons schemas params grp from (nullity json)
1027− -> Expression commons schemas params grp from (nullity path)
1028− -> Expression commons schemas params grp from ('Null json)
1026+ => Expression grp commons schemas params from (nullity json)
1027+ -> Expression grp commons schemas params from (nullity path)
1028+ -> Expression grp commons schemas params from ('Null json)
10291029infixl 8 .#>
10301030(.#>) = unsafeBinaryOp "#>"
10311031
10321032-- | Get JSON value at a specified path as text.
10331033(.#>>)
10341034 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1035− => Expression commons schemas params grp from (nullity json)
1036− -> Expression commons schemas params grp from (nullity path)
1037− -> Expression commons schemas params grp from ('Null 'PGtext)
1035+ => Expression grp commons schemas params from (nullity json)
1036+ -> Expression grp commons schemas params from (nullity path)
1037+ -> Expression grp commons schemas params from ('Null 'PGtext)
10381038infixl 8 .#>>
10391039(.#>>) = unsafeBinaryOp "#>>"
10401040
@@ -1043,42 +1043,42 @@ infixl 8 .#>>
10431043-- | Does the left JSON value contain the right JSON path/value entries at the
10441044-- top level?
10451045(.@>)
1046− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1047− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1048− -> Condition commons schemas params grp from
1046+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1047+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1048+ -> Condition grp commons schemas params from
10491049infixl 9 .@>
10501050(.@>) = unsafeBinaryOp "@>"
10511051
10521052-- | Are the left JSON path/value entries contained at the top level within the
10531053-- right JSON value?
10541054(.<@)
1055− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1056− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1057− -> Condition commons schemas params grp from
1055+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1056+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1057+ -> Condition grp commons schemas params from
10581058infixl 9 .<@
10591059(.<@) = unsafeBinaryOp "<@"
10601060
10611061-- | Does the string exist as a top-level key within the JSON value?
10621062(.?)
1063− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1064− -> Expression commons schemas params grp from (nullity 'PGtext)
1065− -> Condition commons schemas params grp from
1063+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1064+ -> Expression grp commons schemas params from (nullity 'PGtext)
1065+ -> Condition grp commons schemas params from
10661066infixl 9 .?
10671067(.?) = unsafeBinaryOp "?"
10681068
10691069-- | Do any of these array strings exist as top-level keys?
10701070(.?|)
1071− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1072− -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1073− -> Condition commons schemas params grp from
1071+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1072+ -> Expression grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1073+ -> Condition grp commons schemas params from
10741074infixl 9 .?|
10751075(.?|) = unsafeBinaryOp "?|"
10761076
10771077-- | Do all of these array strings exist as top-level keys?
10781078(.?&)
1079− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1080− -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1081− -> Condition commons schemas params grp from
1079+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1080+ -> Expression grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1081+ -> Condition grp commons schemas params from
10821082infixl 9 .?&
10831083(.?&) = unsafeBinaryOp "?&"
10841084
@@ -1101,9 +1101,9 @@ instance
11011101-- count from the end). Throws an error if top level container is not an array.
11021102(.-.)
11031103 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1104− => Expression commons schemas params grp from (nullity 'PGjsonb)
1105− -> Expression commons schemas params grp from (nullity key)
1106− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1104+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1105+ -> Expression grp commons schemas params from (nullity key)
1106+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
11071107infixl 6 .-.
11081108(.-.) = unsafeBinaryOp "-"
11091109
@@ -1111,9 +1111,9 @@ infixl 6 .-.
11111111-- integers count from the end)
11121112(#-.)
11131113 :: PGTextArray "(#-.)" arrayty
1114− => Expression commons schemas params grp from (nullity 'PGjsonb)
1115− -> Expression commons schemas params grp from (nullity arrayty)
1116− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1114+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1115+ -> Expression grp commons schemas params from (nullity arrayty)
1116+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
11171117infixl 6 #-.
11181118(#-.) = unsafeBinaryOp "#-"
11191119
@@ -1124,14 +1124,14 @@ Table 9.45: JSON creation functions
11241124-- | Literal binary JSON
11251125jsonbLit
11261126 :: JSON.ToJSON x
1127− => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
1127+ => x -> Expression grp commons schemas params from (nullity 'PGjsonb)
11281128jsonbLit = cast jsonb . UnsafeExpression
11291129 . singleQuotedUtf8 . toStrict . JSON.encode
11301130
11311131-- | Literal JSON
11321132jsonLit
11331133 :: JSON.ToJSON x
1134− => x -> Expression commons schemas params grp from (nullity 'PGjson)
1134+ => x -> Expression grp commons schemas params from (nullity 'PGjson)
11351135jsonLit = cast json . UnsafeExpression
11361136 . singleQuotedUtf8 . toStrict . JSON.encode
11371137
@@ -1142,8 +1142,8 @@ jsonLit = cast json . UnsafeExpression
11421142-- number, a Boolean, or a null value, the text representation will be used, in
11431143-- such a fashion that it is a valid json value.
11441144toJson
1145− :: Expression commons schemas params grp from (nullity ty)
1146− -> Expression commons schemas params grp from (nullity 'PGjson)
1145+ :: Expression grp commons schemas params from (nullity ty)
1146+ -> Expression grp commons schemas params from (nullity 'PGjson)
11471147toJson = unsafeFunction "to_json"
11481148
11491149-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1153,43 +1153,43 @@ toJson = unsafeFunction "to_json"
11531153-- number, a Boolean, or a null value, the text representation will be used, in
11541154-- such a fashion that it is a valid jsonb value.
11551155toJsonb
1156− :: Expression commons schemas params grp from (nullity ty)
1157− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1156+ :: Expression grp commons schemas params from (nullity ty)
1157+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
11581158toJsonb = unsafeFunction "to_jsonb"
11591159
11601160-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
11611161-- becomes a JSON array of arrays.
11621162arrayToJson
11631163 :: PGArray "arrayToJson" arr
1164− => Expression commons schemas params grp from (nullity arr)
1165− -> Expression commons schemas params grp from (nullity 'PGjson)
1164+ => Expression grp commons schemas params from (nullity arr)
1165+ -> Expression grp commons schemas params from (nullity 'PGjson)
11661166arrayToJson = unsafeFunction "array_to_json"
11671167
11681168-- | Returns the row as a JSON object.
11691169rowToJson
1170− :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1171− -> Expression commons schemas params grp from (nullity 'PGjson)
1170+ :: Expression grp commons schemas params from (nullity ('PGcomposite ty))
1171+ -> Expression grp commons schemas params from (nullity 'PGjson)
11721172rowToJson = unsafeFunction "row_to_json"
11731173
11741174-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
11751175-- argument list.
11761176jsonBuildArray
11771177 :: SListI elems
1178− => NP (Expression commons schemas params grp from) elems
1179− -> Expression commons schemas params grp from (nullity 'PGjson)
1178+ => NP (Expression grp commons schemas params from) elems
1179+ -> Expression grp commons schemas params from (nullity 'PGjson)
11801180jsonBuildArray = unsafeVariadicFunction "json_build_array"
11811181
11821182-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
11831183-- variadic argument list.
11841184jsonbBuildArray
11851185 :: SListI elems
1186− => NP (Expression commons schemas params grp from) elems
1187− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1186+ => NP (Expression grp commons schemas params from) elems
1187+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
11881188jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
11891189
11901190unsafeRowFunction
11911191 :: All Top elems
1192− => NP (Aliased (Expression commons schemas params grp from)) elems
1192+ => NP (Aliased (Expression grp commons schemas params from)) elems
11931193 -> [ByteString]
11941194unsafeRowFunction =
11951195 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1204,8 +1204,8 @@ unsafeRowFunction =
12041204-- and values.
12051205jsonBuildObject
12061206 :: All Top elems
1207− => NP (Aliased (Expression commons schemas params grp from)) elems
1208− -> Expression commons schemas params grp from (nullity 'PGjson)
1207+ => NP (Aliased (Expression grp commons schemas params from)) elems
1208+ -> Expression grp commons schemas params from (nullity 'PGjson)
12091209jsonBuildObject
12101210 = unsafeFunction "json_build_object"
12111211 . UnsafeExpression
@@ -1217,8 +1217,8 @@ jsonBuildObject
12171217-- between text and values.
12181218jsonbBuildObject
12191219 :: All Top elems
1220− => NP (Aliased (Expression commons schemas params grp from)) elems
1221− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1220+ => NP (Aliased (Expression grp commons schemas params from)) elems
1221+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
12221222jsonbBuildObject
12231223 = unsafeFunction "jsonb_build_object"
12241224 . UnsafeExpression
@@ -1231,8 +1231,8 @@ jsonbBuildObject
12311231-- array has exactly two elements, which are taken as a key/value pair.
12321232jsonObject
12331233 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1234− => Expression commons schemas params grp from (nullity arr)
1235− -> Expression commons schemas params grp from (nullity 'PGjson)
1234+ => Expression grp commons schemas params from (nullity arr)
1235+ -> Expression grp commons schemas params from (nullity 'PGjson)
12361236jsonObject = unsafeFunction "json_object"
12371237
12381238-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1241,8 +1241,8 @@ jsonObject = unsafeFunction "json_object"
12411241-- array has exactly two elements, which are taken as a key/value pair.
12421242jsonbObject
12431243 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1244− => Expression commons schemas params grp from (nullity arr)
1245− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1244+ => Expression grp commons schemas params from (nullity arr)
1245+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
12461246jsonbObject = unsafeFunction "jsonb_object"
12471247
12481248-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1250,9 +1250,9 @@ jsonbObject = unsafeFunction "jsonb_object"
12501250jsonZipObject
12511251 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
12521252 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1253− => Expression commons schemas params grp from (nullity keysArray)
1254− -> Expression commons schemas params grp from (nullity valuesArray)
1255− -> Expression commons schemas params grp from (nullity 'PGjson)
1253+ => Expression grp commons schemas params from (nullity keysArray)
1254+ -> Expression grp commons schemas params from (nullity valuesArray)
1255+ -> Expression grp commons schemas params from (nullity 'PGjson)
12561256jsonZipObject ks vs =
12571257 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
12581258
@@ -1262,9 +1262,9 @@ jsonZipObject ks vs =
12621262jsonbZipObject
12631263 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
12641264 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1265− => Expression commons schemas params grp from (nullity keysArray)
1266− -> Expression commons schemas params grp from (nullity valuesArray)
1267− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1265+ => Expression grp commons schemas params from (nullity keysArray)
1266+ -> Expression grp commons schemas params from (nullity valuesArray)
1267+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
12681268jsonbZipObject ks vs =
12691269 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
12701270
@@ -1274,23 +1274,23 @@ Table 9.46: JSON processing functions
12741274
12751275-- | Returns the number of elements in the outermost JSON array.
12761276jsonArrayLength
1277− :: Expression commons schemas params grp from (nullity 'PGjson)
1278− -> Expression commons schemas params grp from (nullity 'PGint4)
1277+ :: Expression grp commons schemas params from (nullity 'PGjson)
1278+ -> Expression grp commons schemas params from (nullity 'PGint4)
12791279jsonArrayLength = unsafeFunction "json_array_length"
12801280
12811281-- | Returns the number of elements in the outermost binary JSON array.
12821282jsonbArrayLength
1283− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1284− -> Expression commons schemas params grp from (nullity 'PGint4)
1283+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1284+ -> Expression grp commons schemas params from (nullity 'PGint4)
12851285jsonbArrayLength = unsafeFunction "jsonb_array_length"
12861286
12871287-- | Returns JSON value pointed to by the given path (equivalent to #>
12881288-- operator).
12891289jsonExtractPath
12901290 :: SListI elems
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 'PGjsonb)
1291+ => Expression grp commons schemas params from (nullity 'PGjson)
1292+ -> NP (Expression grp commons schemas params from) elems
1293+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
12941294jsonExtractPath x xs =
12951295 unsafeVariadicFunction "json_extract_path" (x :* xs)
12961296
@@ -1298,9 +1298,9 @@ jsonExtractPath x xs =
12981298-- operator).
12991299jsonbExtractPath
13001300 :: SListI elems
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)
1301+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1302+ -> NP (Expression grp commons schemas params from) elems
1303+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
13041304jsonbExtractPath x xs =
13051305 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
13061306
@@ -1308,9 +1308,9 @@ jsonbExtractPath x xs =
13081308-- operator), as text.
13091309jsonExtractPathAsText
13101310 :: SListI elems
1311− => Expression commons schemas params grp from (nullity 'PGjson)
1312− -> NP (Expression commons schemas params grp from) elems
1313− -> Expression commons schemas params grp from (nullity 'PGjson)
1311+ => Expression grp commons schemas params from (nullity 'PGjson)
1312+ -> NP (Expression grp commons schemas params from) elems
1313+ -> Expression grp commons schemas params from (nullity 'PGjson)
13141314jsonExtractPathAsText x xs =
13151315 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
13161316
@@ -1318,38 +1318,38 @@ jsonExtractPathAsText x xs =
13181318-- operator), as text.
13191319jsonbExtractPathAsText
13201320 :: SListI elems
1321− => Expression commons schemas params grp from (nullity 'PGjsonb)
1322− -> NP (Expression commons schemas params grp from) elems
1323− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1321+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1322+ -> NP (Expression grp commons schemas params from) elems
1323+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
13241324jsonbExtractPathAsText x xs =
13251325 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
13261326
13271327-- | Returns the type of the outermost JSON value as a text string. Possible
13281328-- types are object, array, string, number, boolean, and null.
13291329jsonTypeof
1330− :: Expression commons schemas params grp from (nullity 'PGjson)
1331− -> Expression commons schemas params grp from (nullity 'PGtext)
1330+ :: Expression grp commons schemas params from (nullity 'PGjson)
1331+ -> Expression grp commons schemas params from (nullity 'PGtext)
13321332jsonTypeof = unsafeFunction "json_typeof"
13331333
13341334-- | Returns the type of the outermost binary JSON value as a text string.
13351335-- Possible types are object, array, string, number, boolean, and null.
13361336jsonbTypeof
1337− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1338− -> Expression commons schemas params grp from (nullity 'PGtext)
1337+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1338+ -> Expression grp commons schemas params from (nullity 'PGtext)
13391339jsonbTypeof = unsafeFunction "jsonb_typeof"
13401340
13411341-- | Returns its argument with all object fields that have null values omitted.
13421342-- Other null values are untouched.
13431343jsonStripNulls
1344− :: Expression commons schemas params grp from (nullity 'PGjson)
1345− -> Expression commons schemas params grp from (nullity 'PGjson)
1344+ :: Expression grp commons schemas params from (nullity 'PGjson)
1345+ -> Expression grp commons schemas params from (nullity 'PGjson)
13461346jsonStripNulls = unsafeFunction "json_strip_nulls"
13471347
13481348-- | Returns its argument with all object fields that have null values omitted.
13491349-- Other null values are untouched.
13501350jsonbStripNulls
1351− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1352− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1351+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1352+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
13531353jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
13541354
13551355-- | @ jsonbSet target path new_value create_missing @
@@ -1361,11 +1361,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
13611361-- arrays.
13621362jsonbSet
13631363 :: PGTextArray "jsonbSet" arr
1364− => Expression commons schemas params grp from (nullity 'PGjsonb)
1365− -> Expression commons schemas params grp from (nullity arr)
1366− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1367− -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1368− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1364+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1365+ -> Expression grp commons schemas params from (nullity arr)
1366+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1367+ -> Maybe (Expression grp commons schemas params from (nullity 'PGbool))
1368+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
13691369jsonbSet tgt path val createMissing = case createMissing of
13701370 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
13711371 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1380,19 +1380,19 @@ jsonbSet tgt path val createMissing = case createMissing of
13801380-- in path count from the end of JSON arrays.
13811381jsonbInsert
13821382 :: PGTextArray "jsonbInsert" arr
1383− => Expression commons schemas params grp from (nullity 'PGjsonb)
1384− -> Expression commons schemas params grp from (nullity arr)
1385− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1386− -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1387− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1383+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1384+ -> Expression grp commons schemas params from (nullity arr)
1385+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1386+ -> Maybe (Expression grp commons schemas params from (nullity 'PGbool))
1387+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
13881388jsonbInsert tgt path val insertAfter = case insertAfter of
13891389 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
13901390 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
13911391
13921392-- | Returns its argument as indented JSON text.
13931393jsonbPretty
1394− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1395− -> Expression commons schemas params grp from (nullity 'PGtext)
1394+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1395+ -> Expression grp commons schemas params from (nullity 'PGtext)
13961396jsonbPretty = unsafeFunction "jsonb_pretty"
13971397
13981398{-----------------------------------------
@@ -1402,54 +1402,54 @@ aggregation
14021402-- | escape hatch to define aggregate functions
14031403unsafeAggregate
14041404 :: ByteString -- ^ aggregate function
1405− -> Expression commons schemas from 'Ungrouped params (xty)
1406− -> Expression commons schemas from ('Grouped bys) params (yty)
1405+ -> Expression 'Ungrouped commons schemas params from xty
1406+ -> Expression ('Grouped bys) commons schemas params from yty
14071407unsafeAggregate fun x = UnsafeExpression $ mconcat
14081408 [fun, "(", renderSQL x, ")"]
14091409
14101410-- | escape hatch to define aggregate functions over distinct values
14111411unsafeAggregateDistinct
14121412 :: ByteString -- ^ aggregate function
1413− -> Expression commons schemas from 'Ungrouped params (xty)
1414− -> Expression commons schemas from ('Grouped bys) params (yty)
1413+ -> Expression 'Ungrouped commons schemas params from xty
1414+ -> Expression ('Grouped bys) commons schemas params from yty
14151415unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
14161416 [fun, "(DISTINCT ", renderSQL x, ")"]
14171417
14181418-- | >>> :{
14191419-- let
1420−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1420+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
14211421-- expression = sum_ #col
14221422-- in printSQL expression
14231423-- :}
14241424-- sum("col")
14251425sum_
14261426 :: ty `In` PGNum
1427− => Expression commons schemas from 'Ungrouped params (nullity ty)
1427+ => Expression 'Ungrouped commons schemas params from (nullity ty)
14281428 -- ^ what to sum
1429− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1429+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
14301430sum_ = unsafeAggregate "sum"
14311431
14321432-- | >>> :{
14331433-- let
1434−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1434+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
14351435-- expression = sumDistinct #col
14361436-- in printSQL expression
14371437-- :}
14381438-- sum(DISTINCT "col")
14391439sumDistinct
14401440 :: ty `In` PGNum
1441− => Expression commons schemas from 'Ungrouped params (nullity ty)
1441+ => Expression 'Ungrouped commons schemas params from (nullity ty)
14421442 -- ^ what to sum
1443− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1443+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
14441444sumDistinct = unsafeAggregateDistinct "sum"
14451445
14461446-- | A constraint for `PGType`s that you can take averages of and the resulting
14471447-- `PGType`.
14481448class PGAvg ty avg | ty -> avg where
14491449 avg, avgDistinct
1450− :: Expression commons schemas from 'Ungrouped params (nullity ty)
1450+ :: Expression 'Ungrouped commons schemas params from (nullity ty)
14511451 -- ^ what to average
1452− -> Expression commons schemas from ('Grouped bys) params (nullity avg)
1452+ -> Expression ('Grouped bys) commons schemas params from (nullity avg)
14531453 avg = unsafeAggregate "avg"
14541454 avgDistinct = unsafeAggregateDistinct "avg"
14551455instance PGAvg 'PGint2 'PGnumeric
@@ -1469,37 +1469,37 @@ instance PGAvg 'PGinterval 'PGinterval
14691469-- bit_and("col")
14701470bitAnd
14711471 :: int `In` PGIntegral
1472− => Expression commons schemas from 'Ungrouped params (nullity int)
1472+ => Expression 'Ungrouped commons schemas params from (nullity int)
14731473 -- ^ what to aggregate
1474− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1474+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
14751475bitAnd = unsafeAggregate "bit_and"
14761476
14771477-- | >>> :{
14781478-- let
1479−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1479+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
14801480-- expression = bitOr #col
14811481-- in printSQL expression
14821482-- :}
14831483-- bit_or("col")
14841484bitOr
14851485 :: int `In` PGIntegral
1486− => Expression commons schemas from 'Ungrouped params (nullity int)
1486+ => Expression 'Ungrouped commons schemas params from (nullity int)
14871487 -- ^ what to aggregate
1488− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1488+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
14891489bitOr = unsafeAggregate "bit_or"
14901490
14911491-- | >>> :{
14921492-- let
1493−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1493+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
14941494-- expression = bitAndDistinct #col
14951495-- in printSQL expression
14961496-- :}
14971497-- bit_and(DISTINCT "col")
14981498bitAndDistinct
14991499 :: int `In` PGIntegral
1500− => Expression commons schemas from 'Ungrouped params (nullity int)
1500+ => Expression 'Ungrouped commons schemas params from (nullity int)
15011501 -- ^ what to aggregate
1502− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1502+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
15031503bitAndDistinct = unsafeAggregateDistinct "bit_and"
15041504
15051505-- | >>> :{
@@ -1511,9 +1511,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
15111511-- bit_or(DISTINCT "col")
15121512bitOrDistinct
15131513 :: int `In` PGIntegral
1514− => Expression commons schemas from 'Ungrouped params (nullity int)
1514+ => Expression 'Ungrouped commons schemas params from (nullity int)
15151515 -- ^ what to aggregate
1516− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1516+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
15171517bitOrDistinct = unsafeAggregateDistinct "bit_or"
15181518
15191519-- | >>> :{
@@ -1524,9 +1524,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
15241524-- :}
15251525-- bool_and("col")
15261526boolAnd
1527− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1527+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
15281528 -- ^ what to aggregate
1529− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1529+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
15301530boolAnd = unsafeAggregate "bool_and"
15311531
15321532-- | >>> :{
@@ -1537,9 +1537,9 @@ boolAnd = unsafeAggregate "bool_and"
15371537-- :}
15381538-- bool_or("col")
15391539boolOr
1540− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1540+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
15411541 -- ^ what to aggregate
1542− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1542+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
15431543boolOr = unsafeAggregate "bool_or"
15441544
15451545-- | >>> :{
@@ -1550,9 +1550,9 @@ boolOr = unsafeAggregate "bool_or"
15501550-- :}
15511551-- bool_and(DISTINCT "col")
15521552boolAndDistinct
1553− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1553+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
15541554 -- ^ what to aggregate
1555− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1555+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
15561556boolAndDistinct = unsafeAggregateDistinct "bool_and"
15571557
15581558-- | >>> :{
@@ -1563,9 +1563,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
15631563-- :}
15641564-- bool_or(DISTINCT "col")
15651565boolOrDistinct
1566− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1566+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
15671567 -- ^ what to aggregate
1568− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1568+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
15691569boolOrDistinct = unsafeAggregateDistinct "bool_or"
15701570
15711571-- | A special aggregation that does not require an input
@@ -1573,7 +1573,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
15731573-- >>> printSQL countStar
15741574-- count(*)
15751575countStar
1576− :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1576+ :: Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
15771577countStar = UnsafeExpression $ "count(*)"
15781578
15791579-- | >>> :{
@@ -1584,9 +1584,9 @@ countStar = UnsafeExpression $ "count(*)"
15841584-- :}
15851585-- count("col")
15861586count
1587− :: Expression commons schemas from 'Ungrouped params ty
1587+ :: Expression 'Ungrouped commons schemas params from ty
15881588 -- ^ what to count
1589− -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1589+ -> Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
15901590count = unsafeAggregate "count"
15911591
15921592-- | >>> :{
@@ -1597,9 +1597,9 @@ count = unsafeAggregate "count"
15971597-- :}
15981598-- count(DISTINCT "col")
15991599countDistinct
1600− :: Expression commons schemas from 'Ungrouped params ty
1600+ :: Expression 'Ungrouped commons schemas params from ty
16011601 -- ^ what to count
1602− -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1602+ -> Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
16031603countDistinct = unsafeAggregateDistinct "count"
16041604
16051605-- | synonym for `boolAnd`
@@ -1612,9 +1612,9 @@ countDistinct = unsafeAggregateDistinct "count"
16121612-- :}
16131613-- every("col")
16141614every
1615− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1615+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
16161616 -- ^ what to aggregate
1617− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1617+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
16181618every = unsafeAggregate "every"
16191619
16201620-- | synonym for `boolAndDistinct`
@@ -1627,16 +1627,16 @@ every = unsafeAggregate "every"
16271627-- :}
16281628-- every(DISTINCT "col")
16291629everyDistinct
1630− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1630+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
16311631 -- ^ what to aggregate
1632− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1632+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
16331633everyDistinct = unsafeAggregateDistinct "every"
16341634
16351635-- | minimum and maximum aggregation
16361636max_, min_, maxDistinct, minDistinct
1637− :: Expression commons schemas from 'Ungrouped params (nullity ty)
1637+ :: Expression 'Ungrouped commons schemas params from (nullity ty)
16381638 -- ^ what to aggregate
1639− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1639+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
16401640max_ = unsafeAggregate "max"
16411641min_ = unsafeAggregate "min"
16421642maxDistinct = unsafeAggregateDistinct "max"
@@ -1822,35 +1822,35 @@ Sorting
18221822-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
18231823-- determine whether nulls appear before or after non-null values in the sort
18241824-- ordering of a `Null` result column.
1825−data SortExpression commons schemas params grp from where
1825+data SortExpression grp commons schemas params from where
18261826 Asc
1827− :: Expression commons schemas params grp from ('NotNull ty)
1828− -> SortExpression commons schemas params grp from
1827+ :: Expression grp commons schemas params from ('NotNull ty)
1828+ -> SortExpression grp commons schemas params from
18291829 Desc
1830− :: Expression commons schemas params grp from ('NotNull ty)
1831− -> SortExpression commons schemas params grp from
1830+ :: Expression grp commons schemas params from ('NotNull ty)
1831+ -> SortExpression grp commons schemas params from
18321832 AscNullsFirst
1833− :: Expression commons schemas params grp from ('Null ty)
1834− -> SortExpression commons schemas params grp from
1833+ :: Expression grp commons schemas params from ('Null ty)
1834+ -> SortExpression grp commons schemas params from
18351835 AscNullsLast
1836− :: Expression commons schemas params grp from ('Null ty)
1837− -> SortExpression commons schemas params grp from
1836+ :: Expression grp commons schemas params from ('Null ty)
1837+ -> SortExpression grp commons schemas params from
18381838 DescNullsFirst
1839− :: Expression commons schemas params grp from ('Null ty)
1840− -> SortExpression commons schemas params grp from
1839+ :: Expression grp commons schemas params from ('Null ty)
1840+ -> SortExpression grp commons schemas params from
18411841 DescNullsLast
1842− :: Expression commons schemas params grp from ('Null ty)
1843− -> SortExpression commons schemas params grp from
1844−deriving instance Show (SortExpression commons schemas params grp from)
1842+ :: Expression grp commons schemas params from ('Null ty)
1843+ -> SortExpression grp commons schemas params from
1844+deriving instance Show (SortExpression grp commons schemas params from)
18451845
18461846class OrderBy expr where
18471847 orderBy
1848− :: [SortExpression commons schemas params grp from]
1849− -> expr commons schemas params grp from
1850− -> expr commons schemas params grp from
1848+ :: [SortExpression grp commons schemas params from]
1849+ -> expr grp commons schemas params from
1850+ -> expr grp commons schemas params from
18511851
18521852-- | Render a `SortExpression`.
1853−instance RenderSQL (SortExpression commons schemas params grp from) where
1853+instance RenderSQL (SortExpression grp commons schemas params from) where
18541854 renderSQL = \case
18551855 Asc expression -> renderSQL expression <+> "ASC"
18561856 Desc expression -> renderSQL expression <+> "DESC"
@@ -1861,12 +1861,12 @@ instance RenderSQL (SortExpression commons schemas params grp from) where
18611861 AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
18621862 DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
18631863
1864−data WindowDefinition commons schemas params grp from where
1864+data WindowDefinition grp commons schemas params from where
18651865 WindowDefinition
18661866 :: SListI bys
1867− => NP (Expression commons schemas params grp from) bys
1868− -> [SortExpression commons schemas params grp from]
1869− -> WindowDefinition commons schemas params grp from
1867+ => NP (Expression grp commons schemas params from) bys
1868+ -> [SortExpression grp commons schemas params from]
1869+ -> WindowDefinition grp commons schemas params from
18701870
18711871instance OrderBy WindowDefinition where
18721872 orderBy sortsR (WindowDefinition parts sortsL)
@@ -1886,49 +1886,49 @@ instance RenderSQL (WindowDefinition commons schemas from grp params) where
18861886
18871887partitionBy
18881888 :: SListI bys
1889− => NP (Expression commons schemas params grp from) bys
1890− -> WindowDefinition commons schemas params grp from
1889+ => NP (Expression grp commons schemas params from) bys
1890+ -> WindowDefinition grp commons schemas params from
18911891partitionBy bys = WindowDefinition bys []
18921892
18931893newtype WindowFunction
1894+ (grp :: Grouping)
18941895 (commons :: FromType)
18951896 (schemas :: SchemasType)
18961897 (params :: [NullityType])
1897− (grp :: Grouping)
18981898 (from :: FromType)
18991899 (ty :: NullityType)
19001900 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
19011901 deriving (GHC.Generic,Show,Eq,Ord,NFData)
19021902
1903−instance RenderSQL (WindowFunction commons schemas params grp from ty) where
1903+instance RenderSQL (WindowFunction grp commons schemas params from ty) where
19041904 renderSQL = renderWindowFunction
19051905
19061906{- | rank of the current row with gaps; same as `rowNumber` of its first peer
19071907>>> printSQL rank
19081908rank()
19091909-}
1910−rank :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1910+rank :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
19111911rank = UnsafeWindowFunction "rank()"
19121912
19131913{- | number of the current row within its partition, counting from 1
19141914>>> printSQL rowNumber
19151915row_number()
19161916-}
1917−rowNumber :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1917+rowNumber :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
19181918rowNumber = UnsafeWindowFunction "row_number()"
19191919
19201920{- | rank of the current row without gaps; this function counts peer groups
19211921>>> printSQL denseRank
19221922dense_rank()
19231923-}
1924−denseRank :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1924+denseRank :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
19251925denseRank = UnsafeWindowFunction "dense_rank()"
19261926
19271927{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
19281928>>> printSQL percentRank
19291929percent_rank()
19301930-}
1931−percentRank :: WindowFunction commons schemas from grp params ('NotNull 'PGfloat8)
1931+percentRank :: WindowFunction grp commons schemas params from ('NotNull 'PGfloat8)
19321932percentRank = UnsafeWindowFunction "percent_rank()"
19331933
19341934{- | cumulative distribution: (number of partition rows
@@ -1936,16 +1936,16 @@ preceding or peer with current row) / total partition rows
19361936>>> printSQL cumeDist
19371937cume_dist()
19381938-}
1939−cumeDist :: WindowFunction commons schemas from grp params ('NotNull 'PGfloat8)
1939+cumeDist :: WindowFunction grp commons schemas params from ('NotNull 'PGfloat8)
19401940cumeDist = UnsafeWindowFunction "cume_dist()"
19411941
19421942{- | integer ranging from 1 to the argument value,
19431943dividing the partition as equally as possible
19441944-}
19451945ntile
1946− :: Expression commons schemas from grp params ('NotNull 'PGint4)
1946+ :: Expression grp commons schemas params from ('NotNull 'PGint4)
19471947 -- ^ numuckets
1948− -> WindowFunction commons schemas from grp params ('NotNull 'PGint4)
1948+ -> WindowFunction grp commons schemas params from ('NotNull 'PGint4)
19491949ntile numBuckets = UnsafeWindowFunction $ "ntile"
19501950 <> parenthesized (renderSQL numBuckets)
19511951
@@ -1955,13 +1955,13 @@ row within the partition; if there is no such row, instead return default
19551955evaluated with respect to the current row.
19561956-}
19571957lag
1958− :: Expression commons schemas from grp params ty
1958+ :: Expression grp commons schemas params from ty
19591959 -- ^ value
1960− -> Expression commons schemas from grp params ('NotNull 'PGint4)
1960+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
19611961 -- ^ offset
1962− -> Expression commons schemas from grp params ty
1962+ -> Expression grp commons schemas params from ty
19631963 -- ^ default
1964− -> WindowFunction commons schemas from grp params ty
1964+ -> WindowFunction grp commons schemas params from ty
19651965lag value offset def = UnsafeWindowFunction $ "lag"
19661966 <> parenthesized
19671967 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
@@ -1972,13 +1972,13 @@ row within the partition; if there is no such row, instead return default
19721972evaluated with respect to the current row.
19731973-}
19741974lead
1975− :: Expression commons schemas from grp params ty
1975+ :: Expression grp commons schemas params from ty
19761976 -- ^ value
1977− -> Expression commons schemas from grp params ('NotNull 'PGint4)
1977+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
19781978 -- ^ offset
1979− -> Expression commons schemas from grp params ty
1979+ -> Expression grp commons schemas params from ty
19801980 -- ^ default
1981− -> WindowFunction commons schemas from grp params ty
1981+ -> WindowFunction grp commons schemas params from ty
19821982lead value offset def = UnsafeWindowFunction $ "lag"
19831983 <> parenthesized
19841984 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
@@ -1987,9 +1987,9 @@ lead value offset def = UnsafeWindowFunction $ "lag"
19871987first row of the window frame
19881988-}
19891989firstValue
1990− :: Expression commons schemas from grp params ty
1990+ :: Expression grp commons schemas params from ty
19911991 -- ^ value
1992− -> WindowFunction commons schemas from grp params ty
1992+ -> WindowFunction grp commons schemas params from ty
19931993firstValue value = UnsafeWindowFunction $ "first_value"
19941994 <> parenthesized (renderSQL value)
19951995
@@ -1997,9 +1997,9 @@ firstValue value = UnsafeWindowFunction $ "first_value"
19971997last row of the window frame
19981998-}
19991999lastValue
2000− :: Expression commons schemas from grp params ty
2000+ :: Expression grp commons schemas params from ty
20012001 -- ^ value
2002− -> WindowFunction commons schemas from grp params ty
2002+ -> WindowFunction grp commons schemas params from ty
20032003lastValue value = UnsafeWindowFunction $ "last_value"
20042004 <> parenthesized (renderSQL value)
20052005
@@ -2007,10 +2007,10 @@ lastValue value = UnsafeWindowFunction $ "last_value"
20072007row of the window frame (counting from 1); null if no such row
20082008-}
20092009nthValue
2010− :: Expression commons schemas from grp params (nullity ty)
2010+ :: Expression grp commons schemas params from (nullity ty)
20112011 -- ^ value
2012− -> Expression commons schemas from grp params ('NotNull 'PGint4)
2012+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
20132013 -- ^ nth
2014− -> WindowFunction commons schemas from grp params ('Null ty)
2014+ -> WindowFunction grp commons schemas params from ('Null ty)
20152015nthValue value nth = UnsafeWindowFunction $ "nth_value"
20162016 <> parenthesized (commaSeparated [renderSQL value, renderSQL nth])