@@ -217,14 +217,14 @@ and other operations.
218newtype Expression
218newtype Expression
219 (schema :: SchemaType)
219 (schema :: SchemaType)
220− (relations :: RelationsType)
220+ (from :: FromType)
221 (grouping :: Grouping)
221 (grouping :: Grouping)
222 (params :: [NullityType])
222 (params :: [NullityType])
223 (ty :: NullityType)
223 (ty :: NullityType)
224 = UnsafeExpression { renderExpression :: ByteString }
224 = UnsafeExpression { renderExpression :: ByteString }
225 deriving (GHC.Generic,Show,Eq,Ord,NFData)
225 deriving (GHC.Generic,Show,Eq,Ord,NFData)
227−instance RenderSQL (Expression schema relations grouping params ty) where
227+instance RenderSQL (Expression schema from grouping params ty) where
228 renderSQL = renderExpression
228 renderSQL = renderExpression
230{- | A `HasParameter` constraint is used to indicate a value that is
230{- | A `HasParameter` constraint is used to indicate a value that is
@@ -248,7 +248,7 @@ class KnownNat n => HasParameter
248 -- ($1 :: int4)
248 -- ($1 :: int4)
249 parameter
249 parameter
250 :: TypeExpression schema ty
250 :: TypeExpression schema ty
251− -> Expression schema relations grouping params ty
251+ -> Expression schema from grouping params ty
252 parameter ty = UnsafeExpression $ parenthesized $
252 parameter ty = UnsafeExpression $ parenthesized $
253 "$" <> renderNat @n <+> "::"
253 "$" <> renderNat @n <+> "::"
254 <+> renderTypeExpression ty
254 <+> renderTypeExpression ty
@@ -263,82 +263,82 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
263-- >>> printSQL expr
263-- >>> printSQL expr
264-- ($1 :: int4)
264-- ($1 :: int4)
266− :: forall n schema params relations grouping ty
266+ :: forall n schema params from grouping ty
267 . (PGTyped schema ty, HasParameter n schema params ty)
267 . (PGTyped schema ty, HasParameter n schema params ty)
268− => Expression schema relations grouping params ty -- ^ param
268+ => Expression schema from grouping params ty -- ^ param
269param = parameter @n pgtype
269param = parameter @n pgtype
271−instance (HasUnique relation relations columns, Has column columns ty)
271+instance (HasUnique relation from columns, Has column columns ty)
272− => IsLabel column (Expression schema relations 'Ungrouped params ty) where
272+ => IsLabel column (Expression schema from 'Ungrouped params ty) where
273 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
273 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
274−instance (HasUnique relation relations columns, Has column columns ty)
274+instance (HasUnique relation from columns, Has column columns ty)
275 => IsLabel column
275 => IsLabel column
276− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
276+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
277 fromLabel = fromLabel @column `As` Alias @column
277 fromLabel = fromLabel @column `As` Alias @column
278−instance (HasUnique relation relations columns, Has column columns ty)
278+instance (HasUnique relation from columns, Has column columns ty)
279 => IsLabel column
279 => IsLabel column
280− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
280+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
281 fromLabel = fromLabel @column :* Nil
281 fromLabel = fromLabel @column :* Nil
283−instance (Has relation relations columns, Has column columns ty)
283+instance (Has relation from columns, Has column columns ty)
284− => IsQualified relation column (Expression schema relations 'Ungrouped params ty) where
284+ => IsQualified relation column (Expression schema from 'Ungrouped params ty) where
285 relation ! column = UnsafeExpression $
285 relation ! column = UnsafeExpression $
286 renderAlias relation <> "." <> renderAlias column
286 renderAlias relation <> "." <> renderAlias column
287−instance (Has relation relations columns, Has column columns ty)
287+instance (Has relation from columns, Has column columns ty)
288 => IsQualified relation column
288 => IsQualified relation column
289− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
289+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
290 relation ! column = relation ! column `As` column
290 relation ! column = relation ! column `As` column
291−instance (Has relation relations columns, Has column columns ty)
291+instance (Has relation from columns, Has column columns ty)
292 => IsQualified relation column
292 => IsQualified relation column
293− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
293+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
294 relation ! column = relation ! column :* Nil
294 relation ! column = relation ! column :* Nil
297− ( HasUnique relation relations columns
297+ ( HasUnique relation from columns
298 , Has column columns ty
298 , Has column columns ty
299 , GroupedBy relation column bys
299 , GroupedBy relation column bys
300 ) => IsLabel column
300 ) => IsLabel column
301− (Expression schema relations ('Grouped bys) params ty) where
301+ (Expression schema from ('Grouped bys) params ty) where
302 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
302 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
304− ( HasUnique relation relations columns
304+ ( HasUnique relation from columns
305 , Has column columns ty
305 , Has column columns ty
306 , GroupedBy relation column bys
306 , GroupedBy relation column bys
307 ) => IsLabel column
307 ) => IsLabel column
308− ( Aliased (Expression schema relations ('Grouped bys) params)
308+ ( Aliased (Expression schema from ('Grouped bys) params)
309 (column ::: ty) ) where
309 (column ::: ty) ) where
310 fromLabel = fromLabel @column `As` Alias @column
310 fromLabel = fromLabel @column `As` Alias @column
312− ( HasUnique relation relations columns
312+ ( HasUnique relation from columns
313 , Has column columns ty
313 , Has column columns ty
314 , GroupedBy relation column bys
314 , GroupedBy relation column bys
315 ) => IsLabel column
315 ) => IsLabel column
316− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
316+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
317 '[column ::: ty] ) where
317 '[column ::: ty] ) where
318 fromLabel = fromLabel @column :* Nil
318 fromLabel = fromLabel @column :* Nil
321− ( Has relation relations columns
321+ ( Has relation from columns
322 , Has column columns ty
322 , Has column columns ty
323 , GroupedBy relation column bys
323 , GroupedBy relation column bys
324 ) => IsQualified relation column
324 ) => IsQualified relation column
325− (Expression schema relations ('Grouped bys) params ty) where
325+ (Expression schema from ('Grouped bys) params ty) where
326 relation ! column = UnsafeExpression $
326 relation ! column = UnsafeExpression $
327 renderAlias relation <> "." <> renderAlias column
327 renderAlias relation <> "." <> renderAlias column
329− ( Has relation relations columns
329+ ( Has relation from columns
330 , Has column columns ty
330 , Has column columns ty
331 , GroupedBy relation column bys
331 , GroupedBy relation column bys
332 ) => IsQualified relation column
332 ) => IsQualified relation column
333− (Aliased (Expression schema relations ('Grouped bys) params)
333+ (Aliased (Expression schema from ('Grouped bys) params)
334 (column ::: ty)) where
334 (column ::: ty)) where
335 relation ! column = relation ! column `As` column
335 relation ! column = relation ! column `As` column
337− ( Has relation relations columns
337+ ( Has relation from columns
338 , Has column columns ty
338 , Has column columns ty
339 , GroupedBy relation column bys
339 , GroupedBy relation column bys
340 ) => IsQualified relation column
340 ) => IsQualified relation column
341− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
341+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
342 '[column ::: ty]) where
342 '[column ::: ty]) where
343 relation ! column = relation ! column :* Nil
343 relation ! column = relation ! column :* Nil
@@ -363,11 +363,11 @@ notNull = UnsafeExpression . renderExpression
363-- >>> printSQL $ coalesce [null_, true] false
363-- >>> printSQL $ coalesce [null_, true] false
364-- COALESCE(NULL, TRUE, FALSE)
364-- COALESCE(NULL, TRUE, FALSE)
366− :: [Expression schema relations grouping params ('Null ty)]
366+ :: [Expression schema from grouping params ('Null ty)]
367 -- ^ @NULL@s may be present
367 -- ^ @NULL@s may be present
368− -> Expression schema relations grouping params ('NotNull ty)
368+ -> Expression schema from grouping params ('NotNull ty)
369 -- ^ @NULL@ is absent
369 -- ^ @NULL@ is absent
370− -> Expression schema relations grouping params ('NotNull ty)
370+ -> Expression schema from grouping params ('NotNull ty)
371coalesce nullxs notNullx = UnsafeExpression $
371coalesce nullxs notNullx = UnsafeExpression $
372 "COALESCE" <> parenthesized (commaSeparated
372 "COALESCE" <> parenthesized (commaSeparated
373 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
373 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -377,26 +377,26 @@ coalesce nullxs notNullx = UnsafeExpression $
377-- >>> printSQL $ fromNull true null_
377-- >>> printSQL $ fromNull true null_
378-- COALESCE(NULL, TRUE)
378-- COALESCE(NULL, TRUE)
380− :: Expression schema relations grouping params ('NotNull ty)
380+ :: Expression schema from grouping params ('NotNull ty)
381 -- ^ what to convert @NULL@ to
381 -- ^ what to convert @NULL@ to
382− -> Expression schema relations grouping params ('Null ty)
382+ -> Expression schema from grouping params ('Null ty)
383− -> Expression schema relations grouping params ('NotNull ty)
383+ -> Expression schema from grouping params ('NotNull ty)
384fromNull notNullx nullx = coalesce [nullx] notNullx
384fromNull notNullx nullx = coalesce [nullx] notNullx
386-- | >>> printSQL $ null_ & isNull
386-- | >>> printSQL $ null_ & isNull
387-- NULL IS NULL
387-- NULL IS NULL
389− :: Expression schema relations grouping params ('Null ty)
389+ :: Expression schema from grouping params ('Null ty)
390 -- ^ possibly @NULL@
390 -- ^ possibly @NULL@
391− -> Condition schema relations grouping params
391+ -> Condition schema from grouping params
392isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
392isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
394-- | >>> printSQL $ null_ & isNotNull
394-- | >>> printSQL $ null_ & isNotNull
395-- NULL IS NOT NULL
395-- NULL IS NOT NULL
397− :: Expression schema relations grouping params ('Null ty)
397+ :: Expression schema from grouping params ('Null ty)
398 -- ^ possibly @NULL@
398 -- ^ possibly @NULL@
399− -> Condition schema relations grouping params
399+ -> Condition schema from grouping params
400isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
400isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
402-- | analagous to `maybe` using @IS NULL@
402-- | analagous to `maybe` using @IS NULL@
@@ -404,13 +404,13 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
404-- >>> printSQL $ matchNull true not_ null_
404-- >>> printSQL $ matchNull true not_ null_
405-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
405-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
407− :: Expression schema relations grouping params (nullty)
407+ :: Expression schema from grouping params (nullty)
408 -- ^ what to convert @NULL@ to
408 -- ^ what to convert @NULL@ to
409− -> ( Expression schema relations grouping params ('NotNull ty)
409+ -> ( Expression schema from grouping params ('NotNull ty)
410− -> Expression schema relations grouping params (nullty) )
410+ -> Expression schema from grouping params (nullty) )
411 -- ^ function to perform when @NULL@ is absent
411 -- ^ function to perform when @NULL@ is absent
412− -> Expression schema relations grouping params ('Null ty)
412+ -> Expression schema from grouping params ('Null ty)
413− -> Expression schema relations grouping params (nullty)
413+ -> Expression schema from grouping params (nullty)
414matchNull y f x = ifThenElse (isNull x) y
414matchNull y f x = ifThenElse (isNull x) y
415 (f (UnsafeExpression (renderExpression x)))
415 (f (UnsafeExpression (renderExpression x)))
@@ -423,25 +423,25 @@ matchNull y f x = ifThenElse (isNull x) y
423NULL IF (FALSE, ($1 :: bool))
423NULL IF (FALSE, ($1 :: bool))
426− :: Expression schema relations grouping params ('NotNull ty)
426+ :: Expression schema from grouping params ('NotNull ty)
427 -- ^ @NULL@ is absent
427 -- ^ @NULL@ is absent
428− -> Expression schema relations grouping params ('NotNull ty)
428+ -> Expression schema from grouping params ('NotNull ty)
429 -- ^ @NULL@ is absent
429 -- ^ @NULL@ is absent
430− -> Expression schema relations grouping params ('Null ty)
430+ -> Expression schema from grouping params ('Null ty)
431nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
431nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
432 (renderExpression x <> ", " <> renderExpression y)
432 (renderExpression x <> ", " <> renderExpression y)
434-- | >>> printSQL $ array [null_, false, true]
434-- | >>> printSQL $ array [null_, false, true]
435-- ARRAY[NULL, FALSE, TRUE]
435-- ARRAY[NULL, FALSE, TRUE]
437− :: [Expression schema relations grouping params ty]
437+ :: [Expression schema from grouping params ty]
438 -- ^ array elements
438 -- ^ array elements
439− -> Expression schema relations grouping params (nullity ('PGvararray ty))
439+ -> Expression schema from grouping params (nullity ('PGvararray ty))
440array xs = UnsafeExpression $
440array xs = UnsafeExpression $
441 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
441 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
443instance (KnownSymbol label, label `In` labels) => IsPGlabel label
443instance (KnownSymbol label, label `In` labels) => IsPGlabel label
444− (Expression schema relations grouping params (nullity ('PGenum labels))) where
444+ (Expression schema from grouping params (nullity ('PGenum labels))) where
445 label = UnsafeExpression $ renderLabel (PGlabel @label)
445 label = UnsafeExpression $ renderLabel (PGlabel @label)
447-- | A row constructor is an expression that builds a row value
447-- | A row constructor is an expression that builds a row value
@@ -458,9 +458,9 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
458-- ROW(0, 1)
458-- ROW(0, 1)
460 :: SListI fields
460 :: SListI fields
461− => NP (Aliased (Expression schema relations grouping params)) fields
461+ => NP (Aliased (Expression schema from grouping params)) fields
462 -- ^ zero or more expressions for the row field values
462 -- ^ zero or more expressions for the row field values
463− -> Expression schema relations grouping params (nullity ('PGcomposite fields))
463+ -> Expression schema from grouping params (nullity ('PGcomposite fields))
464row exprs = UnsafeExpression $ "ROW" <> parenthesized
464row exprs = UnsafeExpression $ "ROW" <> parenthesized
465 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
465 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
@@ -472,11 +472,11 @@ instance Has field fields ty => IsLabel field
472 renderSymbol @field
472 renderSymbol @field
474instance Semigroup
474instance Semigroup
475− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
475+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
476 (<>) = unsafeBinaryOp "||"
476 (<>) = unsafeBinaryOp "||"
478instance Monoid
478instance Monoid
479− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
479+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
480 mempty = array []
480 mempty = array []
481 mappend = (<>)
481 mappend = (<>)
@@ -484,22 +484,22 @@ instance Monoid
484-- >>> printSQL expr
484-- >>> printSQL expr
485-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
485-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
487− :: Expression schema relations grouping params (nullty)
487+ :: Expression schema from grouping params (nullty)
488 -- ^ needs at least 1 argument
488 -- ^ needs at least 1 argument
489− -> [Expression schema relations grouping params (nullty)]
489+ -> [Expression schema from grouping params (nullty)]
490 -- ^ or more
490 -- ^ or more
491− -> Expression schema relations grouping params (nullty)
491+ -> Expression schema from grouping params (nullty)
492greatest x xs = UnsafeExpression $ "GREATEST("
492greatest x xs = UnsafeExpression $ "GREATEST("
493 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
493 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
495-- | >>> printSQL $ least currentTimestamp [null_]
495-- | >>> printSQL $ least currentTimestamp [null_]
496-- LEAST(CURRENT_TIMESTAMP, NULL)
496-- LEAST(CURRENT_TIMESTAMP, NULL)
498− :: Expression schema relations grouping params (nullty)
498+ :: Expression schema from grouping params (nullty)
499 -- ^ needs at least 1 argument
499 -- ^ needs at least 1 argument
500− -> [Expression schema relations grouping params (nullty)]
500+ -> [Expression schema from grouping params (nullty)]
501 -- ^ or more
501 -- ^ or more
502− -> Expression schema relations grouping params (nullty)
502+ -> Expression schema from grouping params (nullty)
503least x xs = UnsafeExpression $ "LEAST("
503least x xs = UnsafeExpression $ "LEAST("
504 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
504 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
@@ -508,9 +508,9 @@ least x xs = UnsafeExpression $ "LEAST("
508unsafeBinaryOp
508unsafeBinaryOp
509 :: ByteString
509 :: ByteString
510 -- ^ operator
510 -- ^ operator
511− -> Expression schema relations grouping params (ty0)
511+ -> Expression schema from grouping params (ty0)
512− -> Expression schema relations grouping params (ty1)
512+ -> Expression schema from grouping params (ty1)
513− -> Expression schema relations grouping params (ty2)
513+ -> Expression schema from grouping params (ty2)
514unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
514unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
515 renderExpression x <+> op <+> renderExpression y
515 renderExpression x <+> op <+> renderExpression y
@@ -519,8 +519,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
519unsafeUnaryOp
519unsafeUnaryOp
520 :: ByteString
520 :: ByteString
521 -- ^ operator
521 -- ^ operator
522− -> Expression schema relations grouping params (ty0)
522+ -> Expression schema from grouping params (ty0)
523− -> Expression schema relations grouping params (ty1)
523+ -> Expression schema from grouping params (ty1)
524unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
524unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
525 op <+> renderExpression x
525 op <+> renderExpression x
@@ -529,8 +529,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
529unsafeFunction
529unsafeFunction
530 :: ByteString
530 :: ByteString
531 -- ^ function
531 -- ^ function
532− -> Expression schema relations grouping params (xty)
532+ -> Expression schema from grouping params (xty)
533− -> Expression schema relations grouping params (yty)
533+ -> Expression schema from grouping params (yty)
534unsafeFunction fun x = UnsafeExpression $
534unsafeFunction fun x = UnsafeExpression $
535 fun <> parenthesized (renderExpression x)
535 fun <> parenthesized (renderExpression x)
@@ -539,13 +539,13 @@ unsafeVariadicFunction
539 :: SListI elems
539 :: SListI elems
540 => ByteString
540 => ByteString
541 -- ^ function
541 -- ^ function
542− -> NP (Expression schema relations grouping params) elems
542+ -> NP (Expression schema from grouping params) elems
543− -> Expression schema relations grouping params ret
543+ -> Expression schema from grouping params ret
544unsafeVariadicFunction fun x = UnsafeExpression $
544unsafeVariadicFunction fun x = UnsafeExpression $
545 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
545 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
547instance PGNum ty
547instance PGNum ty
548− => Num (Expression schema relations grouping params (nullity ty)) where
548+ => Num (Expression schema from grouping params (nullity ty)) where
549 (+) = unsafeBinaryOp "+"
549 (+) = unsafeBinaryOp "+"
550 (-) = unsafeBinaryOp "-"
550 (-) = unsafeBinaryOp "-"
551 (*) = unsafeBinaryOp "*"
551 (*) = unsafeBinaryOp "*"
@@ -557,12 +557,12 @@ instance PGNum ty
559instance (PGNum ty, PGFloating ty) => Fractional
559instance (PGNum ty, PGFloating ty) => Fractional
560− (Expression schema relations grouping params (nullity ty)) where
560+ (Expression schema from grouping params (nullity ty)) where
561 (/) = unsafeBinaryOp "/"
561 (/) = unsafeBinaryOp "/"
562 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
562 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
564instance (PGNum ty, PGFloating ty) => Floating
564instance (PGNum ty, PGFloating ty) => Floating
565− (Expression schema relations grouping params (nullity ty)) where
565+ (Expression schema from grouping params (nullity ty)) where
566 pi = UnsafeExpression "pi()"
566 pi = UnsafeExpression "pi()"
567 exp = unsafeFunction "exp"
567 exp = unsafeFunction "exp"
568 log = unsafeFunction "ln"
568 log = unsafeFunction "ln"
@@ -585,18 +585,18 @@ instance (PGNum ty, PGFloating ty) => Floating
586-- | >>> :{
586-- | >>> :{
588−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
588+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
589-- expression = atan2_ pi 2
589-- expression = atan2_ pi 2
590-- in printSQL expression
590-- in printSQL expression
592-- atan2(pi(), 2)
592-- atan2(pi(), 2)
594 :: PGFloating float
594 :: PGFloating float
595− => Expression schema relations grouping params (nullity float)
595+ => Expression schema from grouping params (nullity float)
596 -- ^ numerator
596 -- ^ numerator
597− -> Expression schema relations grouping params (nullity float)
597+ -> Expression schema from grouping params (nullity float)
598 -- ^ denominator
598 -- ^ denominator
599− -> Expression schema relations grouping params (nullity float)
599+ -> Expression schema from grouping params (nullity float)
600atan2_ y x = UnsafeExpression $
600atan2_ y x = UnsafeExpression $
601 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
601 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
@@ -609,9 +609,9 @@ atan2_ y x = UnsafeExpression $
610 :: TypeExpression schema ty1
610 :: TypeExpression schema ty1
611 -- ^ type to cast as
611 -- ^ type to cast as
612− -> Expression schema relations grouping params ty0
612+ -> Expression schema from grouping params ty0
613 -- ^ value to convert
613 -- ^ value to convert
614− -> Expression schema relations grouping params ty1
614+ -> Expression schema from grouping params ty1
615cast ty x = UnsafeExpression $ parenthesized $
615cast ty x = UnsafeExpression $ parenthesized $
616 renderExpression x <+> "::" <+> renderTypeExpression ty
616 renderExpression x <+> "::" <+> renderTypeExpression ty
@@ -619,134 +619,134 @@ cast ty x = UnsafeExpression $ parenthesized $
622−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
622+-- expression :: Expression schema from grouping params (nullity 'PGint2)
623-- expression = 5 `quot_` 2
623-- expression = 5 `quot_` 2
624-- in printSQL expression
624-- in printSQL expression
626-- (5 / 2)
626-- (5 / 2)
628 :: PGIntegral int
628 :: PGIntegral int
629− => Expression schema relations grouping params (nullity int)
629+ => Expression schema from grouping params (nullity int)
630 -- ^ numerator
630 -- ^ numerator
631− -> Expression schema relations grouping params (nullity int)
631+ -> Expression schema from grouping params (nullity int)
632 -- ^ denominator
632 -- ^ denominator
633− -> Expression schema relations grouping params (nullity int)
633+ -> Expression schema from grouping params (nullity int)
634quot_ = unsafeBinaryOp "/"
634quot_ = unsafeBinaryOp "/"
636-- | remainder upon integer division
636-- | remainder upon integer division
640−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
640+-- expression :: Expression schema from grouping params (nullity 'PGint2)
641-- expression = 5 `rem_` 2
641-- expression = 5 `rem_` 2
642-- in printSQL expression
642-- in printSQL expression
644-- (5 % 2)
644-- (5 % 2)
646 :: PGIntegral int
646 :: PGIntegral int
647− => Expression schema relations grouping params (nullity int)
647+ => Expression schema from grouping params (nullity int)
648 -- ^ numerator
648 -- ^ numerator
649− -> Expression schema relations grouping params (nullity int)
649+ -> Expression schema from grouping params (nullity int)
650 -- ^ denominator
650 -- ^ denominator
651− -> Expression schema relations grouping params (nullity int)
651+ -> Expression schema from grouping params (nullity int)
652rem_ = unsafeBinaryOp "%"
652rem_ = unsafeBinaryOp "%"
654-- | >>> :{
654-- | >>> :{
656−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
656+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
657-- expression = trunc pi
657-- expression = trunc pi
658-- in printSQL expression
658-- in printSQL expression
660-- trunc(pi())
660-- trunc(pi())
662 :: PGFloating frac
662 :: PGFloating frac
663− => Expression schema relations grouping params (nullity frac)
663+ => Expression schema from grouping params (nullity frac)
664 -- ^ fractional number
664 -- ^ fractional number
665− -> Expression schema relations grouping params (nullity frac)
665+ -> Expression schema from grouping params (nullity frac)
666trunc = unsafeFunction "trunc"
666trunc = unsafeFunction "trunc"
668-- | >>> :{
668-- | >>> :{
670−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
670+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
671-- expression = round_ pi
671-- expression = round_ pi
672-- in printSQL expression
672-- in printSQL expression
674-- round(pi())
674-- round(pi())
676 :: PGFloating frac
676 :: PGFloating frac
677− => Expression schema relations grouping params (nullity frac)
677+ => Expression schema from grouping params (nullity frac)
678 -- ^ fractional number
678 -- ^ fractional number
679− -> Expression schema relations grouping params (nullity frac)
679+ -> Expression schema from grouping params (nullity frac)
680round_ = unsafeFunction "round"
680round_ = unsafeFunction "round"
682-- | >>> :{
682-- | >>> :{
684−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
684+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
685-- expression = ceiling_ pi
685-- expression = ceiling_ pi
686-- in printSQL expression
686-- in printSQL expression
688-- ceiling(pi())
688-- ceiling(pi())
690 :: PGFloating frac
690 :: PGFloating frac
691− => Expression schema relations grouping params (nullity frac)
691+ => Expression schema from grouping params (nullity frac)
692 -- ^ fractional number
692 -- ^ fractional number
693− -> Expression schema relations grouping params (nullity frac)
693+ -> Expression schema from grouping params (nullity frac)
694ceiling_ = unsafeFunction "ceiling"
694ceiling_ = unsafeFunction "ceiling"
696-- | A `Condition` is an `Expression`, which can evaluate
696-- | A `Condition` is an `Expression`, which can evaluate
697-- to `TRUE`, `FALSE` or `NULL`. This is because SQL uses
697-- to `TRUE`, `FALSE` or `NULL`. This is because SQL uses
698-- a three valued logic.
698-- a three valued logic.
699−type Condition schema relations grouping params =
699+type Condition schema from grouping params =
700− Expression schema relations grouping params ('Null 'PGbool)
700+ Expression schema from grouping params ('Null 'PGbool)
702-- | >>> printSQL true
702-- | >>> printSQL true
704−true :: Expression schema relations grouping params (nullity 'PGbool)
704+true :: Expression schema from grouping params (nullity 'PGbool)
705true = UnsafeExpression "TRUE"
705true = UnsafeExpression "TRUE"
707-- | >>> printSQL false
707-- | >>> printSQL false
709−false :: Expression schema relations grouping params (nullity 'PGbool)
709+false :: Expression schema from grouping params (nullity 'PGbool)
710false = UnsafeExpression "FALSE"
710false = UnsafeExpression "FALSE"
712-- | >>> printSQL $ not_ true
712-- | >>> printSQL $ not_ true
713-- (NOT TRUE)
713-- (NOT TRUE)
715− :: Expression schema relations grouping params (nullity 'PGbool)
715+ :: Expression schema from grouping params (nullity 'PGbool)
716− -> Expression schema relations grouping params (nullity 'PGbool)
716+ -> Expression schema from grouping params (nullity 'PGbool)
717not_ = unsafeUnaryOp "NOT"
717not_ = unsafeUnaryOp "NOT"
719-- | >>> printSQL $ true .&& false
719-- | >>> printSQL $ true .&& false
720-- (TRUE AND FALSE)
720-- (TRUE AND FALSE)
722− :: Condition schema relations grouping params
722+ :: Condition schema from grouping params
723− -> Condition schema relations grouping params
723+ -> Condition schema from grouping params
724− -> Condition schema relations grouping params
724+ -> Condition schema from grouping params
725(.&&) = unsafeBinaryOp "AND"
725(.&&) = unsafeBinaryOp "AND"
727-- | >>> printSQL $ true .|| false
727-- | >>> printSQL $ true .|| false
728-- (TRUE OR FALSE)
728-- (TRUE OR FALSE)
730− :: Condition schema relations grouping params
730+ :: Condition schema from grouping params
731− -> Condition schema relations grouping params
731+ -> Condition schema from grouping params
732− -> Condition schema relations grouping params
732+ -> Condition schema from grouping params
733(.||) = unsafeBinaryOp "OR"
733(.||) = unsafeBinaryOp "OR"
735-- | >>> :{
735-- | >>> :{
737−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
737+-- expression :: Expression schema from grouping params (nullity 'PGint2)
738-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
738-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
739-- in printSQL expression
739-- in printSQL expression
741-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
741-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
742caseWhenThenElse
742caseWhenThenElse
743− :: [ ( Condition schema relations grouping params
743+ :: [ ( Condition schema from grouping params
744− , Expression schema relations grouping params ty
744+ , Expression schema from grouping params ty
746 -- ^ whens and thens
746 -- ^ whens and thens
747− -> Expression schema relations grouping params ty
747+ -> Expression schema from grouping params ty
748 -- ^ else
748 -- ^ else
749− -> Expression schema relations grouping params ty
749+ -> Expression schema from grouping params ty
750caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
750caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
752 , mconcat
752 , mconcat
@@ -762,16 +762,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
763-- | >>> :{
763-- | >>> :{
765−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
765+-- expression :: Expression schema from grouping params (nullity 'PGint2)
766-- expression = ifThenElse true 1 0
766-- expression = ifThenElse true 1 0
767-- in printSQL expression
767-- in printSQL expression
769-- CASE WHEN TRUE THEN 1 ELSE 0 END
769-- CASE WHEN TRUE THEN 1 ELSE 0 END
770ifThenElse
770ifThenElse
771− :: Condition schema relations grouping params
771+ :: Condition schema from grouping params
772− -> Expression schema relations grouping params ty -- ^ then
772+ -> Expression schema from grouping params ty -- ^ then
773− -> Expression schema relations grouping params ty -- ^ else
773+ -> Expression schema from grouping params ty -- ^ else
774− -> Expression schema relations grouping params ty
774+ -> Expression schema from grouping params ty
775ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
775ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
777-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
777-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -780,85 +780,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
780-- >>> printSQL $ true .== null_
780-- >>> printSQL $ true .== null_
781-- (TRUE = NULL)
781-- (TRUE = NULL)
783− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
783+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
784− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
784+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
785− -> Condition schema relations grouping params
785+ -> Condition schema from grouping params
786(.==) = unsafeBinaryOp "="
786(.==) = unsafeBinaryOp "="
787infix 4 .==
787infix 4 .==
789-- | >>> printSQL $ true ./= null_
789-- | >>> printSQL $ true ./= null_
790-- (TRUE <> NULL)
790-- (TRUE <> NULL)
792− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
792+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
793− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
793+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
794− -> Condition schema relations grouping params
794+ -> Condition schema from grouping params
795(./=) = unsafeBinaryOp "<>"
795(./=) = unsafeBinaryOp "<>"
796infix 4 ./=
796infix 4 ./=
798-- | >>> printSQL $ true .>= null_
798-- | >>> printSQL $ true .>= null_
799-- (TRUE >= NULL)
799-- (TRUE >= NULL)
801− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
801+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
802− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
802+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
803− -> Condition schema relations grouping params
803+ -> Condition schema from grouping params
804(.>=) = unsafeBinaryOp ">="
804(.>=) = unsafeBinaryOp ">="
805infix 4 .>=
805infix 4 .>=
807-- | >>> printSQL $ true .< null_
807-- | >>> printSQL $ true .< null_
808-- (TRUE < NULL)
808-- (TRUE < NULL)
810− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
810+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
811− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
811+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
812− -> Condition schema relations grouping params
812+ -> Condition schema from grouping params
813(.<) = unsafeBinaryOp "<"
813(.<) = unsafeBinaryOp "<"
814infix 4 .<
814infix 4 .<
816-- | >>> printSQL $ true .<= null_
816-- | >>> printSQL $ true .<= null_
817-- (TRUE <= NULL)
817-- (TRUE <= NULL)
819− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
819+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
820− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
820+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
821− -> Condition schema relations grouping params
821+ -> Condition schema from grouping params
822(.<=) = unsafeBinaryOp "<="
822(.<=) = unsafeBinaryOp "<="
823infix 4 .<=
823infix 4 .<=
825-- | >>> printSQL $ true .> null_
825-- | >>> printSQL $ true .> null_
826-- (TRUE > NULL)
826-- (TRUE > NULL)
828− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
828+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
829− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
829+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
830− -> Condition schema relations grouping params
830+ -> Condition schema from grouping params
831(.>) = unsafeBinaryOp ">"
831(.>) = unsafeBinaryOp ">"
832infix 4 .>
832infix 4 .>
834-- | >>> printSQL currentDate
834-- | >>> printSQL currentDate
835-- CURRENT_DATE
835-- CURRENT_DATE
836currentDate
836currentDate
837− :: Expression schema relations grouping params (nullity 'PGdate)
837+ :: Expression schema from grouping params (nullity 'PGdate)
838currentDate = UnsafeExpression "CURRENT_DATE"
838currentDate = UnsafeExpression "CURRENT_DATE"
840-- | >>> printSQL currentTime
840-- | >>> printSQL currentTime
841-- CURRENT_TIME
841-- CURRENT_TIME
842currentTime
842currentTime
843− :: Expression schema relations grouping params (nullity 'PGtimetz)
843+ :: Expression schema from grouping params (nullity 'PGtimetz)
844currentTime = UnsafeExpression "CURRENT_TIME"
844currentTime = UnsafeExpression "CURRENT_TIME"
846-- | >>> printSQL currentTimestamp
846-- | >>> printSQL currentTimestamp
847-- CURRENT_TIMESTAMP
847-- CURRENT_TIMESTAMP
848currentTimestamp
848currentTimestamp
849− :: Expression schema relations grouping params (nullity 'PGtimestamptz)
849+ :: Expression schema from grouping params (nullity 'PGtimestamptz)
850currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
850currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
852-- | >>> printSQL localTime
852-- | >>> printSQL localTime
853-- LOCALTIME
853-- LOCALTIME
855− :: Expression schema relations grouping params (nullity 'PGtime)
855+ :: Expression schema from grouping params (nullity 'PGtime)
856localTime = UnsafeExpression "LOCALTIME"
856localTime = UnsafeExpression "LOCALTIME"
858-- | >>> printSQL localTimestamp
858-- | >>> printSQL localTimestamp
859-- LOCALTIMESTAMP
859-- LOCALTIMESTAMP
860localTimestamp
860localTimestamp
861− :: Expression schema relations grouping params (nullity 'PGtimestamp)
861+ :: Expression schema from grouping params (nullity 'PGtimestamp)
862localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
862localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
864{-----------------------------------------
864{-----------------------------------------
@@ -866,7 +866,7 @@ text
866-----------------------------------------}
866-----------------------------------------}
868instance IsString
868instance IsString
869− (Expression schema relations grouping params (nullity 'PGtext)) where
869+ (Expression schema from grouping params (nullity 'PGtext)) where
870 fromString str = UnsafeExpression $
870 fromString str = UnsafeExpression $
871 "E\'" <> fromString (escape =<< str) <> "\'"
871 "E\'" <> fromString (escape =<< str) <> "\'"
@@ -882,36 +882,36 @@ instance IsString
884instance Semigroup
884instance Semigroup
885− (Expression schema relations grouping params (nullity 'PGtext)) where
885+ (Expression schema from grouping params (nullity 'PGtext)) where
886 (<>) = unsafeBinaryOp "||"
886 (<>) = unsafeBinaryOp "||"
888instance Monoid
888instance Monoid
889− (Expression schema relations grouping params (nullity 'PGtext)) where
889+ (Expression schema from grouping params (nullity 'PGtext)) where
890 mempty = fromString ""
890 mempty = fromString ""
891 mappend = (<>)
891 mappend = (<>)
893-- | >>> printSQL $ lower "ARRRGGG"
893-- | >>> printSQL $ lower "ARRRGGG"
894-- lower(E'ARRRGGG')
894-- lower(E'ARRRGGG')
896− :: Expression schema relations grouping params (nullity 'PGtext)
896+ :: Expression schema from grouping params (nullity 'PGtext)
897 -- ^ string to lower case
897 -- ^ string to lower case
898− -> Expression schema relations grouping params (nullity 'PGtext)
898+ -> Expression schema from grouping params (nullity 'PGtext)
899lower = unsafeFunction "lower"
899lower = unsafeFunction "lower"
901-- | >>> printSQL $ upper "eeee"
901-- | >>> printSQL $ upper "eeee"
902-- upper(E'eeee')
902-- upper(E'eeee')
904− :: Expression schema relations grouping params (nullity 'PGtext)
904+ :: Expression schema from grouping params (nullity 'PGtext)
905 -- ^ string to upper case
905 -- ^ string to upper case
906− -> Expression schema relations grouping params (nullity 'PGtext)
906+ -> Expression schema from grouping params (nullity 'PGtext)
907upper = unsafeFunction "upper"
907upper = unsafeFunction "upper"
909-- | >>> printSQL $ charLength "four"
909-- | >>> printSQL $ charLength "four"
910-- char_length(E'four')
910-- char_length(E'four')
911charLength
911charLength
912− :: Expression schema relations grouping params (nullity 'PGtext)
912+ :: Expression schema from grouping params (nullity 'PGtext)
913 -- ^ string to measure
913 -- ^ string to measure
914− -> Expression schema relations grouping params (nullity 'PGint4)
914+ -> Expression schema from grouping params (nullity 'PGint4)
915charLength = unsafeFunction "char_length"
915charLength = unsafeFunction "char_length"
917-- | The `like` expression returns true if the @string@ matches
917-- | The `like` expression returns true if the @string@ matches
@@ -924,11 +924,11 @@ charLength = unsafeFunction "char_length"
924-- >>> printSQL $ "abc" `like` "a%"
924-- >>> printSQL $ "abc" `like` "a%"
925-- (E'abc' LIKE E'a%')
925-- (E'abc' LIKE E'a%')
927− :: Expression schema relations grouping params (nullity 'PGtext)
927+ :: Expression schema from grouping params (nullity 'PGtext)
928 -- ^ string
928 -- ^ string
929− -> Expression schema relations grouping params (nullity 'PGtext)
929+ -> Expression schema from grouping params (nullity 'PGtext)
930 -- ^ pattern
930 -- ^ pattern
931− -> Expression schema relations grouping params (nullity 'PGbool)
931+ -> Expression schema from grouping params (nullity 'PGbool)
932like = unsafeBinaryOp "LIKE"
932like = unsafeBinaryOp "LIKE"
934{-----------------------------------------
934{-----------------------------------------
@@ -943,33 +943,33 @@ Table 9.44: json and jsonb operators
943-- | Get JSON value (object field or array element) at a key.
943-- | Get JSON value (object field or array element) at a key.
945 :: (PGjson_ json, PGjsonKey key)
945 :: (PGjson_ json, PGjsonKey key)
946− => Expression schema relations grouping params (nullity json)
946+ => Expression schema from grouping params (nullity json)
947− -> Expression schema relations grouping params (nullity key)
947+ -> Expression schema from grouping params (nullity key)
948− -> Expression schema relations grouping params ('Null json)
948+ -> Expression schema from grouping params ('Null json)
949(.->) = unsafeBinaryOp "->"
949(.->) = unsafeBinaryOp "->"
951-- | Get JSON value (object field or array element) at a key, as text.
951-- | Get JSON value (object field or array element) at a key, as text.
953 :: (PGjson_ json, PGjsonKey key)
953 :: (PGjson_ json, PGjsonKey key)
954− => Expression schema relations grouping params (nullity json)
954+ => Expression schema from grouping params (nullity json)
955− -> Expression schema relations grouping params (nullity key)
955+ -> Expression schema from grouping params (nullity key)
956− -> Expression schema relations grouping params ('Null 'PGtext)
956+ -> Expression schema from grouping params ('Null 'PGtext)
957(.->>) = unsafeBinaryOp "->>"
957(.->>) = unsafeBinaryOp "->>"
959-- | Get JSON value at a specified path.
959-- | Get JSON value at a specified path.
961 :: (PGjson_ json, PGtextArray "(.#>)" path)
961 :: (PGjson_ json, PGtextArray "(.#>)" path)
962− => Expression schema relations grouping params (nullity json)
962+ => Expression schema from grouping params (nullity json)
963− -> Expression schema relations grouping params (nullity path)
963+ -> Expression schema from grouping params (nullity path)
964− -> Expression schema relations grouping params ('Null json)
964+ -> Expression schema from grouping params ('Null json)
965(.#>) = unsafeBinaryOp "#>"
965(.#>) = unsafeBinaryOp "#>"
967-- | Get JSON value at a specified path as text.
967-- | Get JSON value at a specified path as text.
969 :: (PGjson_ json, PGtextArray "(.#>>)" path)
969 :: (PGjson_ json, PGtextArray "(.#>>)" path)
970− => Expression schema relations grouping params (nullity json)
970+ => Expression schema from grouping params (nullity json)
971− -> Expression schema relations grouping params (nullity path)
971+ -> Expression schema from grouping params (nullity path)
972− -> Expression schema relations grouping params ('Null 'PGtext)
972+ -> Expression schema from grouping params ('Null 'PGtext)
973(.#>>) = unsafeBinaryOp "#>>"
973(.#>>) = unsafeBinaryOp "#>>"
975-- Additional jsonb operators
975-- Additional jsonb operators
@@ -977,43 +977,43 @@ Table 9.44: json and jsonb operators
977-- | Does the left JSON value contain the right JSON path/value entries at the
977-- | Does the left JSON value contain the right JSON path/value entries at the
978-- top level?
978-- top level?
980− :: Expression schema relations grouping params (nullity 'PGjsonb)
980+ :: Expression schema from grouping params (nullity 'PGjsonb)
981− -> Expression schema relations grouping params (nullity 'PGjsonb)
981+ -> Expression schema from grouping params (nullity 'PGjsonb)
982− -> Condition schema relations grouping params
982+ -> Condition schema from grouping params
983(.@>) = unsafeBinaryOp "@>"
983(.@>) = unsafeBinaryOp "@>"
985-- | Are the left JSON path/value entries contained at the top level within the
985-- | Are the left JSON path/value entries contained at the top level within the
986-- right JSON value?
986-- right JSON value?
988− :: Expression schema relations grouping params (nullity 'PGjsonb)
988+ :: Expression schema from grouping params (nullity 'PGjsonb)
989− -> Expression schema relations grouping params (nullity 'PGjsonb)
989+ -> Expression schema from grouping params (nullity 'PGjsonb)
990− -> Condition schema relations grouping params
990+ -> Condition schema from grouping params
991(.<@) = unsafeBinaryOp "<@"
991(.<@) = unsafeBinaryOp "<@"
993-- | Does the string exist as a top-level key within the JSON value?
993-- | Does the string exist as a top-level key within the JSON value?
995− :: Expression schema relations grouping params (nullity 'PGjsonb)
995+ :: Expression schema from grouping params (nullity 'PGjsonb)
996− -> Expression schema relations grouping params (nullity 'PGtext)
996+ -> Expression schema from grouping params (nullity 'PGtext)
997− -> Condition schema relations grouping params
997+ -> Condition schema from grouping params
998(.?) = unsafeBinaryOp "?"
998(.?) = unsafeBinaryOp "?"
1000-- | Do any of these array strings exist as top-level keys?
1000-- | Do any of these array strings exist as top-level keys?
1002− :: Expression schema relations grouping params (nullity 'PGjsonb)
1002+ :: Expression schema from grouping params (nullity 'PGjsonb)
1003− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1003+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1004− -> Condition schema relations grouping params
1004+ -> Condition schema from grouping params
1005(.?|) = unsafeBinaryOp "?|"
1005(.?|) = unsafeBinaryOp "?|"
1007-- | Do all of these array strings exist as top-level keys?
1007-- | Do all of these array strings exist as top-level keys?
1009− :: Expression schema relations grouping params (nullity 'PGjsonb)
1009+ :: Expression schema from grouping params (nullity 'PGjsonb)
1010− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1010+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1011− -> Condition schema relations grouping params
1011+ -> Condition schema from grouping params
1012(.?&) = unsafeBinaryOp "?&"
1012(.?&) = unsafeBinaryOp "?&"
1014-- | Concatenate two jsonb values into a new jsonb value.
1014-- | Concatenate two jsonb values into a new jsonb value.
1016− Semigroup (Expression schema relations grouping param (nullity 'PGjsonb)) where
1016+ Semigroup (Expression schema from grouping param (nullity 'PGjsonb)) where
1017 (<>) = unsafeBinaryOp "||"
1017 (<>) = unsafeBinaryOp "||"
1019-- | Delete a key or keys from a JSON object, or remove an array element.
1019-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1030,18 +1030,18 @@ instance
1030-- count from the end). Throws an error if top level container is not an array.
1030-- count from the end). Throws an error if top level container is not an array.
1032 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1032 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1033− => Expression schema relations grouping params (nullity 'PGjsonb)
1033+ => Expression schema from grouping params (nullity 'PGjsonb)
1034− -> Expression schema relations grouping params (nullity key)
1034+ -> Expression schema from grouping params (nullity key)
1035− -> Expression schema relations grouping params (nullity 'PGjsonb)
1035+ -> Expression schema from grouping params (nullity 'PGjsonb)
1036(.-.) = unsafeBinaryOp "-"
1036(.-.) = unsafeBinaryOp "-"
1038-- | Delete the field or element with specified path (for JSON arrays, negative
1038-- | Delete the field or element with specified path (for JSON arrays, negative
1039-- integers count from the end)
1039-- integers count from the end)
1041 :: PGtextArray "(#-.)" arrayty
1041 :: PGtextArray "(#-.)" arrayty
1042− => Expression schema relations grouping params (nullity 'PGjsonb)
1042+ => Expression schema from grouping params (nullity 'PGjsonb)
1043− -> Expression schema relations grouping params (nullity arrayty)
1043+ -> Expression schema from grouping params (nullity arrayty)
1044− -> Expression schema relations grouping params (nullity 'PGjsonb)
1044+ -> Expression schema from grouping params (nullity 'PGjsonb)
1045(#-.) = unsafeBinaryOp "#-"
1045(#-.) = unsafeBinaryOp "#-"
1047{-----------------------------------------
1047{-----------------------------------------
@@ -1049,11 +1049,11 @@ Table 9.45: JSON creation functions
1049-----------------------------------------}
1049-----------------------------------------}
1051-- | Literal binary JSON
1051-- | Literal binary JSON
1052−jsonbLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjsonb)
1052+jsonbLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjsonb)
1053jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1053jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1055-- | Literal JSON
1055-- | Literal JSON
1056−jsonLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjson)
1056+jsonLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjson)
1057jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1057jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1059-- | Returns the value as json. Arrays and composites are converted
1059-- | Returns the value as json. Arrays and composites are converted
@@ -1063,8 +1063,8 @@ jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.enco
1063-- number, a Boolean, or a null value, the text representation will be used, in
1063-- number, a Boolean, or a null value, the text representation will be used, in
1064-- such a fashion that it is a valid json value.
1064-- such a fashion that it is a valid json value.
1066− :: Expression schema relations grouping params (nullity ty)
1066+ :: Expression schema from grouping params (nullity ty)
1067− -> Expression schema relations grouping params (nullity 'PGjson)
1067+ -> Expression schema from grouping params (nullity 'PGjson)
1068toJson = unsafeFunction "to_json"
1068toJson = unsafeFunction "to_json"
1070-- | Returns the value as jsonb. Arrays and composites are converted
1070-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1074,43 +1074,43 @@ toJson = unsafeFunction "to_json"
1074-- number, a Boolean, or a null value, the text representation will be used, in
1074-- number, a Boolean, or a null value, the text representation will be used, in
1075-- such a fashion that it is a valid jsonb value.
1075-- such a fashion that it is a valid jsonb value.
1077− :: Expression schema relations grouping params (nullity ty)
1077+ :: Expression schema from grouping params (nullity ty)
1078− -> Expression schema relations grouping params (nullity 'PGjsonb)
1078+ -> Expression schema from grouping params (nullity 'PGjsonb)
1079toJsonb = unsafeFunction "to_jsonb"
1079toJsonb = unsafeFunction "to_jsonb"
1081-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1081-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1082-- becomes a JSON array of arrays.
1082-- becomes a JSON array of arrays.
1083arrayToJson
1083arrayToJson
1084 :: PGarray "arrayToJson" arr
1084 :: PGarray "arrayToJson" arr
1085− => Expression schema relations grouping params (nullity arr)
1085+ => Expression schema from grouping params (nullity arr)
1086− -> Expression schema relations grouping params (nullity 'PGjson)
1086+ -> Expression schema from grouping params (nullity 'PGjson)
1087arrayToJson = unsafeFunction "array_to_json"
1087arrayToJson = unsafeFunction "array_to_json"
1089-- | Returns the row as a JSON object.
1089-- | Returns the row as a JSON object.
1090rowToJson
1090rowToJson
1091− :: Expression schema relations grouping params (nullity ('PGcomposite ty))
1091+ :: Expression schema from grouping params (nullity ('PGcomposite ty))
1092− -> Expression schema relations grouping params (nullity 'PGjson)
1092+ -> Expression schema from grouping params (nullity 'PGjson)
1093rowToJson = unsafeFunction "row_to_json"
1093rowToJson = unsafeFunction "row_to_json"
1095-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1095-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1096-- argument list.
1096-- argument list.
1097jsonBuildArray
1097jsonBuildArray
1098 :: SListI elems
1098 :: SListI elems
1099− => NP (Expression schema relations grouping params) elems
1099+ => NP (Expression schema from grouping params) elems
1100− -> Expression schema relations grouping params (nullity 'PGjson)
1100+ -> Expression schema from grouping params (nullity 'PGjson)
1101jsonBuildArray = unsafeVariadicFunction "json_build_array"
1101jsonBuildArray = unsafeVariadicFunction "json_build_array"
1103-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1103-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1104-- variadic argument list.
1104-- variadic argument list.
1105jsonbBuildArray
1105jsonbBuildArray
1106 :: SListI elems
1106 :: SListI elems
1107− => NP (Expression schema relations grouping params) elems
1107+ => NP (Expression schema from grouping params) elems
1108− -> Expression schema relations grouping params (nullity 'PGjsonb)
1108+ -> Expression schema from grouping params (nullity 'PGjsonb)
1109jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1109jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1111unsafeRowFunction
1111unsafeRowFunction
1112 :: All Top elems
1112 :: All Top elems
1113− => NP (Aliased (Expression schema relations grouping params)) elems
1113+ => NP (Aliased (Expression schema from grouping params)) elems
1114 -> [ByteString]
1114 -> [ByteString]
1115unsafeRowFunction =
1115unsafeRowFunction =
1116 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1116 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1122,8 +1122,8 @@ unsafeRowFunction =
1122-- and values.
1122-- and values.
1123jsonBuildObject
1123jsonBuildObject
1124 :: All Top elems
1124 :: All Top elems
1125− => NP (Aliased (Expression schema relations grouping params)) elems
1125+ => NP (Aliased (Expression schema from grouping params)) elems
1126− -> Expression schema relations grouping params (nullity 'PGjson)
1126+ -> Expression schema from grouping params (nullity 'PGjson)
1127jsonBuildObject
1127jsonBuildObject
1128 = unsafeFunction "json_build_object"
1128 = unsafeFunction "json_build_object"
1129 . UnsafeExpression
1129 . UnsafeExpression
@@ -1135,8 +1135,8 @@ jsonBuildObject
1135-- between text and values.
1135-- between text and values.
1136jsonbBuildObject
1136jsonbBuildObject
1137 :: All Top elems
1137 :: All Top elems
1138− => NP (Aliased (Expression schema relations grouping params)) elems
1138+ => NP (Aliased (Expression schema from grouping params)) elems
1139− -> Expression schema relations grouping params (nullity 'PGjsonb)
1139+ -> Expression schema from grouping params (nullity 'PGjsonb)
1140jsonbBuildObject
1140jsonbBuildObject
1141 = unsafeFunction "jsonb_build_object"
1141 = unsafeFunction "jsonb_build_object"
1142 . UnsafeExpression
1142 . UnsafeExpression
@@ -1149,8 +1149,8 @@ jsonbBuildObject
1149-- array has exactly two elements, which are taken as a key/value pair.
1149-- array has exactly two elements, which are taken as a key/value pair.
1150jsonObject
1150jsonObject
1151 :: PGarrayOf "jsonObject" arr ('NotNull 'PGtext)
1151 :: PGarrayOf "jsonObject" arr ('NotNull 'PGtext)
1152− => Expression schema relations grouping params (nullity arr)
1152+ => Expression schema from grouping params (nullity arr)
1153− -> Expression schema relations grouping params (nullity 'PGjson)
1153+ -> Expression schema from grouping params (nullity 'PGjson)
1154jsonObject = unsafeFunction "json_object"
1154jsonObject = unsafeFunction "json_object"
1156-- | Builds a binary JSON object out of a text array. The array must have either
1156-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1159,8 +1159,8 @@ jsonObject = unsafeFunction "json_object"
1159-- array has exactly two elements, which are taken as a key/value pair.
1159-- array has exactly two elements, which are taken as a key/value pair.
1160jsonbObject
1160jsonbObject
1161 :: PGarrayOf "jsonbObject" arr ('NotNull 'PGtext)
1161 :: PGarrayOf "jsonbObject" arr ('NotNull 'PGtext)
1162− => Expression schema relations grouping params (nullity arr)
1162+ => Expression schema from grouping params (nullity arr)
1163− -> Expression schema relations grouping params (nullity 'PGjsonb)
1163+ -> Expression schema from grouping params (nullity 'PGjsonb)
1164jsonbObject = unsafeFunction "jsonb_object"
1164jsonbObject = unsafeFunction "jsonb_object"
1166-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1166-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1168,9 +1168,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1168jsonZipObject
1168jsonZipObject
1169 :: ( PGarrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1169 :: ( PGarrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1170 , PGarrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1170 , PGarrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1171− => Expression schema relations grouping params (nullity keysArray)
1171+ => Expression schema from grouping params (nullity keysArray)
1172− -> Expression schema relations grouping params (nullity valuesArray)
1172+ -> Expression schema from grouping params (nullity valuesArray)
1173− -> Expression schema relations grouping params (nullity 'PGjson)
1173+ -> Expression schema from grouping params (nullity 'PGjson)
1174jsonZipObject ks vs =
1174jsonZipObject ks vs =
1175 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1175 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
@@ -1180,9 +1180,9 @@ jsonZipObject ks vs =
1180jsonbZipObject
1180jsonbZipObject
1181 :: ( PGarrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1181 :: ( PGarrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1182 , PGarrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1182 , PGarrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1183− => Expression schema relations grouping params (nullity keysArray)
1183+ => Expression schema from grouping params (nullity keysArray)
1184− -> Expression schema relations grouping params (nullity valuesArray)
1184+ -> Expression schema from grouping params (nullity valuesArray)
1185− -> Expression schema relations grouping params (nullity 'PGjsonb)
1185+ -> Expression schema from grouping params (nullity 'PGjsonb)
1186jsonbZipObject ks vs =
1186jsonbZipObject ks vs =
1187 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1187 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
@@ -1192,23 +1192,23 @@ Table 9.46: JSON processing functions
1193-- | Returns the number of elements in the outermost JSON array.
1193-- | Returns the number of elements in the outermost JSON array.
1194jsonArrayLength
1194jsonArrayLength
1195− :: Expression schema relations grouping params (nullity 'PGjson)
1195+ :: Expression schema from grouping params (nullity 'PGjson)
1196− -> Expression schema relations grouping params (nullity 'PGint4)
1196+ -> Expression schema from grouping params (nullity 'PGint4)
1197jsonArrayLength = unsafeFunction "json_array_length"
1197jsonArrayLength = unsafeFunction "json_array_length"
1199-- | Returns the number of elements in the outermost binary JSON array.
1199-- | Returns the number of elements in the outermost binary JSON array.
1200jsonbArrayLength
1200jsonbArrayLength
1201− :: Expression schema relations grouping params (nullity 'PGjsonb)
1201+ :: Expression schema from grouping params (nullity 'PGjsonb)
1202− -> Expression schema relations grouping params (nullity 'PGint4)
1202+ -> Expression schema from grouping params (nullity 'PGint4)
1203jsonbArrayLength = unsafeFunction "jsonb_array_length"
1203jsonbArrayLength = unsafeFunction "jsonb_array_length"
1205-- | Returns JSON value pointed to by the given path (equivalent to #>
1205-- | Returns JSON value pointed to by the given path (equivalent to #>
1206-- operator).
1206-- operator).
1207jsonExtractPath
1207jsonExtractPath
1208 :: SListI elems
1208 :: SListI elems
1209− => Expression schema relations grouping params (nullity 'PGjson)
1209+ => Expression schema from grouping params (nullity 'PGjson)
1210− -> NP (Expression schema relations grouping params) elems
1210+ -> NP (Expression schema from grouping params) elems
1211− -> Expression schema relations grouping params (nullity 'PGjsonb)
1211+ -> Expression schema from grouping params (nullity 'PGjsonb)
1212jsonExtractPath x xs =
1212jsonExtractPath x xs =
1213 unsafeVariadicFunction "json_extract_path" (x :* xs)
1213 unsafeVariadicFunction "json_extract_path" (x :* xs)
@@ -1216,9 +1216,9 @@ jsonExtractPath x xs =
1216-- operator).
1216-- operator).
1217jsonbExtractPath
1217jsonbExtractPath
1218 :: SListI elems
1218 :: SListI elems
1219− => Expression schema relations grouping params (nullity 'PGjsonb)
1219+ => Expression schema from grouping params (nullity 'PGjsonb)
1220− -> NP (Expression schema relations grouping params) elems
1220+ -> NP (Expression schema from grouping params) elems
1221− -> Expression schema relations grouping params (nullity 'PGjsonb)
1221+ -> Expression schema from grouping params (nullity 'PGjsonb)
1222jsonbExtractPath x xs =
1222jsonbExtractPath x xs =
1223 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1223 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
@@ -1226,9 +1226,9 @@ jsonbExtractPath x xs =
1226-- operator), as text.
1226-- operator), as text.
1227jsonExtractPathAsText
1227jsonExtractPathAsText
1228 :: SListI elems
1228 :: SListI elems
1229− => Expression schema relations grouping params (nullity 'PGjson)
1229+ => Expression schema from grouping params (nullity 'PGjson)
1230− -> NP (Expression schema relations grouping params) elems
1230+ -> NP (Expression schema from grouping params) elems
1231− -> Expression schema relations grouping params (nullity 'PGjson)
1231+ -> Expression schema from grouping params (nullity 'PGjson)
1232jsonExtractPathAsText x xs =
1232jsonExtractPathAsText x xs =
1233 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1233 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
@@ -1236,50 +1236,50 @@ jsonExtractPathAsText x xs =
1236-- operator), as text.
1236-- operator), as text.
1237jsonbExtractPathAsText
1237jsonbExtractPathAsText
1238 :: SListI elems
1238 :: SListI elems
1239− => Expression schema relations grouping params (nullity 'PGjsonb)
1239+ => Expression schema from grouping params (nullity 'PGjsonb)
1240− -> NP (Expression schema relations grouping params) elems
1240+ -> NP (Expression schema from grouping params) elems
1241− -> Expression schema relations grouping params (nullity 'PGjsonb)
1241+ -> Expression schema from grouping params (nullity 'PGjsonb)
1242jsonbExtractPathAsText x xs =
1242jsonbExtractPathAsText x xs =
1243 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1243 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1245-- | Returns set of keys in the outermost JSON object.
1245-- | Returns set of keys in the outermost JSON object.
1246jsonObjectKeys
1246jsonObjectKeys
1247− :: Expression schema relations grouping params (nullity 'PGjson)
1247+ :: Expression schema from grouping params (nullity 'PGjson)
1248− -> Expression schema relations grouping params (nullity 'PGtext)
1248+ -> Expression schema from grouping params (nullity 'PGtext)
1249jsonObjectKeys = unsafeFunction "json_object_keys"
1249jsonObjectKeys = unsafeFunction "json_object_keys"
1251-- | Returns set of keys in the outermost JSON object.
1251-- | Returns set of keys in the outermost JSON object.
1252jsonbObjectKeys
1252jsonbObjectKeys
1253− :: Expression schema relations grouping params (nullity 'PGjsonb)
1253+ :: Expression schema from grouping params (nullity 'PGjsonb)
1254− -> Expression schema relations grouping params (nullity 'PGtext)
1254+ -> Expression schema from grouping params (nullity 'PGtext)
1255jsonbObjectKeys = unsafeFunction "jsonb_object_keys"
1255jsonbObjectKeys = unsafeFunction "jsonb_object_keys"
1257-- | Returns the type of the outermost JSON value as a text string. Possible
1257-- | Returns the type of the outermost JSON value as a text string. Possible
1258-- types are object, array, string, number, boolean, and null.
1258-- types are object, array, string, number, boolean, and null.
1259jsonTypeof
1259jsonTypeof
1260− :: Expression schema relations grouping params (nullity 'PGjson)
1260+ :: Expression schema from grouping params (nullity 'PGjson)
1261− -> Expression schema relations grouping params (nullity 'PGtext)
1261+ -> Expression schema from grouping params (nullity 'PGtext)
1262jsonTypeof = unsafeFunction "json_typeof"
1262jsonTypeof = unsafeFunction "json_typeof"
1264-- | Returns the type of the outermost binary JSON value as a text string.
1264-- | Returns the type of the outermost binary JSON value as a text string.
1265-- Possible types are object, array, string, number, boolean, and null.
1265-- Possible types are object, array, string, number, boolean, and null.
1266jsonbTypeof
1266jsonbTypeof
1267− :: Expression schema relations grouping params (nullity 'PGjsonb)
1267+ :: Expression schema from grouping params (nullity 'PGjsonb)
1268− -> Expression schema relations grouping params (nullity 'PGtext)
1268+ -> Expression schema from grouping params (nullity 'PGtext)
1269jsonbTypeof = unsafeFunction "jsonb_typeof"
1269jsonbTypeof = unsafeFunction "jsonb_typeof"
1271-- | Returns its argument with all object fields that have null values omitted.
1271-- | Returns its argument with all object fields that have null values omitted.
1272-- Other null values are untouched.
1272-- Other null values are untouched.
1273jsonStripNulls
1273jsonStripNulls
1274− :: Expression schema relations grouping params (nullity 'PGjson)
1274+ :: Expression schema from grouping params (nullity 'PGjson)
1275− -> Expression schema relations grouping params (nullity 'PGjson)
1275+ -> Expression schema from grouping params (nullity 'PGjson)
1276jsonStripNulls = unsafeFunction "json_strip_nulls"
1276jsonStripNulls = unsafeFunction "json_strip_nulls"
1278-- | Returns its argument with all object fields that have null values omitted.
1278-- | Returns its argument with all object fields that have null values omitted.
1279-- Other null values are untouched.
1279-- Other null values are untouched.
1280jsonbStripNulls
1280jsonbStripNulls
1281− :: Expression schema relations grouping params (nullity 'PGjsonb)
1281+ :: Expression schema from grouping params (nullity 'PGjsonb)
1282− -> Expression schema relations grouping params (nullity 'PGjsonb)
1282+ -> Expression schema from grouping params (nullity 'PGjsonb)
1283jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1283jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1285-- | @ jsonbSet target path new_value create_missing @
1285-- | @ jsonbSet target path new_value create_missing @
@@ -1291,11 +1291,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1291-- arrays.
1291-- arrays.
1293 :: PGtextArray "jsonbSet" arr
1293 :: PGtextArray "jsonbSet" arr
1294− => Expression schema relations grouping params (nullity 'PGjsonb)
1294+ => Expression schema from grouping params (nullity 'PGjsonb)
1295− -> Expression schema relations grouping params (nullity arr)
1295+ -> Expression schema from grouping params (nullity arr)
1296− -> Expression schema relations grouping params (nullity 'PGjsonb)
1296+ -> Expression schema from grouping params (nullity 'PGjsonb)
1297− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1297+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1298− -> Expression schema relations grouping params (nullity 'PGjsonb)
1298+ -> Expression schema from grouping params (nullity 'PGjsonb)
1299jsonbSet tgt path val createMissing = case createMissing of
1299jsonbSet tgt path val createMissing = case createMissing of
1300 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1300 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1301 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1301 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1310,19 +1310,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1310-- in path count from the end of JSON arrays.
1310-- in path count from the end of JSON arrays.
1311jsonbInsert
1311jsonbInsert
1312 :: PGtextArray "jsonbInsert" arr
1312 :: PGtextArray "jsonbInsert" arr
1313− => Expression schema relations grouping params (nullity 'PGjsonb)
1313+ => Expression schema from grouping params (nullity 'PGjsonb)
1314− -> Expression schema relations grouping params (nullity arr)
1314+ -> Expression schema from grouping params (nullity arr)
1315− -> Expression schema relations grouping params (nullity 'PGjsonb)
1315+ -> Expression schema from grouping params (nullity 'PGjsonb)
1316− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1316+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1317− -> Expression schema relations grouping params (nullity 'PGjsonb)
1317+ -> Expression schema from grouping params (nullity 'PGjsonb)
1318jsonbInsert tgt path val insertAfter = case insertAfter of
1318jsonbInsert tgt path val insertAfter = case insertAfter of
1319 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1319 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1320 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1320 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1322-- | Returns its argument as indented JSON text.
1322-- | Returns its argument as indented JSON text.
1323jsonbPretty
1323jsonbPretty
1324− :: Expression schema relations grouping params (nullity 'PGjsonb)
1324+ :: Expression schema from grouping params (nullity 'PGjsonb)
1325− -> Expression schema relations grouping params (nullity 'PGtext)
1325+ -> Expression schema from grouping params (nullity 'PGtext)
1326jsonbPretty = unsafeFunction "jsonb_pretty"
1326jsonbPretty = unsafeFunction "jsonb_pretty"
1328{-----------------------------------------
1328{-----------------------------------------
@@ -1332,16 +1332,16 @@ aggregation
1332-- | escape hatch to define aggregate functions
1332-- | escape hatch to define aggregate functions
1333unsafeAggregate
1333unsafeAggregate
1334 :: ByteString -- ^ aggregate function
1334 :: ByteString -- ^ aggregate function
1335− -> Expression schema relations 'Ungrouped params (xty)
1335+ -> Expression schema from 'Ungrouped params (xty)
1336− -> Expression schema relations ('Grouped bys) params (yty)
1336+ -> Expression schema from ('Grouped bys) params (yty)
1337unsafeAggregate fun x = UnsafeExpression $ mconcat
1337unsafeAggregate fun x = UnsafeExpression $ mconcat
1338 [fun, "(", renderExpression x, ")"]
1338 [fun, "(", renderExpression x, ")"]
1340-- | escape hatch to define aggregate functions over distinct values
1340-- | escape hatch to define aggregate functions over distinct values
1341unsafeAggregateDistinct
1341unsafeAggregateDistinct
1342 :: ByteString -- ^ aggregate function
1342 :: ByteString -- ^ aggregate function
1343− -> Expression schema relations 'Ungrouped params (xty)
1343+ -> Expression schema from 'Ungrouped params (xty)
1344− -> Expression schema relations ('Grouped bys) params (yty)
1344+ -> Expression schema from ('Grouped bys) params (yty)
1345unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1345unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1346 [fun, "(DISTINCT ", renderExpression x, ")"]
1346 [fun, "(DISTINCT ", renderExpression x, ")"]
@@ -1354,9 +1354,9 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1354-- sum("col")
1354-- sum("col")
1356 :: PGNum ty
1356 :: PGNum ty
1357− => Expression schema relations 'Ungrouped params (nullity ty)
1357+ => Expression schema from 'Ungrouped params (nullity ty)
1358 -- ^ what to sum
1358 -- ^ what to sum
1359− -> Expression schema relations ('Grouped bys) params (nullity ty)
1359+ -> Expression schema from ('Grouped bys) params (nullity ty)
1360sum_ = unsafeAggregate "sum"
1360sum_ = unsafeAggregate "sum"
1362-- | >>> :{
1362-- | >>> :{
@@ -1368,18 +1368,18 @@ sum_ = unsafeAggregate "sum"
1368-- sum(DISTINCT "col")
1368-- sum(DISTINCT "col")
1369sumDistinct
1369sumDistinct
1370 :: PGNum ty
1370 :: PGNum ty
1371− => Expression schema relations 'Ungrouped params (nullity ty)
1371+ => Expression schema from 'Ungrouped params (nullity ty)
1372 -- ^ what to sum
1372 -- ^ what to sum
1373− -> Expression schema relations ('Grouped bys) params (nullity ty)
1373+ -> Expression schema from ('Grouped bys) params (nullity ty)
1374sumDistinct = unsafeAggregateDistinct "sum"
1374sumDistinct = unsafeAggregateDistinct "sum"
1376-- | A constraint for `PGType`s that you can take averages of and the resulting
1376-- | A constraint for `PGType`s that you can take averages of and the resulting
1377-- `PGType`.
1377-- `PGType`.
1378class PGAvg ty avg | ty -> avg where
1378class PGAvg ty avg | ty -> avg where
1379 avg, avgDistinct
1379 avg, avgDistinct
1380− :: Expression schema relations 'Ungrouped params (nullity ty)
1380+ :: Expression schema from 'Ungrouped params (nullity ty)
1381 -- ^ what to average
1381 -- ^ what to average
1382− -> Expression schema relations ('Grouped bys) params (nullity avg)
1382+ -> Expression schema from ('Grouped bys) params (nullity avg)
1383 avg = unsafeAggregate "avg"
1383 avg = unsafeAggregate "avg"
1384 avgDistinct = unsafeAggregateDistinct "avg"
1384 avgDistinct = unsafeAggregateDistinct "avg"
1385instance PGAvg 'PGint2 'PGnumeric
1385instance PGAvg 'PGint2 'PGnumeric
@@ -1399,9 +1399,9 @@ instance PGAvg 'PGinterval 'PGinterval
1399-- bit_and("col")
1399-- bit_and("col")
1401 :: PGIntegral int
1401 :: PGIntegral int
1402− => Expression schema relations 'Ungrouped params (nullity int)
1402+ => Expression schema from 'Ungrouped params (nullity int)
1403 -- ^ what to aggregate
1403 -- ^ what to aggregate
1404− -> Expression schema relations ('Grouped bys) params (nullity int)
1404+ -> Expression schema from ('Grouped bys) params (nullity int)
1405bitAnd = unsafeAggregate "bit_and"
1405bitAnd = unsafeAggregate "bit_and"
1407-- | >>> :{
1407-- | >>> :{
@@ -1413,9 +1413,9 @@ bitAnd = unsafeAggregate "bit_and"
1413-- bit_or("col")
1413-- bit_or("col")
1415 :: PGIntegral int
1415 :: PGIntegral int
1416− => Expression schema relations 'Ungrouped params (nullity int)
1416+ => Expression schema from 'Ungrouped params (nullity int)
1417 -- ^ what to aggregate
1417 -- ^ what to aggregate
1418− -> Expression schema relations ('Grouped bys) params (nullity int)
1418+ -> Expression schema from ('Grouped bys) params (nullity int)
1419bitOr = unsafeAggregate "bit_or"
1419bitOr = unsafeAggregate "bit_or"
1421-- | >>> :{
1421-- | >>> :{
@@ -1427,9 +1427,9 @@ bitOr = unsafeAggregate "bit_or"
1427-- bit_and(DISTINCT "col")
1427-- bit_and(DISTINCT "col")
1428bitAndDistinct
1428bitAndDistinct
1429 :: PGIntegral int
1429 :: PGIntegral int
1430− => Expression schema relations 'Ungrouped params (nullity int)
1430+ => Expression schema from 'Ungrouped params (nullity int)
1431 -- ^ what to aggregate
1431 -- ^ what to aggregate
1432− -> Expression schema relations ('Grouped bys) params (nullity int)
1432+ -> Expression schema from ('Grouped bys) params (nullity int)
1433bitAndDistinct = unsafeAggregateDistinct "bit_and"
1433bitAndDistinct = unsafeAggregateDistinct "bit_and"
1435-- | >>> :{
1435-- | >>> :{
@@ -1441,9 +1441,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
1441-- bit_or(DISTINCT "col")
1441-- bit_or(DISTINCT "col")
1442bitOrDistinct
1442bitOrDistinct
1443 :: PGIntegral int
1443 :: PGIntegral int
1444− => Expression schema relations 'Ungrouped params (nullity int)
1444+ => Expression schema from 'Ungrouped params (nullity int)
1445 -- ^ what to aggregate
1445 -- ^ what to aggregate
1446− -> Expression schema relations ('Grouped bys) params (nullity int)
1446+ -> Expression schema from ('Grouped bys) params (nullity int)
1447bitOrDistinct = unsafeAggregateDistinct "bit_or"
1447bitOrDistinct = unsafeAggregateDistinct "bit_or"
1449-- | >>> :{
1449-- | >>> :{
@@ -1454,9 +1454,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
1455-- bool_and("col")
1455-- bool_and("col")
1457− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1457+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1458 -- ^ what to aggregate
1458 -- ^ what to aggregate
1459− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1459+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1460boolAnd = unsafeAggregate "bool_and"
1460boolAnd = unsafeAggregate "bool_and"
1462-- | >>> :{
1462-- | >>> :{
@@ -1467,9 +1467,9 @@ boolAnd = unsafeAggregate "bool_and"
1468-- bool_or("col")
1468-- bool_or("col")
1470− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1470+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1471 -- ^ what to aggregate
1471 -- ^ what to aggregate
1472− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1472+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1473boolOr = unsafeAggregate "bool_or"
1473boolOr = unsafeAggregate "bool_or"
1475-- | >>> :{
1475-- | >>> :{
@@ -1480,9 +1480,9 @@ boolOr = unsafeAggregate "bool_or"
1481-- bool_and(DISTINCT "col")
1481-- bool_and(DISTINCT "col")
1482boolAndDistinct
1482boolAndDistinct
1483− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1483+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1484 -- ^ what to aggregate
1484 -- ^ what to aggregate
1485− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1485+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1486boolAndDistinct = unsafeAggregateDistinct "bool_and"
1486boolAndDistinct = unsafeAggregateDistinct "bool_and"
1488-- | >>> :{
1488-- | >>> :{
@@ -1493,9 +1493,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
1494-- bool_or(DISTINCT "col")
1494-- bool_or(DISTINCT "col")
1495boolOrDistinct
1495boolOrDistinct
1496− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1496+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1497 -- ^ what to aggregate
1497 -- ^ what to aggregate
1498− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1498+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1499boolOrDistinct = unsafeAggregateDistinct "bool_or"
1499boolOrDistinct = unsafeAggregateDistinct "bool_or"
1501-- | A special aggregation that does not require an input
1501-- | A special aggregation that does not require an input
@@ -1503,7 +1503,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1503-- >>> printSQL countStar
1503-- >>> printSQL countStar
1504-- count(*)
1504-- count(*)
1505countStar
1505countStar
1506− :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1506+ :: Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1507countStar = UnsafeExpression $ "count(*)"
1507countStar = UnsafeExpression $ "count(*)"
1509-- | >>> :{
1509-- | >>> :{
@@ -1514,9 +1514,9 @@ countStar = UnsafeExpression $ "count(*)"
1515-- count("col")
1515-- count("col")
1517− :: Expression schema relations 'Ungrouped params ty
1517+ :: Expression schema from 'Ungrouped params ty
1518 -- ^ what to count
1518 -- ^ what to count
1519− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1519+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1520count = unsafeAggregate "count"
1520count = unsafeAggregate "count"
1522-- | >>> :{
1522-- | >>> :{
@@ -1527,9 +1527,9 @@ count = unsafeAggregate "count"
1528-- count(DISTINCT "col")
1528-- count(DISTINCT "col")
1529countDistinct
1529countDistinct
1530− :: Expression schema relations 'Ungrouped params ty
1530+ :: Expression schema from 'Ungrouped params ty
1531 -- ^ what to count
1531 -- ^ what to count
1532− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1532+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1533countDistinct = unsafeAggregateDistinct "count"
1533countDistinct = unsafeAggregateDistinct "count"
1535-- | synonym for `boolAnd`
1535-- | synonym for `boolAnd`
@@ -1542,9 +1542,9 @@ countDistinct = unsafeAggregateDistinct "count"
1543-- every("col")
1543-- every("col")
1545− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1545+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1546 -- ^ what to aggregate
1546 -- ^ what to aggregate
1547− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1547+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1548every = unsafeAggregate "every"
1548every = unsafeAggregate "every"
1550-- | synonym for `boolAndDistinct`
1550-- | synonym for `boolAndDistinct`
@@ -1557,16 +1557,16 @@ every = unsafeAggregate "every"
1558-- every(DISTINCT "col")
1558-- every(DISTINCT "col")
1559everyDistinct
1559everyDistinct
1560− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1560+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1561 -- ^ what to aggregate
1561 -- ^ what to aggregate
1562− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1562+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1563everyDistinct = unsafeAggregateDistinct "every"
1563everyDistinct = unsafeAggregateDistinct "every"
1565-- | minimum and maximum aggregation
1565-- | minimum and maximum aggregation
1566max_, min_, maxDistinct, minDistinct
1566max_, min_, maxDistinct, minDistinct
1567− :: Expression schema relations 'Ungrouped params (nullity ty)
1567+ :: Expression schema from 'Ungrouped params (nullity ty)
1568 -- ^ what to aggregate
1568 -- ^ what to aggregate
1569− -> Expression schema relations ('Grouped bys) params (nullity ty)
1569+ -> Expression schema from ('Grouped bys) params (nullity ty)
1570max_ = unsafeAggregate "max"
1570max_ = unsafeAggregate "max"
1571min_ = unsafeAggregate "min"
1571min_ = unsafeAggregate "min"
1572maxDistinct = unsafeAggregateDistinct "max"
1572maxDistinct = unsafeAggregateDistinct "max"