@@ -217,7 +217,7 @@ values from primitive expression using arithmetic, logical,
217and other operations.
217and other operations.
219newtype Expression
219newtype Expression
220− (schema :: SchemaType)
220+ (db :: DBType)
221 (from :: FromType)
221 (from :: FromType)
222 (grouping :: Grouping)
222 (grouping :: Grouping)
223 (params :: [NullityType])
223 (params :: [NullityType])
@@ -225,7 +225,7 @@ newtype Expression
225 = UnsafeExpression { renderExpression :: ByteString }
225 = UnsafeExpression { renderExpression :: ByteString }
226 deriving (GHC.Generic,Show,Eq,Ord,NFData)
226 deriving (GHC.Generic,Show,Eq,Ord,NFData)
228−instance RenderSQL (Expression schema from grouping params ty) where
228+instance RenderSQL (Expression db from grouping params ty) where
229 renderSQL = renderExpression
229 renderSQL = renderExpression
231{- | A `HasParameter` constraint is used to indicate a value that is
231{- | A `HasParameter` constraint is used to indicate a value that is
@@ -238,7 +238,7 @@ refer to the out-of-line data values.
239class KnownNat n => HasParameter
239class KnownNat n => HasParameter
240 (n :: Nat)
240 (n :: Nat)
241− (schema :: SchemaType)
241+ (db :: DBType)
242 (params :: [NullityType])
242 (params :: [NullityType])
243 (ty :: NullityType)
243 (ty :: NullityType)
244 | n params -> ty where
244 | n params -> ty where
@@ -248,8 +248,8 @@ class KnownNat n => HasParameter
248 -- >>> printSQL expr
248 -- >>> printSQL expr
249 -- ($1 :: int4)
249 -- ($1 :: int4)
250 parameter
250 parameter
251− :: TypeExpression schema ty
251+ :: TypeExpression db ty
252− -> Expression schema from grouping params ty
252+ -> Expression db from grouping params ty
253 parameter ty = UnsafeExpression $ parenthesized $
253 parameter ty = UnsafeExpression $ parenthesized $
254 "$" <> renderNat @n <+> "::"
254 "$" <> renderNat @n <+> "::"
255 <+> renderTypeExpression ty
255 <+> renderTypeExpression ty
@@ -264,34 +264,34 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
264-- >>> printSQL expr
264-- >>> printSQL expr
265-- ($1 :: int4)
265-- ($1 :: int4)
267− :: forall n schema params from grouping ty
267+ :: forall n db params from grouping ty
268− . (PGTyped schema ty, HasParameter n schema params ty)
268+ . (PGTyped db ty, HasParameter n db params ty)
269− => Expression schema from grouping params ty -- ^ param
269+ => Expression db from grouping params ty -- ^ param
270param = parameter @n pgtype
270param = parameter @n pgtype
272instance (HasUnique table from columns, Has column columns ty)
272instance (HasUnique table from columns, Has column columns ty)
273− => IsLabel column (Expression schema from 'Ungrouped params ty) where
273+ => IsLabel column (Expression db from 'Ungrouped params ty) where
274 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
274 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
275instance (HasUnique table from columns, Has column columns ty)
275instance (HasUnique table from columns, Has column columns ty)
276 => IsLabel column
276 => IsLabel column
277− (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
277+ (Aliased (Expression db from 'Ungrouped params) (column ::: ty)) where
278 fromLabel = fromLabel @column `As` Alias @column
278 fromLabel = fromLabel @column `As` Alias @column
279instance (HasUnique table from columns, Has column columns ty)
279instance (HasUnique table from columns, Has column columns ty)
280 => IsLabel column
280 => IsLabel column
281− (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
281+ (NP (Aliased (Expression db from 'Ungrouped params)) '[column ::: ty]) where
282 fromLabel = fromLabel @column :* Nil
282 fromLabel = fromLabel @column :* Nil
284instance (Has table from columns, Has column columns ty)
284instance (Has table from columns, Has column columns ty)
285− => IsQualified table column (Expression schema from 'Ungrouped params ty) where
285+ => IsQualified table column (Expression db from 'Ungrouped params ty) where
286 table ! column = UnsafeExpression $
286 table ! column = UnsafeExpression $
287 renderAlias table <> "." <> renderAlias column
287 renderAlias table <> "." <> renderAlias column
288instance (Has table from columns, Has column columns ty)
288instance (Has table from columns, Has column columns ty)
289 => IsQualified table column
289 => IsQualified table column
290− (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
290+ (Aliased (Expression db from 'Ungrouped params) (column ::: ty)) where
291 table ! column = table ! column `As` column
291 table ! column = table ! column `As` column
292instance (Has table from columns, Has column columns ty)
292instance (Has table from columns, Has column columns ty)
293 => IsQualified table column
293 => IsQualified table column
294− (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
294+ (NP (Aliased (Expression db from 'Ungrouped params)) '[column ::: ty]) where
295 table ! column = table ! column :* Nil
295 table ! column = table ! column :* Nil
@@ -299,14 +299,14 @@ instance
299 , Has column columns ty
299 , Has column columns ty
300 , GroupedBy table column bys
300 , GroupedBy table column bys
301 ) => IsLabel column
301 ) => IsLabel column
302− (Expression schema from ('Grouped bys) params ty) where
302+ (Expression db from ('Grouped bys) params ty) where
303 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
303 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
305 ( HasUnique table from columns
305 ( HasUnique table from columns
306 , Has column columns ty
306 , Has column columns ty
307 , GroupedBy table column bys
307 , GroupedBy table column bys
308 ) => IsLabel column
308 ) => IsLabel column
309− ( Aliased (Expression schema from ('Grouped bys) params)
309+ ( Aliased (Expression db from ('Grouped bys) params)
310 (column ::: ty) ) where
310 (column ::: ty) ) where
311 fromLabel = fromLabel @column `As` Alias @column
311 fromLabel = fromLabel @column `As` Alias @column
@@ -314,7 +314,7 @@ instance
314 , Has column columns ty
314 , Has column columns ty
315 , GroupedBy table column bys
315 , GroupedBy table column bys
316 ) => IsLabel column
316 ) => IsLabel column
317− ( NP (Aliased (Expression schema from ('Grouped bys) params))
317+ ( NP (Aliased (Expression db from ('Grouped bys) params))
318 '[column ::: ty] ) where
318 '[column ::: ty] ) where
319 fromLabel = fromLabel @column :* Nil
319 fromLabel = fromLabel @column :* Nil
@@ -323,7 +323,7 @@ instance
323 , Has column columns ty
323 , Has column columns ty
324 , GroupedBy table column bys
324 , GroupedBy table column bys
325 ) => IsQualified table column
325 ) => IsQualified table column
326− (Expression schema from ('Grouped bys) params ty) where
326+ (Expression db from ('Grouped bys) params ty) where
327 table ! column = UnsafeExpression $
327 table ! column = UnsafeExpression $
328 renderAlias table <> "." <> renderAlias column
328 renderAlias table <> "." <> renderAlias column
@@ -331,7 +331,7 @@ instance
331 , Has column columns ty
331 , Has column columns ty
332 , GroupedBy table column bys
332 , GroupedBy table column bys
333 ) => IsQualified table column
333 ) => IsQualified table column
334− (Aliased (Expression schema from ('Grouped bys) params)
334+ (Aliased (Expression db from ('Grouped bys) params)
335 (column ::: ty)) where
335 (column ::: ty)) where
336 table ! column = table ! column `As` column
336 table ! column = table ! column `As` column
@@ -339,7 +339,7 @@ instance
339 , Has column columns ty
339 , Has column columns ty
340 , GroupedBy table column bys
340 , GroupedBy table column bys
341 ) => IsQualified table column
341 ) => IsQualified table column
342− ( NP (Aliased (Expression schema from ('Grouped bys) params))
342+ ( NP (Aliased (Expression db from ('Grouped bys) params))
343 '[column ::: ty]) where
343 '[column ::: ty]) where
344 table ! column = table ! column :* Nil
344 table ! column = table ! column :* Nil
@@ -347,7 +347,7 @@ instance
348-- >>> printSQL null_
348-- >>> printSQL null_
350−null_ :: Expression schema rels grouping params ('Null ty)
350+null_ :: Expression db rels grouping params ('Null ty)
351null_ = UnsafeExpression "NULL"
351null_ = UnsafeExpression "NULL"
353-- | analagous to `Just`
353-- | analagous to `Just`
@@ -355,8 +355,8 @@ null_ = UnsafeExpression "NULL"
355-- >>> printSQL $ notNull true
355-- >>> printSQL $ notNull true
358− :: Expression schema rels grouping params ('NotNull ty)
358+ :: Expression db rels grouping params ('NotNull ty)
359− -> Expression schema rels grouping params ('Null ty)
359+ -> Expression db rels grouping params ('Null ty)
360notNull = UnsafeExpression . renderExpression
360notNull = UnsafeExpression . renderExpression
362-- | return the leftmost value which is not NULL
362-- | return the leftmost value which is not NULL
@@ -364,11 +364,11 @@ notNull = UnsafeExpression . renderExpression
364-- >>> printSQL $ coalesce [null_, true] false
364-- >>> printSQL $ coalesce [null_, true] false
365-- COALESCE(NULL, TRUE, FALSE)
365-- COALESCE(NULL, TRUE, FALSE)
367− :: [Expression schema from grouping params ('Null ty)]
367+ :: [Expression db from grouping params ('Null ty)]
368 -- ^ @NULL@s may be present
368 -- ^ @NULL@s may be present
369− -> Expression schema from grouping params ('NotNull ty)
369+ -> Expression db from grouping params ('NotNull ty)
370 -- ^ @NULL@ is absent
370 -- ^ @NULL@ is absent
371− -> Expression schema from grouping params ('NotNull ty)
371+ -> Expression db from grouping params ('NotNull ty)
372coalesce nullxs notNullx = UnsafeExpression $
372coalesce nullxs notNullx = UnsafeExpression $
373 "COALESCE" <> parenthesized (commaSeparated
373 "COALESCE" <> parenthesized (commaSeparated
374 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
374 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -378,26 +378,26 @@ coalesce nullxs notNullx = UnsafeExpression $
378-- >>> printSQL $ fromNull true null_
378-- >>> printSQL $ fromNull true null_
379-- COALESCE(NULL, TRUE)
379-- COALESCE(NULL, TRUE)
381− :: Expression schema from grouping params ('NotNull ty)
381+ :: Expression db from grouping params ('NotNull ty)
382 -- ^ what to convert @NULL@ to
382 -- ^ what to convert @NULL@ to
383− -> Expression schema from grouping params ('Null ty)
383+ -> Expression db from grouping params ('Null ty)
384− -> Expression schema from grouping params ('NotNull ty)
384+ -> Expression db from grouping params ('NotNull ty)
385fromNull notNullx nullx = coalesce [nullx] notNullx
385fromNull notNullx nullx = coalesce [nullx] notNullx
387-- | >>> printSQL $ null_ & isNull
387-- | >>> printSQL $ null_ & isNull
388-- NULL IS NULL
388-- NULL IS NULL
390− :: Expression schema from grouping params ('Null ty)
390+ :: Expression db from grouping params ('Null ty)
391 -- ^ possibly @NULL@
391 -- ^ possibly @NULL@
392− -> Condition schema from grouping params
392+ -> Condition db from grouping params
393isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
393isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
395-- | >>> printSQL $ null_ & isNotNull
395-- | >>> printSQL $ null_ & isNotNull
396-- NULL IS NOT NULL
396-- NULL IS NOT NULL
398− :: Expression schema from grouping params ('Null ty)
398+ :: Expression db from grouping params ('Null ty)
399 -- ^ possibly @NULL@
399 -- ^ possibly @NULL@
400− -> Condition schema from grouping params
400+ -> Condition db from grouping params
401isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
401isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
403-- | analagous to `maybe` using @IS NULL@
403-- | analagous to `maybe` using @IS NULL@
@@ -405,13 +405,13 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
405-- >>> printSQL $ matchNull true not_ null_
405-- >>> printSQL $ matchNull true not_ null_
406-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
406-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
408− :: Expression schema from grouping params (nullty)
408+ :: Expression db from grouping params (nullty)
409 -- ^ what to convert @NULL@ to
409 -- ^ what to convert @NULL@ to
410− -> ( Expression schema from grouping params ('NotNull ty)
410+ -> ( Expression db from grouping params ('NotNull ty)
411− -> Expression schema from grouping params (nullty) )
411+ -> Expression db from grouping params (nullty) )
412 -- ^ function to perform when @NULL@ is absent
412 -- ^ function to perform when @NULL@ is absent
413− -> Expression schema from grouping params ('Null ty)
413+ -> Expression db from grouping params ('Null ty)
414− -> Expression schema from grouping params (nullty)
414+ -> Expression db from grouping params (nullty)
415matchNull y f x = ifThenElse (isNull x) y
415matchNull y f x = ifThenElse (isNull x) y
416 (f (UnsafeExpression (renderExpression x)))
416 (f (UnsafeExpression (renderExpression x)))
@@ -419,25 +419,25 @@ matchNull y f x = ifThenElse (isNull x) y
419`nullIf` gives @NULL@.
419`nullIf` gives @NULL@.
421>>> :set -XTypeApplications -XDataKinds
421>>> :set -XTypeApplications -XDataKinds
422−>>> let expr = nullIf false (param @1) :: Expression schema rels grp '[ 'NotNull 'PGbool] ('Null 'PGbool)
422+>>> let expr = nullIf false (param @1) :: Expression db rels grp '[ 'NotNull 'PGbool] ('Null 'PGbool)
423>>> printSQL expr
423>>> printSQL expr
424NULL IF (FALSE, ($1 :: bool))
424NULL IF (FALSE, ($1 :: bool))
427− :: Expression schema from grouping params ('NotNull ty)
427+ :: Expression db from grouping params ('NotNull ty)
428 -- ^ @NULL@ is absent
428 -- ^ @NULL@ is absent
429− -> Expression schema from grouping params ('NotNull ty)
429+ -> Expression db from grouping params ('NotNull ty)
430 -- ^ @NULL@ is absent
430 -- ^ @NULL@ is absent
431− -> Expression schema from grouping params ('Null ty)
431+ -> Expression db from grouping params ('Null ty)
432nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
432nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433 (renderExpression x <> ", " <> renderExpression y)
433 (renderExpression x <> ", " <> renderExpression y)
435-- | >>> printSQL $ array [null_, false, true]
435-- | >>> printSQL $ array [null_, false, true]
436-- ARRAY[NULL, FALSE, TRUE]
436-- ARRAY[NULL, FALSE, TRUE]
438− :: [Expression schema from grouping params ty]
438+ :: [Expression db from grouping params ty]
439 -- ^ array elements
439 -- ^ array elements
440− -> Expression schema from grouping params (nullity ('PGvararray ty))
440+ -> Expression db from grouping params (nullity ('PGvararray ty))
441array xs = UnsafeExpression $
441array xs = UnsafeExpression $
442 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
442 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
@@ -445,13 +445,13 @@ array xs = UnsafeExpression $
445-- (ARRAY[NULL, FALSE, TRUE])[2]
445-- (ARRAY[NULL, FALSE, TRUE])[2]
447 :: Word64 -- ^ index
447 :: Word64 -- ^ index
448− -> Expression schema from grouping params (nullity ('PGvararray ty)) -- ^ array
448+ -> Expression db from grouping params (nullity ('PGvararray ty)) -- ^ array
449− -> Expression schema from grouping params (NullifyType ty)
449+ -> Expression db from grouping params (NullifyType ty)
450index n expr = UnsafeExpression $
450index n expr = UnsafeExpression $
451 parenthesized (renderExpression expr) <> "[" <> fromString (show n) <> "]"
451 parenthesized (renderExpression expr) <> "[" <> fromString (show n) <> "]"
453instance (KnownSymbol label, label `In` labels) => IsPGlabel label
453instance (KnownSymbol label, label `In` labels) => IsPGlabel label
454− (Expression schema from grouping params (nullity ('PGenum labels))) where
454+ (Expression db from grouping params (nullity ('PGenum labels))) where
455 label = UnsafeExpression $ renderLabel (PGlabel @label)
455 label = UnsafeExpression $ renderLabel (PGlabel @label)
457-- | A row constructor is an expression that builds a row value
457-- | A row constructor is an expression that builds a row value
@@ -468,9 +468,9 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
468-- ROW(0, 1)
468-- ROW(0, 1)
470 :: SListI row
470 :: SListI row
471− => NP (Aliased (Expression schema from grouping params)) row
471+ => NP (Aliased (Expression db from grouping params)) row
472 -- ^ zero or more expressions for the row field values
472 -- ^ zero or more expressions for the row field values
473− -> Expression schema from grouping params (nullity ('PGcomposite row))
473+ -> Expression db from grouping params (nullity ('PGcomposite row))
474row exprs = UnsafeExpression $ "ROW" <> parenthesized
474row exprs = UnsafeExpression $ "ROW" <> parenthesized
475 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
475 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
@@ -484,21 +484,22 @@ row exprs = UnsafeExpression $ "ROW" <> parenthesized
484-- >>> printSQL $ i & field #complex #imaginary
484-- >>> printSQL $ i & field #complex #imaginary
485-- (ROW(0, 1)::"complex")."imaginary"
485-- (ROW(0, 1)::"complex")."imaginary"
487− :: (Has tydef schema ('Typedef ('PGcomposite row)), Has field row ty)
487+ :: ( HasQualified sch tydef db schema ('Typedef ('PGcomposite row))
488− => Alias tydef -- ^ row type
489+ => QualifiedAlias sch tydef -- ^ row type
489 -> Alias field -- ^ field name
490 -> Alias field -- ^ field name
490− -> Expression schema from grouping params ('NotNull ('PGcomposite row))
491+ -> Expression db from grouping params ('NotNull ('PGcomposite row))
491− -> Expression schema from grouping params ty
492+ -> Expression db from grouping params ty
492field td fld expr = UnsafeExpression $
493field td fld expr = UnsafeExpression $
493− parenthesized (renderExpression expr <> "::" <> renderAlias td)
494+ parenthesized (renderExpression expr <> "::" <> renderQualifiedAlias td)
494 <> "." <> renderAlias fld
495 <> "." <> renderAlias fld
496instance Semigroup
497instance Semigroup
497− (Expression schema from grouping params (nullity ('PGvararray ty))) where
498+ (Expression db from grouping params (nullity ('PGvararray ty))) where
498 (<>) = unsafeBinaryOp "||"
499 (<>) = unsafeBinaryOp "||"
500instance Monoid
501instance Monoid
501− (Expression schema from grouping params (nullity ('PGvararray ty))) where
502+ (Expression db from grouping params (nullity ('PGvararray ty))) where
502 mempty = array []
503 mempty = array []
503 mappend = (<>)
504 mappend = (<>)
@@ -506,22 +507,22 @@ instance Monoid
506-- >>> printSQL expr
507-- >>> printSQL expr
507-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
508-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
509− :: Expression schema from grouping params (nullty)
510+ :: Expression db from grouping params (nullty)
510 -- ^ needs at least 1 argument
511 -- ^ needs at least 1 argument
511− -> [Expression schema from grouping params (nullty)]
512+ -> [Expression db from grouping params (nullty)]
512 -- ^ or more
513 -- ^ or more
513− -> Expression schema from grouping params (nullty)
514+ -> Expression db from grouping params (nullty)
514greatest x xs = UnsafeExpression $ "GREATEST("
515greatest x xs = UnsafeExpression $ "GREATEST("
515 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
516 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
517-- | >>> printSQL $ least currentTimestamp [null_]
518-- | >>> printSQL $ least currentTimestamp [null_]
518-- LEAST(CURRENT_TIMESTAMP, NULL)
519-- LEAST(CURRENT_TIMESTAMP, NULL)
520− :: Expression schema from grouping params (nullty)
521+ :: Expression db from grouping params (nullty)
521 -- ^ needs at least 1 argument
522 -- ^ needs at least 1 argument
522− -> [Expression schema from grouping params (nullty)]
523+ -> [Expression db from grouping params (nullty)]
523 -- ^ or more
524 -- ^ or more
524− -> Expression schema from grouping params (nullty)
525+ -> Expression db from grouping params (nullty)
525least x xs = UnsafeExpression $ "LEAST("
526least x xs = UnsafeExpression $ "LEAST("
526 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
527 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
@@ -530,9 +531,9 @@ least x xs = UnsafeExpression $ "LEAST("
530unsafeBinaryOp
531unsafeBinaryOp
531 :: ByteString
532 :: ByteString
532 -- ^ operator
533 -- ^ operator
533− -> Expression schema from grouping params (ty0)
534+ -> Expression db from grouping params (ty0)
534− -> Expression schema from grouping params (ty1)
535+ -> Expression db from grouping params (ty1)
535− -> Expression schema from grouping params (ty2)
536+ -> Expression db from grouping params (ty2)
536unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
537unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
537 renderExpression x <+> op <+> renderExpression y
538 renderExpression x <+> op <+> renderExpression y
@@ -541,8 +542,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541unsafeUnaryOp
542unsafeUnaryOp
542 :: ByteString
543 :: ByteString
543 -- ^ operator
544 -- ^ operator
544− -> Expression schema from grouping params (ty0)
545+ -> Expression db from grouping params (ty0)
545− -> Expression schema from grouping params (ty1)
546+ -> Expression db from grouping params (ty1)
546unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
547unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
547 op <+> renderExpression x
548 op <+> renderExpression x
@@ -551,8 +552,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551unsafeFunction
552unsafeFunction
552 :: ByteString
553 :: ByteString
553 -- ^ function
554 -- ^ function
554− -> Expression schema from grouping params (xty)
555+ -> Expression db from grouping params (xty)
555− -> Expression schema from grouping params (yty)
556+ -> Expression db from grouping params (yty)
556unsafeFunction fun x = UnsafeExpression $
557unsafeFunction fun x = UnsafeExpression $
557 fun <> parenthesized (renderExpression x)
558 fun <> parenthesized (renderExpression x)
@@ -561,13 +562,13 @@ unsafeVariadicFunction
561 :: SListI elems
562 :: SListI elems
562 => ByteString
563 => ByteString
563 -- ^ function
564 -- ^ function
564− -> NP (Expression schema from grouping params) elems
565+ -> NP (Expression db from grouping params) elems
565− -> Expression schema from grouping params ret
566+ -> Expression db from grouping params ret
566unsafeVariadicFunction fun x = UnsafeExpression $
567unsafeVariadicFunction fun x = UnsafeExpression $
567 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
568 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
569instance ty `In` PGNum
570instance ty `In` PGNum
570− => Num (Expression schema from grouping params (nullity ty)) where
571+ => Num (Expression db from grouping params (nullity ty)) where
571 (+) = unsafeBinaryOp "+"
572 (+) = unsafeBinaryOp "+"
572 (-) = unsafeBinaryOp "-"
573 (-) = unsafeBinaryOp "-"
573 (*) = unsafeBinaryOp "*"
574 (*) = unsafeBinaryOp "*"
@@ -579,12 +580,12 @@ instance ty `In` PGNum
581instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
582instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
582− (Expression schema from grouping params (nullity ty)) where
583+ (Expression db from grouping params (nullity ty)) where
583 (/) = unsafeBinaryOp "/"
584 (/) = unsafeBinaryOp "/"
584 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
585 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
586instance (ty `In` PGNum, ty `In` PGFloating) => Floating
587instance (ty `In` PGNum, ty `In` PGFloating) => Floating
587− (Expression schema from grouping params (nullity ty)) where
588+ (Expression db from grouping params (nullity ty)) where
588 pi = UnsafeExpression "pi()"
589 pi = UnsafeExpression "pi()"
589 exp = unsafeFunction "exp"
590 exp = unsafeFunction "exp"
590 log = unsafeFunction "ln"
591 log = unsafeFunction "ln"
@@ -607,18 +608,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
608-- | >>> :{
609-- | >>> :{
610−-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
611+-- expression :: Expression db from grouping params (nullity 'PGfloat4)
611-- expression = atan2_ pi 2
612-- expression = atan2_ pi 2
612-- in printSQL expression
613-- in printSQL expression
614-- atan2(pi(), 2)
615-- atan2(pi(), 2)
616 :: float `In` PGFloating
617 :: float `In` PGFloating
617− => Expression schema from grouping params (nullity float)
618+ => Expression db from grouping params (nullity float)
618 -- ^ numerator
619 -- ^ numerator
619− -> Expression schema from grouping params (nullity float)
620+ -> Expression db from grouping params (nullity float)
620 -- ^ denominator
621 -- ^ denominator
621− -> Expression schema from grouping params (nullity float)
622+ -> Expression db from grouping params (nullity float)
622atan2_ y x = UnsafeExpression $
623atan2_ y x = UnsafeExpression $
623 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
624 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
@@ -629,11 +630,11 @@ atan2_ y x = UnsafeExpression $
629-- | >>> printSQL $ true & cast int4
630-- | >>> printSQL $ true & cast int4
630-- (TRUE :: int4)
631-- (TRUE :: int4)
632− :: TypeExpression schema ty1
633+ :: TypeExpression db ty1
633 -- ^ type to cast as
634 -- ^ type to cast as
634− -> Expression schema from grouping params ty0
635+ -> Expression db from grouping params ty0
635 -- ^ value to convert
636 -- ^ value to convert
636− -> Expression schema from grouping params ty1
637+ -> Expression db from grouping params ty1
637cast ty x = UnsafeExpression $ parenthesized $
638cast ty x = UnsafeExpression $ parenthesized $
638 renderExpression x <+> "::" <+> renderTypeExpression ty
639 renderExpression x <+> "::" <+> renderTypeExpression ty
@@ -641,136 +642,136 @@ cast ty x = UnsafeExpression $ parenthesized $
644−-- expression :: Expression schema from grouping params (nullity 'PGint2)
645+-- expression :: Expression db from grouping params (nullity 'PGint2)
645-- expression = 5 `quot_` 2
646-- expression = 5 `quot_` 2
646-- in printSQL expression
647-- in printSQL expression
648-- (5 / 2)
649-- (5 / 2)
650 :: int `In` PGIntegral
651 :: int `In` PGIntegral
651− => Expression schema from grouping params (nullity int)
652+ => Expression db from grouping params (nullity int)
652 -- ^ numerator
653 -- ^ numerator
653− -> Expression schema from grouping params (nullity int)
654+ -> Expression db from grouping params (nullity int)
654 -- ^ denominator
655 -- ^ denominator
655− -> Expression schema from grouping params (nullity int)
656+ -> Expression db from grouping params (nullity int)
656quot_ = unsafeBinaryOp "/"
657quot_ = unsafeBinaryOp "/"
658-- | remainder upon integer division
659-- | remainder upon integer division
662−-- expression :: Expression schema from grouping params (nullity 'PGint2)
663+-- expression :: Expression db from grouping params (nullity 'PGint2)
663-- expression = 5 `rem_` 2
664-- expression = 5 `rem_` 2
664-- in printSQL expression
665-- in printSQL expression
666-- (5 % 2)
667-- (5 % 2)
668 :: int `In` PGIntegral
669 :: int `In` PGIntegral
669− => Expression schema from grouping params (nullity int)
670+ => Expression db from grouping params (nullity int)
670 -- ^ numerator
671 -- ^ numerator
671− -> Expression schema from grouping params (nullity int)
672+ -> Expression db from grouping params (nullity int)
672 -- ^ denominator
673 -- ^ denominator
673− -> Expression schema from grouping params (nullity int)
674+ -> Expression db from grouping params (nullity int)
674rem_ = unsafeBinaryOp "%"
675rem_ = unsafeBinaryOp "%"
676-- | >>> :{
677-- | >>> :{
678−-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
679+-- expression :: Expression db from grouping params (nullity 'PGfloat4)
679-- expression = trunc pi
680-- expression = trunc pi
680-- in printSQL expression
681-- in printSQL expression
682-- trunc(pi())
683-- trunc(pi())
684 :: frac `In` PGFloating
685 :: frac `In` PGFloating
685− => Expression schema from grouping params (nullity frac)
686+ => Expression db from grouping params (nullity frac)
686 -- ^ fractional number
687 -- ^ fractional number
687− -> Expression schema from grouping params (nullity frac)
688+ -> Expression db from grouping params (nullity frac)
688trunc = unsafeFunction "trunc"
689trunc = unsafeFunction "trunc"
690-- | >>> :{
691-- | >>> :{
692−-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
693+-- expression :: Expression db from grouping params (nullity 'PGfloat4)
693-- expression = round_ pi
694-- expression = round_ pi
694-- in printSQL expression
695-- in printSQL expression
696-- round(pi())
697-- round(pi())
698 :: frac `In` PGFloating
699 :: frac `In` PGFloating
699− => Expression schema from grouping params (nullity frac)
700+ => Expression db from grouping params (nullity frac)
700 -- ^ fractional number
701 -- ^ fractional number
701− -> Expression schema from grouping params (nullity frac)
702+ -> Expression db from grouping params (nullity frac)
702round_ = unsafeFunction "round"
703round_ = unsafeFunction "round"
704-- | >>> :{
705-- | >>> :{
706−-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
707+-- expression :: Expression db from grouping params (nullity 'PGfloat4)
707-- expression = ceiling_ pi
708-- expression = ceiling_ pi
708-- in printSQL expression
709-- in printSQL expression
710-- ceiling(pi())
711-- ceiling(pi())
712 :: frac `In` PGFloating
713 :: frac `In` PGFloating
713− => Expression schema from grouping params (nullity frac)
714+ => Expression db from grouping params (nullity frac)
714 -- ^ fractional number
715 -- ^ fractional number
715− -> Expression schema from grouping params (nullity frac)
716+ -> Expression db from grouping params (nullity frac)
716ceiling_ = unsafeFunction "ceiling"
717ceiling_ = unsafeFunction "ceiling"
718-- | A `Condition` is an `Expression`, which can evaluate
719-- | A `Condition` is an `Expression`, which can evaluate
719-- to `true`, `false` or `null_`. This is because SQL uses
720-- to `true`, `false` or `null_`. This is because SQL uses
720-- a three valued logic.
721-- a three valued logic.
721−type Condition schema from grouping params =
722+type Condition db from grouping params =
722− Expression schema from grouping params ('Null 'PGbool)
723+ Expression db from grouping params ('Null 'PGbool)
724-- | >>> printSQL true
725-- | >>> printSQL true
726−true :: Expression schema from grouping params (nullity 'PGbool)
727+true :: Expression db from grouping params (nullity 'PGbool)
727true = UnsafeExpression "TRUE"
728true = UnsafeExpression "TRUE"
729-- | >>> printSQL false
730-- | >>> printSQL false
731−false :: Expression schema from grouping params (nullity 'PGbool)
732+false :: Expression db from grouping params (nullity 'PGbool)
732false = UnsafeExpression "FALSE"
733false = UnsafeExpression "FALSE"
734-- | >>> printSQL $ not_ true
735-- | >>> printSQL $ not_ true
735-- (NOT TRUE)
736-- (NOT TRUE)
737− :: Expression schema from grouping params (nullity 'PGbool)
738+ :: Expression db from grouping params (nullity 'PGbool)
738− -> Expression schema from grouping params (nullity 'PGbool)
739+ -> Expression db from grouping params (nullity 'PGbool)
739not_ = unsafeUnaryOp "NOT"
740not_ = unsafeUnaryOp "NOT"
741-- | >>> printSQL $ true .&& false
742-- | >>> printSQL $ true .&& false
742-- (TRUE AND FALSE)
743-- (TRUE AND FALSE)
744− :: Expression schema from grouping params (nullity 'PGbool)
745+ :: Expression db from grouping params (nullity 'PGbool)
745− -> Expression schema from grouping params (nullity 'PGbool)
746+ -> Expression db from grouping params (nullity 'PGbool)
746− -> Expression schema from grouping params (nullity 'PGbool)
747+ -> Expression db from grouping params (nullity 'PGbool)
747infixr 3 .&&
748infixr 3 .&&
748(.&&) = unsafeBinaryOp "AND"
749(.&&) = unsafeBinaryOp "AND"
750-- | >>> printSQL $ true .|| false
751-- | >>> printSQL $ true .|| false
751-- (TRUE OR FALSE)
752-- (TRUE OR FALSE)
753− :: Expression schema from grouping params (nullity 'PGbool)
754+ :: Expression db from grouping params (nullity 'PGbool)
754− -> Expression schema from grouping params (nullity 'PGbool)
755+ -> Expression db from grouping params (nullity 'PGbool)
755− -> Expression schema from grouping params (nullity 'PGbool)
756+ -> Expression db from grouping params (nullity 'PGbool)
756infixr 2 .||
757infixr 2 .||
757(.||) = unsafeBinaryOp "OR"
758(.||) = unsafeBinaryOp "OR"
759-- | >>> :{
760-- | >>> :{
761−-- expression :: Expression schema from grouping params (nullity 'PGint2)
762+-- expression :: Expression db from grouping params (nullity 'PGint2)
762-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
763-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
763-- in printSQL expression
764-- in printSQL expression
765-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
766-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
766caseWhenThenElse
767caseWhenThenElse
767− :: [ ( Condition schema from grouping params
768+ :: [ ( Condition db from grouping params
768− , Expression schema from grouping params ty
769+ , Expression db from grouping params ty
770 -- ^ whens and thens
771 -- ^ whens and thens
771− -> Expression schema from grouping params ty
772+ -> Expression db from grouping params ty
772 -- ^ else
773 -- ^ else
773− -> Expression schema from grouping params ty
774+ -> Expression db from grouping params ty
774caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
775caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
776 , mconcat
777 , mconcat
@@ -786,16 +787,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
787-- | >>> :{
788-- | >>> :{
789−-- expression :: Expression schema from grouping params (nullity 'PGint2)
790+-- expression :: Expression db from grouping params (nullity 'PGint2)
790-- expression = ifThenElse true 1 0
791-- expression = ifThenElse true 1 0
791-- in printSQL expression
792-- in printSQL expression
793-- CASE WHEN TRUE THEN 1 ELSE 0 END
794-- CASE WHEN TRUE THEN 1 ELSE 0 END
794ifThenElse
795ifThenElse
795− :: Condition schema from grouping params
796+ :: Condition db from grouping params
796− -> Expression schema from grouping params ty -- ^ then
797+ -> Expression db from grouping params ty -- ^ then
797− -> Expression schema from grouping params ty -- ^ else
798+ -> Expression db from grouping params ty -- ^ else
798− -> Expression schema from grouping params ty
799+ -> Expression db from grouping params ty
799ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
800ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
801-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
802-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -804,85 +805,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
804-- >>> printSQL $ true .== null_
805-- >>> printSQL $ true .== null_
805-- (TRUE = NULL)
806-- (TRUE = NULL)
807− :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
808+ :: Expression db from grouping params (nullity0 ty) -- ^ lhs
808− -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
809+ -> Expression db from grouping params (nullity1 ty) -- ^ rhs
809− -> Condition schema from grouping params
810+ -> Condition db from grouping params
810(.==) = unsafeBinaryOp "="
811(.==) = unsafeBinaryOp "="
811infix 4 .==
812infix 4 .==
813-- | >>> printSQL $ true ./= null_
814-- | >>> printSQL $ true ./= null_
814-- (TRUE <> NULL)
815-- (TRUE <> NULL)
816− :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
817+ :: Expression db from grouping params (nullity0 ty) -- ^ lhs
817− -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
818+ -> Expression db from grouping params (nullity1 ty) -- ^ rhs
818− -> Condition schema from grouping params
819+ -> Condition db from grouping params
819(./=) = unsafeBinaryOp "<>"
820(./=) = unsafeBinaryOp "<>"
820infix 4 ./=
821infix 4 ./=
822-- | >>> printSQL $ true .>= null_
823-- | >>> printSQL $ true .>= null_
823-- (TRUE >= NULL)
824-- (TRUE >= NULL)
825− :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
826+ :: Expression db from grouping params (nullity0 ty) -- ^ lhs
826− -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
827+ -> Expression db from grouping params (nullity1 ty) -- ^ rhs
827− -> Condition schema from grouping params
828+ -> Condition db from grouping params
828(.>=) = unsafeBinaryOp ">="
829(.>=) = unsafeBinaryOp ">="
829infix 4 .>=
830infix 4 .>=
831-- | >>> printSQL $ true .< null_
832-- | >>> printSQL $ true .< null_
832-- (TRUE < NULL)
833-- (TRUE < NULL)
834− :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
835+ :: Expression db from grouping params (nullity0 ty) -- ^ lhs
835− -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
836+ -> Expression db from grouping params (nullity1 ty) -- ^ rhs
836− -> Condition schema from grouping params
837+ -> Condition db from grouping params
837(.<) = unsafeBinaryOp "<"
838(.<) = unsafeBinaryOp "<"
838infix 4 .<
839infix 4 .<
840-- | >>> printSQL $ true .<= null_
841-- | >>> printSQL $ true .<= null_
841-- (TRUE <= NULL)
842-- (TRUE <= NULL)
843− :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
844+ :: Expression db from grouping params (nullity0 ty) -- ^ lhs
844− -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
845+ -> Expression db from grouping params (nullity1 ty) -- ^ rhs
845− -> Condition schema from grouping params
846+ -> Condition db from grouping params
846(.<=) = unsafeBinaryOp "<="
847(.<=) = unsafeBinaryOp "<="
847infix 4 .<=
848infix 4 .<=
849-- | >>> printSQL $ true .> null_
850-- | >>> printSQL $ true .> null_
850-- (TRUE > NULL)
851-- (TRUE > NULL)
852− :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
853+ :: Expression db from grouping params (nullity0 ty) -- ^ lhs
853− -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
854+ -> Expression db from grouping params (nullity1 ty) -- ^ rhs
854− -> Condition schema from grouping params
855+ -> Condition db from grouping params
855(.>) = unsafeBinaryOp ">"
856(.>) = unsafeBinaryOp ">"
856infix 4 .>
857infix 4 .>
858-- | >>> printSQL currentDate
859-- | >>> printSQL currentDate
859-- CURRENT_DATE
860-- CURRENT_DATE
860currentDate
861currentDate
861− :: Expression schema from grouping params (nullity 'PGdate)
862+ :: Expression db from grouping params (nullity 'PGdate)
862currentDate = UnsafeExpression "CURRENT_DATE"
863currentDate = UnsafeExpression "CURRENT_DATE"
864-- | >>> printSQL currentTime
865-- | >>> printSQL currentTime
865-- CURRENT_TIME
866-- CURRENT_TIME
866currentTime
867currentTime
867− :: Expression schema from grouping params (nullity 'PGtimetz)
868+ :: Expression db from grouping params (nullity 'PGtimetz)
868currentTime = UnsafeExpression "CURRENT_TIME"
869currentTime = UnsafeExpression "CURRENT_TIME"
870-- | >>> printSQL currentTimestamp
871-- | >>> printSQL currentTimestamp
871-- CURRENT_TIMESTAMP
872-- CURRENT_TIMESTAMP
872currentTimestamp
873currentTimestamp
873− :: Expression schema from grouping params (nullity 'PGtimestamptz)
874+ :: Expression db from grouping params (nullity 'PGtimestamptz)
874currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
875currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
876-- | >>> printSQL localTime
877-- | >>> printSQL localTime
877-- LOCALTIME
878-- LOCALTIME
879− :: Expression schema from grouping params (nullity 'PGtime)
880+ :: Expression db from grouping params (nullity 'PGtime)
880localTime = UnsafeExpression "LOCALTIME"
881localTime = UnsafeExpression "LOCALTIME"
882-- | >>> printSQL localTimestamp
883-- | >>> printSQL localTimestamp
883-- LOCALTIMESTAMP
884-- LOCALTIMESTAMP
884localTimestamp
885localTimestamp
885− :: Expression schema from grouping params (nullity 'PGtimestamp)
886+ :: Expression db from grouping params (nullity 'PGtimestamp)
886localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
887localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
888{-----------------------------------------
889{-----------------------------------------
@@ -890,7 +891,7 @@ text
890-----------------------------------------}
891-----------------------------------------}
892instance IsString
893instance IsString
893− (Expression schema from grouping params (nullity 'PGtext)) where
894+ (Expression db from grouping params (nullity 'PGtext)) where
894 fromString str = UnsafeExpression $
895 fromString str = UnsafeExpression $
895 "E\'" <> fromString (escape =<< str) <> "\'"
896 "E\'" <> fromString (escape =<< str) <> "\'"
@@ -906,36 +907,36 @@ instance IsString
908instance Semigroup
909instance Semigroup
909− (Expression schema from grouping params (nullity 'PGtext)) where
910+ (Expression db from grouping params (nullity 'PGtext)) where
910 (<>) = unsafeBinaryOp "||"
911 (<>) = unsafeBinaryOp "||"
912instance Monoid
913instance Monoid
913− (Expression schema from grouping params (nullity 'PGtext)) where
914+ (Expression db from grouping params (nullity 'PGtext)) where
914 mempty = fromString ""
915 mempty = fromString ""
915 mappend = (<>)
916 mappend = (<>)
917-- | >>> printSQL $ lower "ARRRGGG"
918-- | >>> printSQL $ lower "ARRRGGG"
918-- lower(E'ARRRGGG')
919-- lower(E'ARRRGGG')
920− :: Expression schema from grouping params (nullity 'PGtext)
921+ :: Expression db from grouping params (nullity 'PGtext)
921 -- ^ string to lower case
922 -- ^ string to lower case
922− -> Expression schema from grouping params (nullity 'PGtext)
923+ -> Expression db from grouping params (nullity 'PGtext)
923lower = unsafeFunction "lower"
924lower = unsafeFunction "lower"
925-- | >>> printSQL $ upper "eeee"
926-- | >>> printSQL $ upper "eeee"
926-- upper(E'eeee')
927-- upper(E'eeee')
928− :: Expression schema from grouping params (nullity 'PGtext)
929+ :: Expression db from grouping params (nullity 'PGtext)
929 -- ^ string to upper case
930 -- ^ string to upper case
930− -> Expression schema from grouping params (nullity 'PGtext)
931+ -> Expression db from grouping params (nullity 'PGtext)
931upper = unsafeFunction "upper"
932upper = unsafeFunction "upper"
933-- | >>> printSQL $ charLength "four"
934-- | >>> printSQL $ charLength "four"
934-- char_length(E'four')
935-- char_length(E'four')
935charLength
936charLength
936− :: Expression schema from grouping params (nullity 'PGtext)
937+ :: Expression db from grouping params (nullity 'PGtext)
937 -- ^ string to measure
938 -- ^ string to measure
938− -> Expression schema from grouping params (nullity 'PGint4)
939+ -> Expression db from grouping params (nullity 'PGint4)
939charLength = unsafeFunction "char_length"
940charLength = unsafeFunction "char_length"
941-- | The `like` expression returns true if the @string@ matches
942-- | The `like` expression returns true if the @string@ matches
@@ -948,11 +949,11 @@ charLength = unsafeFunction "char_length"
948-- >>> printSQL $ "abc" `like` "a%"
949-- >>> printSQL $ "abc" `like` "a%"
949-- (E'abc' LIKE E'a%')
950-- (E'abc' LIKE E'a%')
951− :: Expression schema from grouping params (nullity 'PGtext)
952+ :: Expression db from grouping params (nullity 'PGtext)
952 -- ^ string
953 -- ^ string
953− -> Expression schema from grouping params (nullity 'PGtext)
954+ -> Expression db from grouping params (nullity 'PGtext)
954 -- ^ pattern
955 -- ^ pattern
955− -> Expression schema from grouping params (nullity 'PGbool)
956+ -> Expression db from grouping params (nullity 'PGbool)
956like = unsafeBinaryOp "LIKE"
957like = unsafeBinaryOp "LIKE"
958{-----------------------------------------
959{-----------------------------------------
@@ -967,36 +968,36 @@ Table 9.44: json and jsonb operators
967-- | Get JSON value (object field or array element) at a key.
968-- | Get JSON value (object field or array element) at a key.
969 :: (json `In` PGJsonType, key `In` PGJsonKey)
970 :: (json `In` PGJsonType, key `In` PGJsonKey)
970− => Expression schema from grouping params (nullity json)
971+ => Expression db from grouping params (nullity json)
971− -> Expression schema from grouping params (nullity key)
972+ -> Expression db from grouping params (nullity key)
972− -> Expression schema from grouping params ('Null json)
973+ -> Expression db from grouping params ('Null json)
973infixl 8 .->
974infixl 8 .->
974(.->) = unsafeBinaryOp "->"
975(.->) = unsafeBinaryOp "->"
976-- | Get JSON value (object field or array element) at a key, as text.
977-- | Get JSON value (object field or array element) at a key, as text.
978 :: (json `In` PGJsonType, key `In` PGJsonKey)
979 :: (json `In` PGJsonType, key `In` PGJsonKey)
979− => Expression schema from grouping params (nullity json)
980+ => Expression db from grouping params (nullity json)
980− -> Expression schema from grouping params (nullity key)
981+ -> Expression db from grouping params (nullity key)
981− -> Expression schema from grouping params ('Null 'PGtext)
982+ -> Expression db from grouping params ('Null 'PGtext)
982infixl 8 .->>
983infixl 8 .->>
983(.->>) = unsafeBinaryOp "->>"
984(.->>) = unsafeBinaryOp "->>"
985-- | Get JSON value at a specified path.
986-- | Get JSON value at a specified path.
987 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
988 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
988− => Expression schema from grouping params (nullity json)
989+ => Expression db from grouping params (nullity json)
989− -> Expression schema from grouping params (nullity path)
990+ -> Expression db from grouping params (nullity path)
990− -> Expression schema from grouping params ('Null json)
991+ -> Expression db from grouping params ('Null json)
991infixl 8 .#>
992infixl 8 .#>
992(.#>) = unsafeBinaryOp "#>"
993(.#>) = unsafeBinaryOp "#>"
994-- | Get JSON value at a specified path as text.
995-- | Get JSON value at a specified path as text.
996 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
997 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
997− => Expression schema from grouping params (nullity json)
998+ => Expression db from grouping params (nullity json)
998− -> Expression schema from grouping params (nullity path)
999+ -> Expression db from grouping params (nullity path)
999− -> Expression schema from grouping params ('Null 'PGtext)
1000+ -> Expression db from grouping params ('Null 'PGtext)
1000infixl 8 .#>>
1001infixl 8 .#>>
1001(.#>>) = unsafeBinaryOp "#>>"
1002(.#>>) = unsafeBinaryOp "#>>"
@@ -1005,48 +1006,48 @@ infixl 8 .#>>
1005-- | Does the left JSON value contain the right JSON path/value entries at the
1006-- | Does the left JSON value contain the right JSON path/value entries at the
1006-- top level?
1007-- top level?
1008− :: Expression schema from grouping params (nullity 'PGjsonb)
1009+ :: Expression db from grouping params (nullity 'PGjsonb)
1009− -> Expression schema from grouping params (nullity 'PGjsonb)
1010+ -> Expression db from grouping params (nullity 'PGjsonb)
1010− -> Condition schema from grouping params
1011+ -> Condition db from grouping params
1011infixl 9 .@>
1012infixl 9 .@>
1012(.@>) = unsafeBinaryOp "@>"
1013(.@>) = unsafeBinaryOp "@>"
1014-- | Are the left JSON path/value entries contained at the top level within the
1015-- | Are the left JSON path/value entries contained at the top level within the
1015-- right JSON value?
1016-- right JSON value?
1017− :: Expression schema from grouping params (nullity 'PGjsonb)
1018+ :: Expression db from grouping params (nullity 'PGjsonb)
1018− -> Expression schema from grouping params (nullity 'PGjsonb)
1019+ -> Expression db from grouping params (nullity 'PGjsonb)
1019− -> Condition schema from grouping params
1020+ -> Condition db from grouping params
1020infixl 9 .<@
1021infixl 9 .<@
1021(.<@) = unsafeBinaryOp "<@"
1022(.<@) = unsafeBinaryOp "<@"
1023-- | Does the string exist as a top-level key within the JSON value?
1024-- | Does the string exist as a top-level key within the JSON value?
1025− :: Expression schema from grouping params (nullity 'PGjsonb)
1026+ :: Expression db from grouping params (nullity 'PGjsonb)
1026− -> Expression schema from grouping params (nullity 'PGtext)
1027+ -> Expression db from grouping params (nullity 'PGtext)
1027− -> Condition schema from grouping params
1028+ -> Condition db from grouping params
1028infixl 9 .?
1029infixl 9 .?
1029(.?) = unsafeBinaryOp "?"
1030(.?) = unsafeBinaryOp "?"
1031-- | Do any of these array strings exist as top-level keys?
1032-- | Do any of these array strings exist as top-level keys?
1033− :: Expression schema from grouping params (nullity 'PGjsonb)
1034+ :: Expression db from grouping params (nullity 'PGjsonb)
1034− -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1035+ -> Expression db from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1035− -> Condition schema from grouping params
1036+ -> Condition db from grouping params
1036infixl 9 .?|
1037infixl 9 .?|
1037(.?|) = unsafeBinaryOp "?|"
1038(.?|) = unsafeBinaryOp "?|"
1039-- | Do all of these array strings exist as top-level keys?
1040-- | Do all of these array strings exist as top-level keys?
1041− :: Expression schema from grouping params (nullity 'PGjsonb)
1042+ :: Expression db from grouping params (nullity 'PGjsonb)
1042− -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1043+ -> Expression db from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1043− -> Condition schema from grouping params
1044+ -> Condition db from grouping params
1044infixl 9 .?&
1045infixl 9 .?&
1045(.?&) = unsafeBinaryOp "?&"
1046(.?&) = unsafeBinaryOp "?&"
1047-- | Concatenate two jsonb values into a new jsonb value.
1048-- | Concatenate two jsonb values into a new jsonb value.
1049− Semigroup (Expression schema from grouping param (nullity 'PGjsonb)) where
1050+ Semigroup (Expression db from grouping param (nullity 'PGjsonb)) where
1050 (<>) = unsafeBinaryOp "||"
1051 (<>) = unsafeBinaryOp "||"
1052-- | Delete a key or keys from a JSON object, or remove an array element.
1053-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1063,9 +1064,9 @@ instance
1063-- count from the end). Throws an error if top level container is not an array.
1064-- count from the end). Throws an error if top level container is not an array.
1065 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1066 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1066− => Expression schema from grouping params (nullity 'PGjsonb)
1067+ => Expression db from grouping params (nullity 'PGjsonb)
1067− -> Expression schema from grouping params (nullity key)
1068+ -> Expression db from grouping params (nullity key)
1068− -> Expression schema from grouping params (nullity 'PGjsonb)
1069+ -> Expression db from grouping params (nullity 'PGjsonb)
1069infixl 6 .-.
1070infixl 6 .-.
1070(.-.) = unsafeBinaryOp "-"
1071(.-.) = unsafeBinaryOp "-"
@@ -1073,9 +1074,9 @@ infixl 6 .-.
1073-- integers count from the end)
1074-- integers count from the end)
1075 :: PGTextArray "(#-.)" arrayty
1076 :: PGTextArray "(#-.)" arrayty
1076− => Expression schema from grouping params (nullity 'PGjsonb)
1077+ => Expression db from grouping params (nullity 'PGjsonb)
1077− -> Expression schema from grouping params (nullity arrayty)
1078+ -> Expression db from grouping params (nullity arrayty)
1078− -> Expression schema from grouping params (nullity 'PGjsonb)
1079+ -> Expression db from grouping params (nullity 'PGjsonb)
1079infixl 6 #-.
1080infixl 6 #-.
1080(#-.) = unsafeBinaryOp "#-"
1081(#-.) = unsafeBinaryOp "#-"
@@ -1086,14 +1087,14 @@ Table 9.45: JSON creation functions
1086-- | Literal binary JSON
1087-- | Literal binary JSON
1088 :: JSON.ToJSON x
1089 :: JSON.ToJSON x
1089− => x -> Expression schema from grouping params (nullity 'PGjsonb)
1090+ => x -> Expression db from grouping params (nullity 'PGjsonb)
1090jsonbLit = cast jsonb . UnsafeExpression
1091jsonbLit = cast jsonb . UnsafeExpression
1091 . singleQuotedUtf8 . toStrict . JSON.encode
1092 . singleQuotedUtf8 . toStrict . JSON.encode
1093-- | Literal JSON
1094-- | Literal JSON
1095 :: JSON.ToJSON x
1096 :: JSON.ToJSON x
1096− => x -> Expression schema from grouping params (nullity 'PGjson)
1097+ => x -> Expression db from grouping params (nullity 'PGjson)
1097jsonLit = cast json . UnsafeExpression
1098jsonLit = cast json . UnsafeExpression
1098 . singleQuotedUtf8 . toStrict . JSON.encode
1099 . singleQuotedUtf8 . toStrict . JSON.encode
@@ -1104,8 +1105,8 @@ jsonLit = cast json . UnsafeExpression
1104-- number, a Boolean, or a null value, the text representation will be used, in
1105-- number, a Boolean, or a null value, the text representation will be used, in
1105-- such a fashion that it is a valid json value.
1106-- such a fashion that it is a valid json value.
1107− :: Expression schema from grouping params (nullity ty)
1108+ :: Expression db from grouping params (nullity ty)
1108− -> Expression schema from grouping params (nullity 'PGjson)
1109+ -> Expression db from grouping params (nullity 'PGjson)
1109toJson = unsafeFunction "to_json"
1110toJson = unsafeFunction "to_json"
1111-- | Returns the value as jsonb. Arrays and composites are converted
1112-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1115,43 +1116,43 @@ toJson = unsafeFunction "to_json"
1115-- number, a Boolean, or a null value, the text representation will be used, in
1116-- number, a Boolean, or a null value, the text representation will be used, in
1116-- such a fashion that it is a valid jsonb value.
1117-- such a fashion that it is a valid jsonb value.
1118− :: Expression schema from grouping params (nullity ty)
1119+ :: Expression db from grouping params (nullity ty)
1119− -> Expression schema from grouping params (nullity 'PGjsonb)
1120+ -> Expression db from grouping params (nullity 'PGjsonb)
1120toJsonb = unsafeFunction "to_jsonb"
1121toJsonb = unsafeFunction "to_jsonb"
1122-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1123-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1123-- becomes a JSON array of arrays.
1124-- becomes a JSON array of arrays.
1124arrayToJson
1125arrayToJson
1125 :: PGArray "arrayToJson" arr
1126 :: PGArray "arrayToJson" arr
1126− => Expression schema from grouping params (nullity arr)
1127+ => Expression db from grouping params (nullity arr)
1127− -> Expression schema from grouping params (nullity 'PGjson)
1128+ -> Expression db from grouping params (nullity 'PGjson)
1128arrayToJson = unsafeFunction "array_to_json"
1129arrayToJson = unsafeFunction "array_to_json"
1130-- | Returns the row as a JSON object.
1131-- | Returns the row as a JSON object.
1131rowToJson
1132rowToJson
1132− :: Expression schema from grouping params (nullity ('PGcomposite ty))
1133+ :: Expression db from grouping params (nullity ('PGcomposite ty))
1133− -> Expression schema from grouping params (nullity 'PGjson)
1134+ -> Expression db from grouping params (nullity 'PGjson)
1134rowToJson = unsafeFunction "row_to_json"
1135rowToJson = unsafeFunction "row_to_json"
1136-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1137-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1137-- argument list.
1138-- argument list.
1138jsonBuildArray
1139jsonBuildArray
1139 :: SListI elems
1140 :: SListI elems
1140− => NP (Expression schema from grouping params) elems
1141+ => NP (Expression db from grouping params) elems
1141− -> Expression schema from grouping params (nullity 'PGjson)
1142+ -> Expression db from grouping params (nullity 'PGjson)
1142jsonBuildArray = unsafeVariadicFunction "json_build_array"
1143jsonBuildArray = unsafeVariadicFunction "json_build_array"
1144-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1145-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1145-- variadic argument list.
1146-- variadic argument list.
1146jsonbBuildArray
1147jsonbBuildArray
1147 :: SListI elems
1148 :: SListI elems
1148− => NP (Expression schema from grouping params) elems
1149+ => NP (Expression db from grouping params) elems
1149− -> Expression schema from grouping params (nullity 'PGjsonb)
1150+ -> Expression db from grouping params (nullity 'PGjsonb)
1150jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1151jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1152unsafeRowFunction
1153unsafeRowFunction
1153 :: All Top elems
1154 :: All Top elems
1154− => NP (Aliased (Expression schema from grouping params)) elems
1155+ => NP (Aliased (Expression db from grouping params)) elems
1155 -> [ByteString]
1156 -> [ByteString]
1156unsafeRowFunction =
1157unsafeRowFunction =
1157 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1158 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1163,8 +1164,8 @@ unsafeRowFunction =
1163-- and values.
1164-- and values.
1164jsonBuildObject
1165jsonBuildObject
1165 :: All Top elems
1166 :: All Top elems
1166− => NP (Aliased (Expression schema from grouping params)) elems
1167+ => NP (Aliased (Expression db from grouping params)) elems
1167− -> Expression schema from grouping params (nullity 'PGjson)
1168+ -> Expression db from grouping params (nullity 'PGjson)
1168jsonBuildObject
1169jsonBuildObject
1169 = unsafeFunction "json_build_object"
1170 = unsafeFunction "json_build_object"
1170 . UnsafeExpression
1171 . UnsafeExpression
@@ -1176,8 +1177,8 @@ jsonBuildObject
1176-- between text and values.
1177-- between text and values.
1177jsonbBuildObject
1178jsonbBuildObject
1178 :: All Top elems
1179 :: All Top elems
1179− => NP (Aliased (Expression schema from grouping params)) elems
1180+ => NP (Aliased (Expression db from grouping params)) elems
1180− -> Expression schema from grouping params (nullity 'PGjsonb)
1181+ -> Expression db from grouping params (nullity 'PGjsonb)
1181jsonbBuildObject
1182jsonbBuildObject
1182 = unsafeFunction "jsonb_build_object"
1183 = unsafeFunction "jsonb_build_object"
1183 . UnsafeExpression
1184 . UnsafeExpression
@@ -1190,8 +1191,8 @@ jsonbBuildObject
1190-- array has exactly two elements, which are taken as a key/value pair.
1191-- array has exactly two elements, which are taken as a key/value pair.
1191jsonObject
1192jsonObject
1192 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1193 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1193− => Expression schema from grouping params (nullity arr)
1194+ => Expression db from grouping params (nullity arr)
1194− -> Expression schema from grouping params (nullity 'PGjson)
1195+ -> Expression db from grouping params (nullity 'PGjson)
1195jsonObject = unsafeFunction "json_object"
1196jsonObject = unsafeFunction "json_object"
1197-- | Builds a binary JSON object out of a text array. The array must have either
1198-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1200,8 +1201,8 @@ jsonObject = unsafeFunction "json_object"
1200-- array has exactly two elements, which are taken as a key/value pair.
1201-- array has exactly two elements, which are taken as a key/value pair.
1201jsonbObject
1202jsonbObject
1202 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1203 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1203− => Expression schema from grouping params (nullity arr)
1204+ => Expression db from grouping params (nullity arr)
1204− -> Expression schema from grouping params (nullity 'PGjsonb)
1205+ -> Expression db from grouping params (nullity 'PGjsonb)
1205jsonbObject = unsafeFunction "jsonb_object"
1206jsonbObject = unsafeFunction "jsonb_object"
1207-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1208-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1209,9 +1210,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1209jsonZipObject
1210jsonZipObject
1210 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1211 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1211 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1212 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1212− => Expression schema from grouping params (nullity keysArray)
1213+ => Expression db from grouping params (nullity keysArray)
1213− -> Expression schema from grouping params (nullity valuesArray)
1214+ -> Expression db from grouping params (nullity valuesArray)
1214− -> Expression schema from grouping params (nullity 'PGjson)
1215+ -> Expression db from grouping params (nullity 'PGjson)
1215jsonZipObject ks vs =
1216jsonZipObject ks vs =
1216 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1217 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
@@ -1221,9 +1222,9 @@ jsonZipObject ks vs =
1221jsonbZipObject
1222jsonbZipObject
1222 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1223 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1223 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1224 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1224− => Expression schema from grouping params (nullity keysArray)
1225+ => Expression db from grouping params (nullity keysArray)
1225− -> Expression schema from grouping params (nullity valuesArray)
1226+ -> Expression db from grouping params (nullity valuesArray)
1226− -> Expression schema from grouping params (nullity 'PGjsonb)
1227+ -> Expression db from grouping params (nullity 'PGjsonb)
1227jsonbZipObject ks vs =
1228jsonbZipObject ks vs =
1228 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1229 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
@@ -1233,23 +1234,23 @@ Table 9.46: JSON processing functions
1234-- | Returns the number of elements in the outermost JSON array.
1235-- | Returns the number of elements in the outermost JSON array.
1235jsonArrayLength
1236jsonArrayLength
1236− :: Expression schema from grouping params (nullity 'PGjson)
1237+ :: Expression db from grouping params (nullity 'PGjson)
1237− -> Expression schema from grouping params (nullity 'PGint4)
1238+ -> Expression db from grouping params (nullity 'PGint4)
1238jsonArrayLength = unsafeFunction "json_array_length"
1239jsonArrayLength = unsafeFunction "json_array_length"
1240-- | Returns the number of elements in the outermost binary JSON array.
1241-- | Returns the number of elements in the outermost binary JSON array.
1241jsonbArrayLength
1242jsonbArrayLength
1242− :: Expression schema from grouping params (nullity 'PGjsonb)
1243+ :: Expression db from grouping params (nullity 'PGjsonb)
1243− -> Expression schema from grouping params (nullity 'PGint4)
1244+ -> Expression db from grouping params (nullity 'PGint4)
1244jsonbArrayLength = unsafeFunction "jsonb_array_length"
1245jsonbArrayLength = unsafeFunction "jsonb_array_length"
1246-- | Returns JSON value pointed to by the given path (equivalent to #>
1247-- | Returns JSON value pointed to by the given path (equivalent to #>
1247-- operator).
1248-- operator).
1248jsonExtractPath
1249jsonExtractPath
1249 :: SListI elems
1250 :: SListI elems
1250− => Expression schema from grouping params (nullity 'PGjson)
1251+ => Expression db from grouping params (nullity 'PGjson)
1251− -> NP (Expression schema from grouping params) elems
1252+ -> NP (Expression db from grouping params) elems
1252− -> Expression schema from grouping params (nullity 'PGjsonb)
1253+ -> Expression db from grouping params (nullity 'PGjsonb)
1253jsonExtractPath x xs =
1254jsonExtractPath x xs =
1254 unsafeVariadicFunction "json_extract_path" (x :* xs)
1255 unsafeVariadicFunction "json_extract_path" (x :* xs)
@@ -1257,9 +1258,9 @@ jsonExtractPath x xs =
1257-- operator).
1258-- operator).
1258jsonbExtractPath
1259jsonbExtractPath
1259 :: SListI elems
1260 :: SListI elems
1260− => Expression schema from grouping params (nullity 'PGjsonb)
1261+ => Expression db from grouping params (nullity 'PGjsonb)
1261− -> NP (Expression schema from grouping params) elems
1262+ -> NP (Expression db from grouping params) elems
1262− -> Expression schema from grouping params (nullity 'PGjsonb)
1263+ -> Expression db from grouping params (nullity 'PGjsonb)
1263jsonbExtractPath x xs =
1264jsonbExtractPath x xs =
1264 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1265 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
@@ -1267,9 +1268,9 @@ jsonbExtractPath x xs =
1267-- operator), as text.
1268-- operator), as text.
1268jsonExtractPathAsText
1269jsonExtractPathAsText
1269 :: SListI elems
1270 :: SListI elems
1270− => Expression schema from grouping params (nullity 'PGjson)
1271+ => Expression db from grouping params (nullity 'PGjson)
1271− -> NP (Expression schema from grouping params) elems
1272+ -> NP (Expression db from grouping params) elems
1272− -> Expression schema from grouping params (nullity 'PGjson)
1273+ -> Expression db from grouping params (nullity 'PGjson)
1273jsonExtractPathAsText x xs =
1274jsonExtractPathAsText x xs =
1274 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1275 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
@@ -1277,38 +1278,38 @@ jsonExtractPathAsText x xs =
1277-- operator), as text.
1278-- operator), as text.
1278jsonbExtractPathAsText
1279jsonbExtractPathAsText
1279 :: SListI elems
1280 :: SListI elems
1280− => Expression schema from grouping params (nullity 'PGjsonb)
1281+ => Expression db from grouping params (nullity 'PGjsonb)
1281− -> NP (Expression schema from grouping params) elems
1282+ -> NP (Expression db from grouping params) elems
1282− -> Expression schema from grouping params (nullity 'PGjsonb)
1283+ -> Expression db from grouping params (nullity 'PGjsonb)
1283jsonbExtractPathAsText x xs =
1284jsonbExtractPathAsText x xs =
1284 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1285 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1286-- | Returns the type of the outermost JSON value as a text string. Possible
1287-- | Returns the type of the outermost JSON value as a text string. Possible
1287-- types are object, array, string, number, boolean, and null.
1288-- types are object, array, string, number, boolean, and null.
1288jsonTypeof
1289jsonTypeof
1289− :: Expression schema from grouping params (nullity 'PGjson)
1290+ :: Expression db from grouping params (nullity 'PGjson)
1290− -> Expression schema from grouping params (nullity 'PGtext)
1291+ -> Expression db from grouping params (nullity 'PGtext)
1291jsonTypeof = unsafeFunction "json_typeof"
1292jsonTypeof = unsafeFunction "json_typeof"
1293-- | Returns the type of the outermost binary JSON value as a text string.
1294-- | Returns the type of the outermost binary JSON value as a text string.
1294-- Possible types are object, array, string, number, boolean, and null.
1295-- Possible types are object, array, string, number, boolean, and null.
1295jsonbTypeof
1296jsonbTypeof
1296− :: Expression schema from grouping params (nullity 'PGjsonb)
1297+ :: Expression db from grouping params (nullity 'PGjsonb)
1297− -> Expression schema from grouping params (nullity 'PGtext)
1298+ -> Expression db from grouping params (nullity 'PGtext)
1298jsonbTypeof = unsafeFunction "jsonb_typeof"
1299jsonbTypeof = unsafeFunction "jsonb_typeof"
1300-- | Returns its argument with all object fields that have null values omitted.
1301-- | Returns its argument with all object fields that have null values omitted.
1301-- Other null values are untouched.
1302-- Other null values are untouched.
1302jsonStripNulls
1303jsonStripNulls
1303− :: Expression schema from grouping params (nullity 'PGjson)
1304+ :: Expression db from grouping params (nullity 'PGjson)
1304− -> Expression schema from grouping params (nullity 'PGjson)
1305+ -> Expression db from grouping params (nullity 'PGjson)
1305jsonStripNulls = unsafeFunction "json_strip_nulls"
1306jsonStripNulls = unsafeFunction "json_strip_nulls"
1307-- | Returns its argument with all object fields that have null values omitted.
1308-- | Returns its argument with all object fields that have null values omitted.
1308-- Other null values are untouched.
1309-- Other null values are untouched.
1309jsonbStripNulls
1310jsonbStripNulls
1310− :: Expression schema from grouping params (nullity 'PGjsonb)
1311+ :: Expression db from grouping params (nullity 'PGjsonb)
1311− -> Expression schema from grouping params (nullity 'PGjsonb)
1312+ -> Expression db from grouping params (nullity 'PGjsonb)
1312jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1313jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1314-- | @ jsonbSet target path new_value create_missing @
1315-- | @ jsonbSet target path new_value create_missing @
@@ -1320,11 +1321,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1320-- arrays.
1321-- arrays.
1322 :: PGTextArray "jsonbSet" arr
1323 :: PGTextArray "jsonbSet" arr
1323− => Expression schema from grouping params (nullity 'PGjsonb)
1324+ => Expression db from grouping params (nullity 'PGjsonb)
1324− -> Expression schema from grouping params (nullity arr)
1325+ -> Expression db from grouping params (nullity arr)
1325− -> Expression schema from grouping params (nullity 'PGjsonb)
1326+ -> Expression db from grouping params (nullity 'PGjsonb)
1326− -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1327+ -> Maybe (Expression db from grouping params (nullity 'PGbool))
1327− -> Expression schema from grouping params (nullity 'PGjsonb)
1328+ -> Expression db from grouping params (nullity 'PGjsonb)
1328jsonbSet tgt path val createMissing = case createMissing of
1329jsonbSet tgt path val createMissing = case createMissing of
1329 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1330 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1330 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1331 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1339,19 +1340,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1339-- in path count from the end of JSON arrays.
1340-- in path count from the end of JSON arrays.
1340jsonbInsert
1341jsonbInsert
1341 :: PGTextArray "jsonbInsert" arr
1342 :: PGTextArray "jsonbInsert" arr
1342− => Expression schema from grouping params (nullity 'PGjsonb)
1343+ => Expression db from grouping params (nullity 'PGjsonb)
1343− -> Expression schema from grouping params (nullity arr)
1344+ -> Expression db from grouping params (nullity arr)
1344− -> Expression schema from grouping params (nullity 'PGjsonb)
1345+ -> Expression db from grouping params (nullity 'PGjsonb)
1345− -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1346+ -> Maybe (Expression db from grouping params (nullity 'PGbool))
1346− -> Expression schema from grouping params (nullity 'PGjsonb)
1347+ -> Expression db from grouping params (nullity 'PGjsonb)
1347jsonbInsert tgt path val insertAfter = case insertAfter of
1348jsonbInsert tgt path val insertAfter = case insertAfter of
1348 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1349 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1349 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1350 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1351-- | Returns its argument as indented JSON text.
1352-- | Returns its argument as indented JSON text.
1352jsonbPretty
1353jsonbPretty
1353− :: Expression schema from grouping params (nullity 'PGjsonb)
1354+ :: Expression db from grouping params (nullity 'PGjsonb)
1354− -> Expression schema from grouping params (nullity 'PGtext)
1355+ -> Expression db from grouping params (nullity 'PGtext)
1355jsonbPretty = unsafeFunction "jsonb_pretty"
1356jsonbPretty = unsafeFunction "jsonb_pretty"
1357{-----------------------------------------
1358{-----------------------------------------
@@ -1361,54 +1362,54 @@ aggregation
1361-- | escape hatch to define aggregate functions
1362-- | escape hatch to define aggregate functions
1362unsafeAggregate
1363unsafeAggregate
1363 :: ByteString -- ^ aggregate function
1364 :: ByteString -- ^ aggregate function
1364− -> Expression schema from 'Ungrouped params (xty)
1365+ -> Expression db from 'Ungrouped params (xty)
1365− -> Expression schema from ('Grouped bys) params (yty)
1366+ -> Expression db from ('Grouped bys) params (yty)
1366unsafeAggregate fun x = UnsafeExpression $ mconcat
1367unsafeAggregate fun x = UnsafeExpression $ mconcat
1367 [fun, "(", renderExpression x, ")"]
1368 [fun, "(", renderExpression x, ")"]
1369-- | escape hatch to define aggregate functions over distinct values
1370-- | escape hatch to define aggregate functions over distinct values
1370unsafeAggregateDistinct
1371unsafeAggregateDistinct
1371 :: ByteString -- ^ aggregate function
1372 :: ByteString -- ^ aggregate function
1372− -> Expression schema from 'Ungrouped params (xty)
1373+ -> Expression db from 'Ungrouped params (xty)
1373− -> Expression schema from ('Grouped bys) params (yty)
1374+ -> Expression db from ('Grouped bys) params (yty)
1374unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1375unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1375 [fun, "(DISTINCT ", renderExpression x, ")"]
1376 [fun, "(DISTINCT ", renderExpression x, ")"]
1377-- | >>> :{
1378-- | >>> :{
1379−-- expression :: Expression schema '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Grouped bys) params ('Null 'PGnumeric)
1380+-- expression :: Expression db '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Grouped bys) params ('Null 'PGnumeric)
1380-- expression = sum_ #col
1381-- expression = sum_ #col
1381-- in printSQL expression
1382-- in printSQL expression
1383-- sum("col")
1384-- sum("col")
1385 :: ty `In` PGNum
1386 :: ty `In` PGNum
1386− => Expression schema from 'Ungrouped params (nullity ty)
1387+ => Expression db from 'Ungrouped params (nullity ty)
1387 -- ^ what to sum
1388 -- ^ what to sum
1388− -> Expression schema from ('Grouped bys) params (nullity ty)
1389+ -> Expression db from ('Grouped bys) params (nullity ty)
1389sum_ = unsafeAggregate "sum"
1390sum_ = unsafeAggregate "sum"
1391-- | >>> :{
1392-- | >>> :{
1393−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGnumeric]] ('Grouped bys) params (nullity 'PGnumeric)
1394+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGnumeric]] ('Grouped bys) params (nullity 'PGnumeric)
1394-- expression = sumDistinct #col
1395-- expression = sumDistinct #col
1395-- in printSQL expression
1396-- in printSQL expression
1397-- sum(DISTINCT "col")
1398-- sum(DISTINCT "col")
1398sumDistinct
1399sumDistinct
1399 :: ty `In` PGNum
1400 :: ty `In` PGNum
1400− => Expression schema from 'Ungrouped params (nullity ty)
1401+ => Expression db from 'Ungrouped params (nullity ty)
1401 -- ^ what to sum
1402 -- ^ what to sum
1402− -> Expression schema from ('Grouped bys) params (nullity ty)
1403+ -> Expression db from ('Grouped bys) params (nullity ty)
1403sumDistinct = unsafeAggregateDistinct "sum"
1404sumDistinct = unsafeAggregateDistinct "sum"
1405-- | A constraint for `PGType`s that you can take averages of and the resulting
1406-- | A constraint for `PGType`s that you can take averages of and the resulting
1406-- `PGType`.
1407-- `PGType`.
1407class PGAvg ty avg | ty -> avg where
1408class PGAvg ty avg | ty -> avg where
1408 avg, avgDistinct
1409 avg, avgDistinct
1409− :: Expression schema from 'Ungrouped params (nullity ty)
1410+ :: Expression db from 'Ungrouped params (nullity ty)
1410 -- ^ what to average
1411 -- ^ what to average
1411− -> Expression schema from ('Grouped bys) params (nullity avg)
1412+ -> Expression db from ('Grouped bys) params (nullity avg)
1412 avg = unsafeAggregate "avg"
1413 avg = unsafeAggregate "avg"
1413 avgDistinct = unsafeAggregateDistinct "avg"
1414 avgDistinct = unsafeAggregateDistinct "avg"
1414instance PGAvg 'PGint2 'PGnumeric
1415instance PGAvg 'PGint2 'PGnumeric
@@ -1421,110 +1422,110 @@ instance PGAvg 'PGinterval 'PGinterval
1422-- | >>> :{
1423-- | >>> :{
1424−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1425+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1425-- expression = bitAnd #col
1426-- expression = bitAnd #col
1426-- in printSQL expression
1427-- in printSQL expression
1428-- bit_and("col")
1429-- bit_and("col")
1430 :: int `In` PGIntegral
1431 :: int `In` PGIntegral
1431− => Expression schema from 'Ungrouped params (nullity int)
1432+ => Expression db from 'Ungrouped params (nullity int)
1432 -- ^ what to aggregate
1433 -- ^ what to aggregate
1433− -> Expression schema from ('Grouped bys) params (nullity int)
1434+ -> Expression db from ('Grouped bys) params (nullity int)
1434bitAnd = unsafeAggregate "bit_and"
1435bitAnd = unsafeAggregate "bit_and"
1436-- | >>> :{
1437-- | >>> :{
1438−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1439+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1439-- expression = bitOr #col
1440-- expression = bitOr #col
1440-- in printSQL expression
1441-- in printSQL expression
1442-- bit_or("col")
1443-- bit_or("col")
1444 :: int `In` PGIntegral
1445 :: int `In` PGIntegral
1445− => Expression schema from 'Ungrouped params (nullity int)
1446+ => Expression db from 'Ungrouped params (nullity int)
1446 -- ^ what to aggregate
1447 -- ^ what to aggregate
1447− -> Expression schema from ('Grouped bys) params (nullity int)
1448+ -> Expression db from ('Grouped bys) params (nullity int)
1448bitOr = unsafeAggregate "bit_or"
1449bitOr = unsafeAggregate "bit_or"
1450-- | >>> :{
1451-- | >>> :{
1452−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1453+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1453-- expression = bitAndDistinct #col
1454-- expression = bitAndDistinct #col
1454-- in printSQL expression
1455-- in printSQL expression
1456-- bit_and(DISTINCT "col")
1457-- bit_and(DISTINCT "col")
1457bitAndDistinct
1458bitAndDistinct
1458 :: int `In` PGIntegral
1459 :: int `In` PGIntegral
1459− => Expression schema from 'Ungrouped params (nullity int)
1460+ => Expression db from 'Ungrouped params (nullity int)
1460 -- ^ what to aggregate
1461 -- ^ what to aggregate
1461− -> Expression schema from ('Grouped bys) params (nullity int)
1462+ -> Expression db from ('Grouped bys) params (nullity int)
1462bitAndDistinct = unsafeAggregateDistinct "bit_and"
1463bitAndDistinct = unsafeAggregateDistinct "bit_and"
1464-- | >>> :{
1465-- | >>> :{
1466−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1467+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
1467-- expression = bitOrDistinct #col
1468-- expression = bitOrDistinct #col
1468-- in printSQL expression
1469-- in printSQL expression
1470-- bit_or(DISTINCT "col")
1471-- bit_or(DISTINCT "col")
1471bitOrDistinct
1472bitOrDistinct
1472 :: int `In` PGIntegral
1473 :: int `In` PGIntegral
1473− => Expression schema from 'Ungrouped params (nullity int)
1474+ => Expression db from 'Ungrouped params (nullity int)
1474 -- ^ what to aggregate
1475 -- ^ what to aggregate
1475− -> Expression schema from ('Grouped bys) params (nullity int)
1476+ -> Expression db from ('Grouped bys) params (nullity int)
1476bitOrDistinct = unsafeAggregateDistinct "bit_or"
1477bitOrDistinct = unsafeAggregateDistinct "bit_or"
1478-- | >>> :{
1479-- | >>> :{
1480−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1481+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1481-- expression = boolAnd #col
1482-- expression = boolAnd #col
1482-- in printSQL expression
1483-- in printSQL expression
1484-- bool_and("col")
1485-- bool_and("col")
1486− :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1487+ :: Expression db from 'Ungrouped params (nullity 'PGbool)
1487 -- ^ what to aggregate
1488 -- ^ what to aggregate
1488− -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1489+ -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1489boolAnd = unsafeAggregate "bool_and"
1490boolAnd = unsafeAggregate "bool_and"
1491-- | >>> :{
1492-- | >>> :{
1493−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1494+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1494-- expression = boolOr #col
1495-- expression = boolOr #col
1495-- in printSQL expression
1496-- in printSQL expression
1497-- bool_or("col")
1498-- bool_or("col")
1499− :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1500+ :: Expression db from 'Ungrouped params (nullity 'PGbool)
1500 -- ^ what to aggregate
1501 -- ^ what to aggregate
1501− -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1502+ -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1502boolOr = unsafeAggregate "bool_or"
1503boolOr = unsafeAggregate "bool_or"
1504-- | >>> :{
1505-- | >>> :{
1506−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1507+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1507-- expression = boolAndDistinct #col
1508-- expression = boolAndDistinct #col
1508-- in printSQL expression
1509-- in printSQL expression
1510-- bool_and(DISTINCT "col")
1511-- bool_and(DISTINCT "col")
1511boolAndDistinct
1512boolAndDistinct
1512− :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1513+ :: Expression db from 'Ungrouped params (nullity 'PGbool)
1513 -- ^ what to aggregate
1514 -- ^ what to aggregate
1514− -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1515+ -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1515boolAndDistinct = unsafeAggregateDistinct "bool_and"
1516boolAndDistinct = unsafeAggregateDistinct "bool_and"
1517-- | >>> :{
1518-- | >>> :{
1519−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1520+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1520-- expression = boolOrDistinct #col
1521-- expression = boolOrDistinct #col
1521-- in printSQL expression
1522-- in printSQL expression
1523-- bool_or(DISTINCT "col")
1524-- bool_or(DISTINCT "col")
1524boolOrDistinct
1525boolOrDistinct
1525− :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1526+ :: Expression db from 'Ungrouped params (nullity 'PGbool)
1526 -- ^ what to aggregate
1527 -- ^ what to aggregate
1527− -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1528+ -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1528boolOrDistinct = unsafeAggregateDistinct "bool_or"
1529boolOrDistinct = unsafeAggregateDistinct "bool_or"
1530-- | A special aggregation that does not require an input
1531-- | A special aggregation that does not require an input
@@ -1532,70 +1533,70 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1532-- >>> printSQL countStar
1533-- >>> printSQL countStar
1533-- count(*)
1534-- count(*)
1534countStar
1535countStar
1535− :: Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1536+ :: Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1536countStar = UnsafeExpression $ "count(*)"
1537countStar = UnsafeExpression $ "count(*)"
1538-- | >>> :{
1539-- | >>> :{
1540−-- expression :: Expression schema '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1541+-- expression :: Expression db '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1541-- expression = count #col
1542-- expression = count #col
1542-- in printSQL expression
1543-- in printSQL expression
1544-- count("col")
1545-- count("col")
1546− :: Expression schema from 'Ungrouped params ty
1547+ :: Expression db from 'Ungrouped params ty
1547 -- ^ what to count
1548 -- ^ what to count
1548− -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1549+ -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1549count = unsafeAggregate "count"
1550count = unsafeAggregate "count"
1551-- | >>> :{
1552-- | >>> :{
1553−-- expression :: Expression schema '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1554+-- expression :: Expression db '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1554-- expression = countDistinct #col
1555-- expression = countDistinct #col
1555-- in printSQL expression
1556-- in printSQL expression
1557-- count(DISTINCT "col")
1558-- count(DISTINCT "col")
1558countDistinct
1559countDistinct
1559− :: Expression schema from 'Ungrouped params ty
1560+ :: Expression db from 'Ungrouped params ty
1560 -- ^ what to count
1561 -- ^ what to count
1561− -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1562+ -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1562countDistinct = unsafeAggregateDistinct "count"
1563countDistinct = unsafeAggregateDistinct "count"
1564-- | synonym for `boolAnd`
1565-- | synonym for `boolAnd`
1566-- >>> :{
1567-- >>> :{
1568−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1569+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1569-- expression = every #col
1570-- expression = every #col
1570-- in printSQL expression
1571-- in printSQL expression
1572-- every("col")
1573-- every("col")
1574− :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1575+ :: Expression db from 'Ungrouped params (nullity 'PGbool)
1575 -- ^ what to aggregate
1576 -- ^ what to aggregate
1576− -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1577+ -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1577every = unsafeAggregate "every"
1578every = unsafeAggregate "every"
1579-- | synonym for `boolAndDistinct`
1580-- | synonym for `boolAndDistinct`
1581-- >>> :{
1582-- >>> :{
1583−-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1584+-- expression :: Expression db '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1584-- expression = everyDistinct #col
1585-- expression = everyDistinct #col
1585-- in printSQL expression
1586-- in printSQL expression
1587-- every(DISTINCT "col")
1588-- every(DISTINCT "col")
1588everyDistinct
1589everyDistinct
1589− :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1590+ :: Expression db from 'Ungrouped params (nullity 'PGbool)
1590 -- ^ what to aggregate
1591 -- ^ what to aggregate
1591− -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1592+ -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1592everyDistinct = unsafeAggregateDistinct "every"
1593everyDistinct = unsafeAggregateDistinct "every"
1594-- | minimum and maximum aggregation
1595-- | minimum and maximum aggregation
1595max_, min_, maxDistinct, minDistinct
1596max_, min_, maxDistinct, minDistinct
1596− :: Expression schema from 'Ungrouped params (nullity ty)
1597+ :: Expression db from 'Ungrouped params (nullity ty)
1597 -- ^ what to aggregate
1598 -- ^ what to aggregate
1598− -> Expression schema from ('Grouped bys) params (nullity ty)
1599+ -> Expression db from ('Grouped bys) params (nullity ty)
1599max_ = unsafeAggregate "max"
1600max_ = unsafeAggregate "max"
1600min_ = unsafeAggregate "min"
1601min_ = unsafeAggregate "min"
1601maxDistinct = unsafeAggregateDistinct "max"
1602maxDistinct = unsafeAggregateDistinct "max"
@@ -1606,153 +1607,153 @@ type expressions
1606-----------------------------------------}
1607-----------------------------------------}
1608-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1609-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1609−newtype TypeExpression (schema :: SchemaType) (ty :: NullityType)
1610+newtype TypeExpression (db :: DBType) (ty :: NullityType)
1610 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1611 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1611 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1612 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1613-- | The enum or composite type in a `Typedef` can be expressed by its alias.
1614-- | The enum or composite type in a `Typedef` can be expressed by its alias.
1615− :: Has alias schema ('Typedef ty)
1616+ :: HasQualified sch td db schema ('Typedef ty)
1616− => Alias alias
1617+ => QualifiedAlias sch td
1617− -> TypeExpression schema (nullity ty)
1618+ -> TypeExpression db (nullity ty)
1618−typedef = UnsafeTypeExpression . renderAlias
1619+typedef = UnsafeTypeExpression . renderQualifiedAlias
1620-- | The composite type corresponding to a `Table` definition can be expressed
1621-- | The composite type corresponding to a `Table` definition can be expressed
1621-- by its alias.
1622-- by its alias.
1622typetable
1623typetable
1623− :: Has alias schema ('Table tab)
1624+ :: HasQualified sch tab db schema ('Table table)
1624− => Alias alias
1625+ => QualifiedAlias sch tab
1625− -> TypeExpression schema (nullity ('PGcomposite (TableToRow tab)))
1626+ -> TypeExpression db (nullity ('PGcomposite (TableToRow table)))
1626−typetable = UnsafeTypeExpression . renderAlias
1627+typetable = UnsafeTypeExpression . renderQualifiedAlias
1628-- | The composite type corresponding to a `View` definition can be expressed
1629-- | The composite type corresponding to a `View` definition can be expressed
1629-- by its alias.
1630-- by its alias.
1631− :: Has alias schema ('View view)
1632+ :: HasQualified sch vw db schema ('View view)
1632− => Alias alias
1633+ => QualifiedAlias sch vw
1633− -> TypeExpression schema (nullity ('PGcomposite view))
1634+ -> TypeExpression db (nullity ('PGcomposite view))
1634−typeview = UnsafeTypeExpression . renderAlias
1635+typeview = UnsafeTypeExpression . renderQualifiedAlias
1636-- | logical Boolean (true/false)
1637-- | logical Boolean (true/false)
1637−bool :: TypeExpression schema (nullity 'PGbool)
1638+bool :: TypeExpression db (nullity 'PGbool)
1638bool = UnsafeTypeExpression "bool"
1639bool = UnsafeTypeExpression "bool"
1639-- | signed two-byte integer
1640-- | signed two-byte integer
1640−int2, smallint :: TypeExpression schema (nullity 'PGint2)
1641+int2, smallint :: TypeExpression db (nullity 'PGint2)
1641int2 = UnsafeTypeExpression "int2"
1642int2 = UnsafeTypeExpression "int2"
1642smallint = UnsafeTypeExpression "smallint"
1643smallint = UnsafeTypeExpression "smallint"
1643-- | signed four-byte integer
1644-- | signed four-byte integer
1644−int4, int, integer :: TypeExpression schema (nullity 'PGint4)
1645+int4, int, integer :: TypeExpression db (nullity 'PGint4)
1645int4 = UnsafeTypeExpression "int4"
1646int4 = UnsafeTypeExpression "int4"
1646int = UnsafeTypeExpression "int"
1647int = UnsafeTypeExpression "int"
1647integer = UnsafeTypeExpression "integer"
1648integer = UnsafeTypeExpression "integer"
1648-- | signed eight-byte integer
1649-- | signed eight-byte integer
1649−int8, bigint :: TypeExpression schema (nullity 'PGint8)
1650+int8, bigint :: TypeExpression db (nullity 'PGint8)
1650int8 = UnsafeTypeExpression "int8"
1651int8 = UnsafeTypeExpression "int8"
1651bigint = UnsafeTypeExpression "bigint"
1652bigint = UnsafeTypeExpression "bigint"
1652-- | arbitrary precision numeric type
1653-- | arbitrary precision numeric type
1653−numeric :: TypeExpression schema (nullity 'PGnumeric)
1654+numeric :: TypeExpression db (nullity 'PGnumeric)
1654numeric = UnsafeTypeExpression "numeric"
1655numeric = UnsafeTypeExpression "numeric"
1655-- | single precision floating-point number (4 bytes)
1656-- | single precision floating-point number (4 bytes)
1656−float4, real :: TypeExpression schema (nullity 'PGfloat4)
1657+float4, real :: TypeExpression db (nullity 'PGfloat4)
1657float4 = UnsafeTypeExpression "float4"
1658float4 = UnsafeTypeExpression "float4"
1658real = UnsafeTypeExpression "real"
1659real = UnsafeTypeExpression "real"
1659-- | double precision floating-point number (8 bytes)
1660-- | double precision floating-point number (8 bytes)
1660−float8, doublePrecision :: TypeExpression schema (nullity 'PGfloat8)
1661+float8, doublePrecision :: TypeExpression db (nullity 'PGfloat8)
1661float8 = UnsafeTypeExpression "float8"
1662float8 = UnsafeTypeExpression "float8"
1662doublePrecision = UnsafeTypeExpression "double precision"
1663doublePrecision = UnsafeTypeExpression "double precision"
1663-- | variable-length character string
1664-- | variable-length character string
1664−text :: TypeExpression schema (nullity 'PGtext)
1665+text :: TypeExpression db (nullity 'PGtext)
1665text = UnsafeTypeExpression "text"
1666text = UnsafeTypeExpression "text"
1666-- | fixed-length character string
1667-- | fixed-length character string
1667char, character
1668char, character
1668− :: forall n schema nullity. (KnownNat n, 1 <= n)
1669+ :: forall n db nullity. (KnownNat n, 1 <= n)
1669− => TypeExpression schema (nullity ('PGchar n))
1670+ => TypeExpression db (nullity ('PGchar n))
1670char = UnsafeTypeExpression $ "char(" <> renderNat @n <> ")"
1671char = UnsafeTypeExpression $ "char(" <> renderNat @n <> ")"
1671character = UnsafeTypeExpression $ "character(" <> renderNat @n <> ")"
1672character = UnsafeTypeExpression $ "character(" <> renderNat @n <> ")"
1672-- | variable-length character string
1673-- | variable-length character string
1673varchar, characterVarying
1674varchar, characterVarying
1674− :: forall n schema nullity. (KnownNat n, 1 <= n)
1675+ :: forall n db nullity. (KnownNat n, 1 <= n)
1675− => TypeExpression schema (nullity ('PGvarchar n))
1676+ => TypeExpression db (nullity ('PGvarchar n))
1676varchar = UnsafeTypeExpression $ "varchar(" <> renderNat @n <> ")"
1677varchar = UnsafeTypeExpression $ "varchar(" <> renderNat @n <> ")"
1677characterVarying = UnsafeTypeExpression $
1678characterVarying = UnsafeTypeExpression $
1678 "character varying(" <> renderNat @n <> ")"
1679 "character varying(" <> renderNat @n <> ")"
1679-- | binary data ("byte array")
1680-- | binary data ("byte array")
1680−bytea :: TypeExpression schema (nullity 'PGbytea)
1681+bytea :: TypeExpression db (nullity 'PGbytea)
1681bytea = UnsafeTypeExpression "bytea"
1682bytea = UnsafeTypeExpression "bytea"
1682-- | date and time (no time zone)
1683-- | date and time (no time zone)
1683−timestamp :: TypeExpression schema (nullity 'PGtimestamp)
1684+timestamp :: TypeExpression db (nullity 'PGtimestamp)
1684timestamp = UnsafeTypeExpression "timestamp"
1685timestamp = UnsafeTypeExpression "timestamp"
1685-- | date and time, including time zone
1686-- | date and time, including time zone
1686−timestampWithTimeZone :: TypeExpression schema (nullity 'PGtimestamptz)
1687+timestampWithTimeZone :: TypeExpression db (nullity 'PGtimestamptz)
1687timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
1688timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
1688-- | calendar date (year, month, day)
1689-- | calendar date (year, month, day)
1689−date :: TypeExpression schema (nullity 'PGdate)
1690+date :: TypeExpression db (nullity 'PGdate)
1690date = UnsafeTypeExpression "date"
1691date = UnsafeTypeExpression "date"
1691-- | time of day (no time zone)
1692-- | time of day (no time zone)
1692−time :: TypeExpression schema (nullity 'PGtime)
1693+time :: TypeExpression db (nullity 'PGtime)
1693time = UnsafeTypeExpression "time"
1694time = UnsafeTypeExpression "time"
1694-- | time of day, including time zone
1695-- | time of day, including time zone
1695−timeWithTimeZone :: TypeExpression schema (nullity 'PGtimetz)
1696+timeWithTimeZone :: TypeExpression db (nullity 'PGtimetz)
1696timeWithTimeZone = UnsafeTypeExpression "time with time zone"
1697timeWithTimeZone = UnsafeTypeExpression "time with time zone"
1697-- | time span
1698-- | time span
1698−interval :: TypeExpression schema (nullity 'PGinterval)
1699+interval :: TypeExpression db (nullity 'PGinterval)
1699interval = UnsafeTypeExpression "interval"
1700interval = UnsafeTypeExpression "interval"
1700-- | universally unique identifier
1701-- | universally unique identifier
1701−uuid :: TypeExpression schema (nullity 'PGuuid)
1702+uuid :: TypeExpression db (nullity 'PGuuid)
1702uuid = UnsafeTypeExpression "uuid"
1703uuid = UnsafeTypeExpression "uuid"
1703-- | IPv4 or IPv6 host address
1704-- | IPv4 or IPv6 host address
1704−inet :: TypeExpression schema (nullity 'PGinet)
1705+inet :: TypeExpression db (nullity 'PGinet)
1705inet = UnsafeTypeExpression "inet"
1706inet = UnsafeTypeExpression "inet"
1706-- | textual JSON data
1707-- | textual JSON data
1707−json :: TypeExpression schema (nullity 'PGjson)
1708+json :: TypeExpression db (nullity 'PGjson)
1708json = UnsafeTypeExpression "json"
1709json = UnsafeTypeExpression "json"
1709-- | binary JSON data, decomposed
1710-- | binary JSON data, decomposed
1710−jsonb :: TypeExpression schema (nullity 'PGjsonb)
1711+jsonb :: TypeExpression db (nullity 'PGjsonb)
1711jsonb = UnsafeTypeExpression "jsonb"
1712jsonb = UnsafeTypeExpression "jsonb"
1712-- | variable length array
1713-- | variable length array
1714− :: TypeExpression schema pg
1715+ :: TypeExpression db pg
1715− -> TypeExpression schema (nullity ('PGvararray pg))
1716+ -> TypeExpression db (nullity ('PGvararray pg))
1716vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1717vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1717-- | fixed length array
1718-- | fixed length array
1719-- >>> renderTypeExpression (fixarray @2 json)
1720-- >>> renderTypeExpression (fixarray @2 json)
1720-- "json[2]"
1721-- "json[2]"
1722− :: forall n schema nullity pg. KnownNat n
1723+ :: forall n db nullity pg. KnownNat n
1723− => TypeExpression schema pg
1724+ => TypeExpression db pg
1724− -> TypeExpression schema (nullity ('PGfixarray n pg))
1725+ -> TypeExpression db (nullity ('PGfixarray n pg))
1725fixarray ty = UnsafeTypeExpression $
1726fixarray ty = UnsafeTypeExpression $
1726 renderTypeExpression ty <> "[" <> renderNat @n <> "]"
1727 renderTypeExpression ty <> "[" <> renderNat @n <> "]"
1728-- | `pgtype` is a demoted version of a `PGType`
1729-- | `pgtype` is a demoted version of a `PGType`
1729−class PGTyped schema (ty :: NullityType) where
1730+class PGTyped db (ty :: NullityType) where
1730− pgtype :: TypeExpression schema ty
1731+ pgtype :: TypeExpression db ty
1731−instance PGTyped schema (nullity 'PGbool) where pgtype = bool
1732+instance PGTyped db (nullity 'PGbool) where pgtype = bool
1732−instance PGTyped schema (nullity 'PGint2) where pgtype = int2
1733+instance PGTyped db (nullity 'PGint2) where pgtype = int2
1733−instance PGTyped schema (nullity 'PGint4) where pgtype = int4
1734+instance PGTyped db (nullity 'PGint4) where pgtype = int4
1734−instance PGTyped schema (nullity 'PGint8) where pgtype = int8
1735+instance PGTyped db (nullity 'PGint8) where pgtype = int8
1735−instance PGTyped schema (nullity 'PGnumeric) where pgtype = numeric
1736+instance PGTyped db (nullity 'PGnumeric) where pgtype = numeric
1736−instance PGTyped schema (nullity 'PGfloat4) where pgtype = float4
1737+instance PGTyped db (nullity 'PGfloat4) where pgtype = float4
1737−instance PGTyped schema (nullity 'PGfloat8) where pgtype = float8
1738+instance PGTyped db (nullity 'PGfloat8) where pgtype = float8
1738−instance PGTyped schema (nullity 'PGtext) where pgtype = text
1739+instance PGTyped db (nullity 'PGtext) where pgtype = text
1739instance (KnownNat n, 1 <= n)
1740instance (KnownNat n, 1 <= n)
1740− => PGTyped schema (nullity ('PGchar n)) where pgtype = char @n
1741+ => PGTyped db (nullity ('PGchar n)) where pgtype = char @n
1741instance (KnownNat n, 1 <= n)
1742instance (KnownNat n, 1 <= n)
1742− => PGTyped schema (nullity ('PGvarchar n)) where pgtype = varchar @n
1743+ => PGTyped db (nullity ('PGvarchar n)) where pgtype = varchar @n
1743−instance PGTyped schema (nullity 'PGbytea) where pgtype = bytea
1744+instance PGTyped db (nullity 'PGbytea) where pgtype = bytea
1744−instance PGTyped schema (nullity 'PGtimestamp) where pgtype = timestamp
1745+instance PGTyped db (nullity 'PGtimestamp) where pgtype = timestamp
1745−instance PGTyped schema (nullity 'PGtimestamptz) where pgtype = timestampWithTimeZone
1746+instance PGTyped db (nullity 'PGtimestamptz) where pgtype = timestampWithTimeZone
1746−instance PGTyped schema (nullity 'PGdate) where pgtype = date
1747+instance PGTyped db (nullity 'PGdate) where pgtype = date
1747−instance PGTyped schema (nullity 'PGtime) where pgtype = time
1748+instance PGTyped db (nullity 'PGtime) where pgtype = time
1748−instance PGTyped schema (nullity 'PGtimetz) where pgtype = timeWithTimeZone
1749+instance PGTyped db (nullity 'PGtimetz) where pgtype = timeWithTimeZone
1749−instance PGTyped schema (nullity 'PGinterval) where pgtype = interval
1750+instance PGTyped db (nullity 'PGinterval) where pgtype = interval
1750−instance PGTyped schema (nullity 'PGuuid) where pgtype = uuid
1751+instance PGTyped db (nullity 'PGuuid) where pgtype = uuid
1751−instance PGTyped schema (nullity 'PGjson) where pgtype = json
1752+instance PGTyped db (nullity 'PGjson) where pgtype = json
1752−instance PGTyped schema (nullity 'PGjsonb) where pgtype = jsonb
1753+instance PGTyped db (nullity 'PGjsonb) where pgtype = jsonb
1753−instance PGTyped schema ty
1754+instance PGTyped db ty
1754− => PGTyped schema (nullity ('PGvararray ty)) where
1755+ => PGTyped db (nullity ('PGvararray ty)) where
1755− pgtype = vararray (pgtype @schema @ty)
1756+ pgtype = vararray (pgtype @db @ty)
1756−instance (KnownNat n, PGTyped schema ty)
1757+instance (KnownNat n, PGTyped db ty)
1757− => PGTyped schema (nullity ('PGfixarray n ty)) where
1758+ => PGTyped db (nullity ('PGfixarray n ty)) where
1758− pgtype = fixarray @n (pgtype @schema @ty)
1759+ pgtype = fixarray @n (pgtype @db @ty)