@@ -452,7 +452,12 @@ instance (PGNum ty, PGFloating ty) => Floating
452 acosh x = log (x + sqrt (x*x - 1))
452 acosh x = log (x + sqrt (x*x - 1))
453 atanh x = log ((1 + x) / (1 - x)) / 2
453 atanh x = log ((1 + x) / (1 - x)) / 2
455−-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ atan2_ pi 2
455+-- | :{
457+-- expression :: Expression tables grouping params (nullity 'PGfloat4)
458+-- expression = atan2_ pi 2
459+-- in renderExpression expression
456-- "atan2(pi(), 2)"
461-- "atan2(pi(), 2)"
458 :: PGFloating float
463 :: PGFloating float
@@ -480,8 +485,12 @@ cast ty x = UnsafeExpression $ parenthesized $
480 renderExpression x <+> "::" <+> renderTypeExpression ty
485 renderExpression x <+> "::" <+> renderTypeExpression ty
482-- | integer division, truncates the result
487-- | integer division, truncates the result
484−-- >>> renderExpression @_ @_ @_ @(_(_ 'PGint2)) $ 5 `quot_` 2
489+-- let
490+-- expression :: Expression tables grouping params (nullity 'PGint2)
491+-- expression = 5 `quot_` 2
492+-- in renderExpression expression
485-- "(5 / 2)"
494-- "(5 / 2)"
487 :: PGIntegral int
496 :: PGIntegral int
@@ -494,7 +503,12 @@ quot_ = unsafeBinaryOp "/"
495-- | remainder upon integer division
504-- | remainder upon integer division
497−-- >>> renderExpression @_ @_ @_ @(_ (_ 'PGint2)) $ 5 `rem_` 2
506+-- :{
508+-- expression :: Expression tables grouping params (nullity 'PGint2)
509+-- expression = 5 `rem_` 2
510+-- in renderExpression expression
498-- "(5 % 2)"
512-- "(5 % 2)"
500 :: PGIntegral int
514 :: PGIntegral int
@@ -505,7 +519,12 @@ rem_
505 -> Expression tables grouping params (nullity int)
519 -> Expression tables grouping params (nullity int)
506rem_ = unsafeBinaryOp "%"
520rem_ = unsafeBinaryOp "%"
508−-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ trunc pi
522+-- | :{
524+-- expression :: Expression tables grouping params (nullity 'PGfloat4)
525+-- expression = trunc pi
526+-- in renderExpression expression
509-- "trunc(pi())"
528-- "trunc(pi())"
511 :: PGFloating frac
530 :: PGFloating frac
@@ -514,7 +533,12 @@ trunc
514 -> Expression tables grouping params (nullity frac)
533 -> Expression tables grouping params (nullity frac)
515trunc = unsafeFunction "trunc"
534trunc = unsafeFunction "trunc"
517−-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ round_ pi
536+-- | :{
538+-- expression :: Expression tables grouping params (nullity 'PGfloat4)
539+-- expression = round_ pi
540+-- in renderExpression expression
518-- "round(pi())"
542-- "round(pi())"
520 :: PGFloating frac
544 :: PGFloating frac
@@ -523,7 +547,12 @@ round_
523 -> Expression tables grouping params (nullity frac)
547 -> Expression tables grouping params (nullity frac)
524round_ = unsafeFunction "round"
548round_ = unsafeFunction "round"
526−-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGfloat4)) $ ceiling_ pi
550+-- | :{
552+-- expression :: Expression tables grouping params (nullity 'PGfloat4)
553+-- expression = ceiling_ pi
554+-- in renderExpression expression
527-- "ceiling(pi())"
556-- "ceiling(pi())"
529 :: PGFloating frac
558 :: PGFloating frac
@@ -572,7 +601,12 @@ not_ = unsafeUnaryOp "NOT"
572 -> Condition tables grouping params
601 -> Condition tables grouping params
573(.||) = unsafeBinaryOp "OR"
602(.||) = unsafeBinaryOp "OR"
606+-- expression :: Expression tables grouping params (nullity 'PGint2)
575−-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGint2)) $ caseWhenThenElse [(true, 1), (false, 2)] 3
607+-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
608+-- in renderExpression expression
576-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
610-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
577caseWhenThenElse
611caseWhenThenElse
578 :: [ ( Condition tables grouping params
612 :: [ ( Condition tables grouping params
@@ -593,7 +627,12 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
632+-- expression :: Expression tables grouping params (nullity 'PGint2)
596−-- | >>> renderExpression @_ @_ @_ @(_ (_ 'PGint2)) $ ifThenElse true 1 0
633+-- expression = ifThenElse true 1 0
634+-- in renderExpression expression
597-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
636-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
598ifThenElse
637ifThenElse
599 :: Condition tables grouping params
638 :: Condition tables grouping params
@@ -775,7 +814,12 @@ unsafeAggregateDistinct
775unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
814unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
776 [fun, "(DISTINCT ", renderExpression x, ")"]
815 [fun, "(DISTINCT ", renderExpression x, ")"]
778−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGnumeric)]] $ sum_ #col
817+-- | :{
819+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGnumeric]] grouping params (nullity 'PGnumeric)
820+-- expression = sum_ #col
821+-- in renderExpression expression
779-- "sum(col)"
823-- "sum(col)"
781 :: PGNum ty
825 :: PGNum ty
@@ -784,7 +828,12 @@ sum_
784 -> Expression tables ('Grouped bys) params (nullity ty)
828 -> Expression tables ('Grouped bys) params (nullity ty)
785sum_ = unsafeAggregate "sum"
829sum_ = unsafeAggregate "sum"
787−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGnumeric)]] $ sumDistinct #col
831+-- | :{
833+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGnumeric]] grouping params (nullity 'PGnumeric)
834+-- expression = sumDistinct #col
835+-- in renderExpression expression
788-- "sum(DISTINCT col)"
837-- "sum(DISTINCT col)"
789sumDistinct
838sumDistinct
790 :: PGNum ty
839 :: PGNum ty
@@ -810,7 +859,12 @@ instance PGAvg 'PGfloat4 'PGfloat8
810instance PGAvg 'PGfloat8 'PGfloat8
859instance PGAvg 'PGfloat8 'PGfloat8
811instance PGAvg 'PGinterval 'PGinterval
860instance PGAvg 'PGinterval 'PGinterval
813−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitAnd #col
862+-- | :{
864+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGint4]] grouping params (nullity 'PGint4)
865+-- expression = bitAnd #col
866+-- in renderExpression expression
814-- "bit_and(col)"
868-- "bit_and(col)"
816 :: PGIntegral int
870 :: PGIntegral int
@@ -819,7 +873,12 @@ bitAnd
819 -> Expression tables ('Grouped bys) params (nullity int)
873 -> Expression tables ('Grouped bys) params (nullity int)
820bitAnd = unsafeAggregate "bit_and"
874bitAnd = unsafeAggregate "bit_and"
822−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitOr #col
876+-- | :{
878+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGint4]] grouping params (nullity 'PGint4)
879+-- expression = bitOr #col
880+-- in renderExpression expression
823-- "bit_or(col)"
882-- "bit_or(col)"
825 :: PGIntegral int
884 :: PGIntegral int
@@ -828,7 +887,12 @@ bitOr
828 -> Expression tables ('Grouped bys) params (nullity int)
887 -> Expression tables ('Grouped bys) params (nullity int)
829bitOr = unsafeAggregate "bit_or"
888bitOr = unsafeAggregate "bit_or"
892+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGint4]] grouping params (nullity 'PGint4)
831−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitAndDistinct #col
893+-- expression = bitAndDistinct #col
894+-- in renderExpression expression
832-- "bit_and(DISTINCT col)"
896-- "bit_and(DISTINCT col)"
833bitAndDistinct
897bitAndDistinct
834 :: PGIntegral int
898 :: PGIntegral int
@@ -837,7 +901,12 @@ bitAndDistinct
837 -> Expression tables ('Grouped bys) params (nullity int)
901 -> Expression tables ('Grouped bys) params (nullity int)
838bitAndDistinct = unsafeAggregateDistinct "bit_and"
902bitAndDistinct = unsafeAggregateDistinct "bit_and"
906+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGint4]] grouping params (nullity 'PGint4)
840−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGint4)]] $ bitOrDistinct #col
907+-- expression = bitOrDistinct #col
908+-- in renderExpression expression
841-- "bit_or(DISTINCT col)"
910-- "bit_or(DISTINCT col)"
842bitOrDistinct
911bitOrDistinct
843 :: PGIntegral int
912 :: PGIntegral int
@@ -846,7 +915,12 @@ bitOrDistinct
846 -> Expression tables ('Grouped bys) params (nullity int)
915 -> Expression tables ('Grouped bys) params (nullity int)
847bitOrDistinct = unsafeAggregateDistinct "bit_or"
916bitOrDistinct = unsafeAggregateDistinct "bit_or"
849−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolAnd #col
918+-- | :{
920+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGbool]] grouping params (nullity 'PGbool)
921+-- expression = boolAnd #col
922+-- in renderExpression expression
850-- "bool_and(col)"
924-- "bool_and(col)"
852 :: Expression tables 'Ungrouped params (nullity 'PGbool)
926 :: Expression tables 'Ungrouped params (nullity 'PGbool)
@@ -854,7 +928,12 @@ boolAnd
854 -> Expression tables ('Grouped bys) params (nullity 'PGbool)
928 -> Expression tables ('Grouped bys) params (nullity 'PGbool)
855boolAnd = unsafeAggregate "bool_and"
929boolAnd = unsafeAggregate "bool_and"
857−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolOr #col
931+-- | :{
933+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGbool]] grouping params (nullity 'PGbool)
934+-- expression = boolOr #col
935+-- in renderExpression expression
858-- "bool_or(col)"
937-- "bool_or(col)"
860 :: Expression tables 'Ungrouped params (nullity 'PGbool)
939 :: Expression tables 'Ungrouped params (nullity 'PGbool)
@@ -862,7 +941,12 @@ boolOr
862 -> Expression tables ('Grouped bys) params (nullity 'PGbool)
941 -> Expression tables ('Grouped bys) params (nullity 'PGbool)
863boolOr = unsafeAggregate "bool_or"
942boolOr = unsafeAggregate "bool_or"
946+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGbool]] grouping params (nullity 'PGbool)
865−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolAndDistinct #col
947+-- expression = boolAndDistinct #col
948+-- in renderExpression expression
866-- "bool_and(DISTINCT col)"
950-- "bool_and(DISTINCT col)"
867boolAndDistinct
951boolAndDistinct
868 :: Expression tables 'Ungrouped params (nullity 'PGbool)
952 :: Expression tables 'Ungrouped params (nullity 'PGbool)
@@ -870,7 +954,12 @@ boolAndDistinct
870 -> Expression tables ('Grouped bys) params (nullity 'PGbool)
954 -> Expression tables ('Grouped bys) params (nullity 'PGbool)
871boolAndDistinct = unsafeAggregateDistinct "bool_and"
955boolAndDistinct = unsafeAggregateDistinct "bool_and"
959+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGbool]] grouping params (nullity 'PGbool)
873−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ boolOrDistinct #col
960+-- expression = boolOrDistinct #col
961+-- in renderExpression expression
874-- "bool_or(DISTINCT col)"
963-- "bool_or(DISTINCT col)"
875boolOrDistinct
964boolOrDistinct
876 :: Expression tables 'Ungrouped params (nullity 'PGbool)
965 :: Expression tables 'Ungrouped params (nullity 'PGbool)
@@ -886,25 +975,40 @@ countStar
886 :: Expression tables ('Grouped bys) params ('NotNull 'PGint8)
975 :: Expression tables ('Grouped bys) params ('NotNull 'PGint8)
887countStar = UnsafeExpression $ "count(*)"
976countStar = UnsafeExpression $ "count(*)"
889−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Optional _]] $ count #col
978+-- | :{
980+-- expression :: Expression [tab ::: ["col" ::: nullity ty]] grouping params (nullity 'PGbool)
981+-- expression = count #col
982+-- in renderExpression expression
890-- "count(col)"
984-- "count(col)"
892− :: Expression tables 'Ungrouped params (ty)
986+ :: Expression tables 'Ungrouped params ty
893 -- ^ what to count
987 -- ^ what to count
894 -> Expression tables ('Grouped bys) params ('NotNull 'PGint8)
988 -> Expression tables ('Grouped bys) params ('NotNull 'PGint8)
895count = unsafeAggregate "count"
989count = unsafeAggregate "count"
993+-- expression :: Expression [tab ::: ["col" ::: nullity ty]] grouping params (nullity 'PGbool)
897−-- | >>> renderExpression @'[_ ::: '["col" ::: 'Required _]] $ countDistinct #col
994+-- expression = countDistinct #col
995+-- in renderExpression expression
898-- "count(DISTINCT col)"
997-- "count(DISTINCT col)"
899countDistinct
998countDistinct
900− :: Expression tables 'Ungrouped params (ty)
999+ :: Expression tables 'Ungrouped params ty
901 -- ^ what to count
1000 -- ^ what to count
902 -> Expression tables ('Grouped bys) params ('NotNull 'PGint8)
1001 -> Expression tables ('Grouped bys) params ('NotNull 'PGint8)
903countDistinct = unsafeAggregateDistinct "count"
1002countDistinct = unsafeAggregateDistinct "count"
905-- | synonym for `boolAnd`
1004-- | synonym for `boolAnd`
907−-- >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ every #col
1006+-- :{
1008+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGbool]] grouping params (nullity 'PGbool)
1009+-- expression = every #col
1010+-- in renderExpression expression
908-- "every(col)"
1012-- "every(col)"
910 :: Expression tables 'Ungrouped params (nullity 'PGbool)
1014 :: Expression tables 'Ungrouped params (nullity 'PGbool)
@@ -914,7 +1018,12 @@ every = unsafeAggregate "every"
915-- | synonym for `boolAndDistinct`
1019-- | synonym for `boolAndDistinct`
1023+-- expression :: Expression [tab ::: ["col" ::: nullity 'PGbool]] grouping params (nullity 'PGbool)
917−-- >>> renderExpression @'[_ ::: '["col" ::: 'Required (_ 'PGbool)]] $ everyDistinct #col
1024+-- expression = everyDistinct #col
1025+-- in renderExpression expression
918-- "every(DISTINCT col)"
1027-- "every(DISTINCT col)"
919everyDistinct
1028everyDistinct
920 :: Expression tables 'Ungrouped params (nullity 'PGbool)
1029 :: Expression tables 'Ungrouped params (nullity 'PGbool)