@@ -239,16 +239,16 @@ values from primitive expression using arithmetic, logical,
239and other operations.
239and other operations.
241newtype Expression
241newtype Expression
242 (commons :: FromType)
243 (commons :: FromType)
243 (schemas :: SchemasType)
244 (schemas :: SchemasType)
244 (params :: [NullityType])
245 (params :: [NullityType])
246 (from :: FromType)
246 (from :: FromType)
247 (ty :: NullityType)
247 (ty :: NullityType)
248 = UnsafeExpression { renderExpression :: ByteString }
248 = UnsafeExpression { renderExpression :: ByteString }
249 deriving (GHC.Generic,Show,Eq,Ord,NFData)
249 deriving (GHC.Generic,Show,Eq,Ord,NFData)
251−instance RenderSQL (Expression commons schemas params grp from ty) where
251+instance RenderSQL (Expression grp commons schemas params from ty) where
252 renderSQL = renderExpression
252 renderSQL = renderExpression
254{- | A `HasParameter` constraint is used to indicate a value that is
254{- | A `HasParameter` constraint is used to indicate a value that is
@@ -271,7 +271,7 @@ class KnownNat n => HasParameter
271 -- ($1 :: int4)
271 -- ($1 :: int4)
272 parameter
272 parameter
273 :: TypeExpression schemas ty
273 :: TypeExpression schemas ty
274− -> Expression commons schemas params grp from ty
274+ -> Expression grp commons schemas params from ty
275 parameter ty = UnsafeExpression $ parenthesized $
275 parameter ty = UnsafeExpression $ parenthesized $
276 "$" <> renderNat @n <+> "::"
276 "$" <> renderNat @n <+> "::"
277 <+> renderSQL ty
277 <+> renderSQL ty
@@ -288,32 +288,32 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
289 :: forall n commons schemas params from grp ty
289 :: forall n commons schemas params from grp ty
290 . (PGTyped schemas ty, HasParameter n params ty)
290 . (PGTyped schemas ty, HasParameter n params ty)
291− => Expression commons schemas params grp from ty -- ^ param
291+ => Expression grp commons schemas params from ty -- ^ param
292param = parameter @n (pgtype @schemas)
292param = parameter @n (pgtype @schemas)
294instance (HasUnique tab from row, Has col row ty)
294instance (HasUnique tab from row, Has col row ty)
295− => IsLabel col (Expression commons schemas params 'Ungrouped from ty) where
295+ => IsLabel col (Expression 'Ungrouped commons schemas params from ty) where
296 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
296 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
297instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
297instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
298 => IsLabel col
298 => IsLabel col
299− (Aliased (Expression commons schemas params 'Ungrouped from) column) where
299+ (Aliased (Expression 'Ungrouped commons schemas params from) column) where
300 fromLabel = fromLabel @col `As` Alias
300 fromLabel = fromLabel @col `As` Alias
301instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
301instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
302 => IsLabel col
302 => IsLabel col
303− (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
303+ (NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns) where
304 fromLabel = fromLabel @col :* Nil
304 fromLabel = fromLabel @col :* Nil
306instance (Has tab from row, Has col row ty)
306instance (Has tab from row, Has col row ty)
307− => IsQualified tab col (Expression commons schemas params 'Ungrouped from ty) where
307+ => IsQualified tab col (Expression 'Ungrouped commons schemas params from ty) where
308 tab ! col = UnsafeExpression $
308 tab ! col = UnsafeExpression $
309 renderSQL tab <> "." <> renderSQL col
309 renderSQL tab <> "." <> renderSQL col
310instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
310instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
311 => IsQualified tab col
311 => IsQualified tab col
312− (Aliased (Expression commons schemas params 'Ungrouped from) column) where
312+ (Aliased (Expression 'Ungrouped commons schemas params from) column) where
313 tab ! col = tab ! col `As` col
313 tab ! col = tab ! col `As` col
314instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
314instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
315 => IsQualified tab col
315 => IsQualified tab col
316− (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
316+ (NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns) where
317 tab ! col = tab ! col :* Nil
317 tab ! col = tab ! col :* Nil
@@ -321,7 +321,7 @@ instance
321 , Has col row ty
321 , Has col row ty
322 , GroupedBy tab col bys
322 , GroupedBy tab col bys
323 ) => IsLabel col
323 ) => IsLabel col
324− (Expression commons schemas params ('Grouped bys) from ty) where
324+ (Expression ('Grouped bys) commons schemas params from ty) where
325 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
325 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
327 ( HasUnique tab from row
327 ( HasUnique tab from row
@@ -329,7 +329,7 @@ instance
329 , GroupedBy tab col bys
329 , GroupedBy tab col bys
330 , column ~ (col ::: ty)
330 , column ~ (col ::: ty)
331 ) => IsLabel col
331 ) => IsLabel col
332− (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
332+ (Aliased (Expression ('Grouped bys) commons schemas params from) column) where
333 fromLabel = fromLabel @col `As` Alias
333 fromLabel = fromLabel @col `As` Alias
335 ( HasUnique tab from row
335 ( HasUnique tab from row
@@ -337,7 +337,7 @@ instance
337 , GroupedBy tab col bys
337 , GroupedBy tab col bys
338 , columns ~ '[col ::: ty]
338 , columns ~ '[col ::: ty]
339 ) => IsLabel col
339 ) => IsLabel col
340− (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
340+ (NP (Aliased (Expression ('Grouped bys) commons schemas params from)) columns) where
341 fromLabel = fromLabel @col :* Nil
341 fromLabel = fromLabel @col :* Nil
@@ -345,7 +345,7 @@ instance
345 , Has col row ty
345 , Has col row ty
346 , GroupedBy tab col bys
346 , GroupedBy tab col bys
347 ) => IsQualified tab col
347 ) => IsQualified tab col
348− (Expression commons schemas params ('Grouped bys) from ty) where
348+ (Expression ('Grouped bys) commons schemas params from ty) where
349 tab ! col = UnsafeExpression $
349 tab ! col = UnsafeExpression $
350 renderSQL tab <> "." <> renderSQL col
350 renderSQL tab <> "." <> renderSQL col
@@ -354,7 +354,7 @@ instance
354 , GroupedBy tab col bys
354 , GroupedBy tab col bys
355 , column ~ (col ::: ty)
355 , column ~ (col ::: ty)
356 ) => IsQualified tab col
356 ) => IsQualified tab col
357− (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
357+ (Aliased (Expression ('Grouped bys) commons schemas params from) column) where
358 tab ! col = tab ! col `As` col
358 tab ! col = tab ! col `As` col
360 ( Has tab from row
360 ( Has tab from row
@@ -362,7 +362,7 @@ instance
362 , GroupedBy tab col bys
362 , GroupedBy tab col bys
363 , columns ~ '[col ::: ty]
363 , columns ~ '[col ::: ty]
364 ) => IsQualified tab col
364 ) => IsQualified tab col
365− (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
365+ (NP (Aliased (Expression ('Grouped bys) commons schemas params from)) columns) where
366 tab ! col = tab ! col :* Nil
366 tab ! col = tab ! col :* Nil
368-- | analagous to `Nothing`
368-- | analagous to `Nothing`
@@ -386,11 +386,11 @@ notNull = UnsafeExpression . renderSQL
386-- >>> printSQL $ coalesce [null_, true] false
386-- >>> printSQL $ coalesce [null_, true] false
387-- COALESCE(NULL, TRUE, FALSE)
387-- COALESCE(NULL, TRUE, FALSE)
389− :: [Expression commons schemas params grp from ('Null ty)]
389+ :: [Expression grp commons schemas params from ('Null ty)]
390 -- ^ @NULL@s may be present
390 -- ^ @NULL@s may be present
391− -> Expression commons schemas params grp from ('NotNull ty)
391+ -> Expression grp commons schemas params from ('NotNull ty)
392 -- ^ @NULL@ is absent
392 -- ^ @NULL@ is absent
393− -> Expression commons schemas params grp from ('NotNull ty)
393+ -> Expression grp commons schemas params from ('NotNull ty)
394coalesce nullxs notNullx = UnsafeExpression $
394coalesce nullxs notNullx = UnsafeExpression $
395 "COALESCE" <> parenthesized (commaSeparated
395 "COALESCE" <> parenthesized (commaSeparated
396 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
396 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
@@ -400,26 +400,26 @@ coalesce nullxs notNullx = UnsafeExpression $
400-- >>> printSQL $ fromNull true null_
400-- >>> printSQL $ fromNull true null_
401-- COALESCE(NULL, TRUE)
401-- COALESCE(NULL, TRUE)
403− :: Expression commons schemas params grp from ('NotNull ty)
403+ :: Expression grp commons schemas params from ('NotNull ty)
404 -- ^ what to convert @NULL@ to
404 -- ^ what to convert @NULL@ to
405− -> Expression commons schemas params grp from ('Null ty)
405+ -> Expression grp commons schemas params from ('Null ty)
406− -> Expression commons schemas params grp from ('NotNull ty)
406+ -> Expression grp commons schemas params from ('NotNull ty)
407fromNull notNullx nullx = coalesce [nullx] notNullx
407fromNull notNullx nullx = coalesce [nullx] notNullx
409-- | >>> printSQL $ null_ & isNull
409-- | >>> printSQL $ null_ & isNull
410-- NULL IS NULL
410-- NULL IS NULL
412− :: Expression commons schemas params grp from ('Null ty)
412+ :: Expression grp commons schemas params from ('Null ty)
413 -- ^ possibly @NULL@
413 -- ^ possibly @NULL@
414− -> Condition commons schemas params grp from
414+ -> Condition grp commons schemas params from
415isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
415isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
417-- | >>> printSQL $ null_ & isNotNull
417-- | >>> printSQL $ null_ & isNotNull
418-- NULL IS NOT NULL
418-- NULL IS NOT NULL
420− :: Expression commons schemas params grp from ('Null ty)
420+ :: Expression grp commons schemas params from ('Null ty)
421 -- ^ possibly @NULL@
421 -- ^ possibly @NULL@
422− -> Condition commons schemas params grp from
422+ -> Condition grp commons schemas params from
423isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
423isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
425-- | analagous to `maybe` using @IS NULL@
425-- | analagous to `maybe` using @IS NULL@
@@ -427,13 +427,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
427-- >>> printSQL $ matchNull true not_ null_
427-- >>> printSQL $ matchNull true not_ null_
428-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
428-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
430− :: Expression commons schemas params grp from (nullty)
430+ :: Expression grp commons schemas params from (nullty)
431 -- ^ what to convert @NULL@ to
431 -- ^ what to convert @NULL@ to
432− -> ( Expression commons schemas params grp from ('NotNull ty)
432+ -> ( Expression grp commons schemas params from ('NotNull ty)
433− -> Expression commons schemas params grp from (nullty) )
433+ -> Expression grp commons schemas params from (nullty) )
434 -- ^ function to perform when @NULL@ is absent
434 -- ^ function to perform when @NULL@ is absent
435− -> Expression commons schemas params grp from ('Null ty)
435+ -> Expression grp commons schemas params from ('Null ty)
436− -> Expression commons schemas params grp from (nullty)
436+ -> Expression grp commons schemas params from (nullty)
437matchNull y f x = ifThenElse (isNull x) y
437matchNull y f x = ifThenElse (isNull x) y
438 (f (UnsafeExpression (renderSQL x)))
438 (f (UnsafeExpression (renderSQL x)))
@@ -446,20 +446,20 @@ matchNull y f x = ifThenElse (isNull x) y
446NULL IF (FALSE, ($1 :: bool))
446NULL IF (FALSE, ($1 :: bool))
449− :: Expression commons schemas params grp from ('NotNull ty)
449+ :: Expression grp commons schemas params from ('NotNull ty)
450 -- ^ @NULL@ is absent
450 -- ^ @NULL@ is absent
451− -> Expression commons schemas params grp from ('NotNull ty)
451+ -> Expression grp commons schemas params from ('NotNull ty)
452 -- ^ @NULL@ is absent
452 -- ^ @NULL@ is absent
453− -> Expression commons schemas params grp from ('Null ty)
453+ -> Expression grp commons schemas params from ('Null ty)
454nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
454nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
455 (renderSQL x <> ", " <> renderSQL y)
455 (renderSQL x <> ", " <> renderSQL y)
457-- | >>> printSQL $ array [null_, false, true]
457-- | >>> printSQL $ array [null_, false, true]
458-- ARRAY[NULL, FALSE, TRUE]
458-- ARRAY[NULL, FALSE, TRUE]
460− :: [Expression commons schemas params grp from ty]
460+ :: [Expression grp commons schemas params from ty]
461 -- ^ array elements
461 -- ^ array elements
462− -> Expression commons schemas params grp from (nullity ('PGvararray ty))
462+ -> Expression grp commons schemas params from (nullity ('PGvararray ty))
463array xs = UnsafeExpression $
463array xs = UnsafeExpression $
464 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
464 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
@@ -467,13 +467,13 @@ array xs = UnsafeExpression $
467-- (ARRAY[NULL, FALSE, TRUE])[2]
467-- (ARRAY[NULL, FALSE, TRUE])[2]
469 :: Word64 -- ^ index
469 :: Word64 -- ^ index
470− -> Expression commons schemas params grp from (nullity ('PGvararray ty)) -- ^ array
470+ -> Expression grp commons schemas params from (nullity ('PGvararray ty)) -- ^ array
471− -> Expression commons schemas params grp from (NullifyType ty)
471+ -> Expression grp commons schemas params from (NullifyType ty)
472index n expr = UnsafeExpression $
472index n expr = UnsafeExpression $
473 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
473 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
475instance (KnownSymbol label, label `In` labels) => IsPGlabel label
475instance (KnownSymbol label, label `In` labels) => IsPGlabel label
476− (Expression commons schemas params grp from (nullity ('PGenum labels))) where
476+ (Expression grp commons schemas params from (nullity ('PGenum labels))) where
477 label = UnsafeExpression $ renderSQL (PGlabel @label)
477 label = UnsafeExpression $ renderSQL (PGlabel @label)
479-- | A row constructor is an expression that builds a row value
479-- | A row constructor is an expression that builds a row value
@@ -485,14 +485,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
485-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
485-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
488−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression commons schemas from grp params ('NotNull Complex)
488+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression grp commons schemas params from ('NotNull Complex)
489-- >>> printSQL i
489-- >>> printSQL i
490-- ROW(0, 1)
490-- ROW(0, 1)
492 :: SListI row
492 :: SListI row
493− => NP (Aliased (Expression commons schemas params grp from)) row
493+ => NP (Aliased (Expression grp commons schemas params from)) row
494 -- ^ zero or more expressions for the row field values
494 -- ^ zero or more expressions for the row field values
495− -> Expression commons schemas params grp from (nullity ('PGcomposite row))
495+ -> Expression grp commons schemas params from (nullity ('PGcomposite row))
496row exprs = UnsafeExpression $ "ROW" <> parenthesized
496row exprs = UnsafeExpression $ "ROW" <> parenthesized
497 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
497 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
@@ -512,18 +512,18 @@ field
512 , Has field row ty)
512 , Has field row ty)
513 => QualifiedAlias sch tydef -- ^ row type
513 => QualifiedAlias sch tydef -- ^ row type
514 -> Alias field -- ^ field name
514 -> Alias field -- ^ field name
515− -> Expression commons schemas params grp from ('NotNull ('PGcomposite row))
515+ -> Expression grp commons schemas params from ('NotNull ('PGcomposite row))
516− -> Expression commons schemas params grp from ty
516+ -> Expression grp commons schemas params from ty
517field td fld expr = UnsafeExpression $
517field td fld expr = UnsafeExpression $
518 parenthesized (renderSQL expr <> "::" <> renderSQL td)
518 parenthesized (renderSQL expr <> "::" <> renderSQL td)
519 <> "." <> renderSQL fld
519 <> "." <> renderSQL fld
521instance Semigroup
521instance Semigroup
522− (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
522+ (Expression grp commons schemas params from (nullity ('PGvararray ty))) where
523 (<>) = unsafeBinaryOp "||"
523 (<>) = unsafeBinaryOp "||"
525instance Monoid
525instance Monoid
526− (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
526+ (Expression grp commons schemas params from (nullity ('PGvararray ty))) where
527 mempty = array []
527 mempty = array []
528 mappend = (<>)
528 mappend = (<>)
@@ -531,22 +531,22 @@ instance Monoid
531-- >>> printSQL expr
531-- >>> printSQL expr
532-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
532-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
534− :: Expression commons schemas params grp from (nullty)
534+ :: Expression grp commons schemas params from (nullty)
535 -- ^ needs at least 1 argument
535 -- ^ needs at least 1 argument
536− -> [Expression commons schemas params grp from (nullty)]
536+ -> [Expression grp commons schemas params from (nullty)]
537 -- ^ or more
537 -- ^ or more
538− -> Expression commons schemas params grp from (nullty)
538+ -> Expression grp commons schemas params from (nullty)
539greatest x xs = UnsafeExpression $ "GREATEST("
539greatest x xs = UnsafeExpression $ "GREATEST("
540 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
540 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
542-- | >>> printSQL $ least currentTimestamp [null_]
542-- | >>> printSQL $ least currentTimestamp [null_]
543-- LEAST(CURRENT_TIMESTAMP, NULL)
543-- LEAST(CURRENT_TIMESTAMP, NULL)
545− :: Expression commons schemas params grp from (nullty)
545+ :: Expression grp commons schemas params from (nullty)
546 -- ^ needs at least 1 argument
546 -- ^ needs at least 1 argument
547− -> [Expression commons schemas params grp from (nullty)]
547+ -> [Expression grp commons schemas params from (nullty)]
548 -- ^ or more
548 -- ^ or more
549− -> Expression commons schemas params grp from (nullty)
549+ -> Expression grp commons schemas params from (nullty)
550least x xs = UnsafeExpression $ "LEAST("
550least x xs = UnsafeExpression $ "LEAST("
551 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
551 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
@@ -555,9 +555,9 @@ least x xs = UnsafeExpression $ "LEAST("
555unsafeBinaryOp
555unsafeBinaryOp
556 :: ByteString
556 :: ByteString
557 -- ^ operator
557 -- ^ operator
558− -> Expression commons schemas params grp from (ty0)
558+ -> Expression grp commons schemas params from (ty0)
559− -> Expression commons schemas params grp from (ty1)
559+ -> Expression grp commons schemas params from (ty1)
560− -> Expression commons schemas params grp from (ty2)
560+ -> Expression grp commons schemas params from (ty2)
561unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
561unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
562 renderSQL x <+> op <+> renderSQL y
562 renderSQL x <+> op <+> renderSQL y
@@ -566,8 +566,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
566unsafeUnaryOp
566unsafeUnaryOp
567 :: ByteString
567 :: ByteString
568 -- ^ operator
568 -- ^ operator
569− -> Expression commons schemas params grp from (ty0)
569+ -> Expression grp commons schemas params from (ty0)
570− -> Expression commons schemas params grp from (ty1)
570+ -> Expression grp commons schemas params from (ty1)
571unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
571unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
572 op <+> renderSQL x
572 op <+> renderSQL x
@@ -576,8 +576,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
576unsafeFunction
576unsafeFunction
577 :: ByteString
577 :: ByteString
578 -- ^ function
578 -- ^ function
579− -> Expression commons schemas params grp from (xty)
579+ -> Expression grp commons schemas params from (xty)
580− -> Expression commons schemas params grp from (yty)
580+ -> Expression grp commons schemas params from (yty)
581unsafeFunction fun x = UnsafeExpression $
581unsafeFunction fun x = UnsafeExpression $
582 fun <> parenthesized (renderSQL x)
582 fun <> parenthesized (renderSQL x)
@@ -586,13 +586,13 @@ unsafeVariadicFunction
586 :: SListI elems
586 :: SListI elems
587 => ByteString
587 => ByteString
588 -- ^ function
588 -- ^ function
589− -> NP (Expression commons schemas params grp from) elems
589+ -> NP (Expression grp commons schemas params from) elems
590− -> Expression commons schemas params grp from ret
590+ -> Expression grp commons schemas params from ret
591unsafeVariadicFunction fun x = UnsafeExpression $
591unsafeVariadicFunction fun x = UnsafeExpression $
592 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
592 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
594instance ty `In` PGNum
594instance ty `In` PGNum
595− => Num (Expression commons schemas params grp from (nullity ty)) where
595+ => Num (Expression grp commons schemas params from (nullity ty)) where
596 (+) = unsafeBinaryOp "+"
596 (+) = unsafeBinaryOp "+"
597 (-) = unsafeBinaryOp "-"
597 (-) = unsafeBinaryOp "-"
598 (*) = unsafeBinaryOp "*"
598 (*) = unsafeBinaryOp "*"
@@ -604,12 +604,12 @@ instance ty `In` PGNum
606instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
606instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
607− (Expression commons schemas params grp from (nullity ty)) where
607+ (Expression grp commons schemas params from (nullity ty)) where
608 (/) = unsafeBinaryOp "/"
608 (/) = unsafeBinaryOp "/"
609 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
609 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
611instance (ty `In` PGNum, ty `In` PGFloating) => Floating
611instance (ty `In` PGNum, ty `In` PGFloating) => Floating
612− (Expression commons schemas params grp from (nullity ty)) where
612+ (Expression grp commons schemas params from (nullity ty)) where
613 pi = UnsafeExpression "pi()"
613 pi = UnsafeExpression "pi()"
614 exp = unsafeFunction "exp"
614 exp = unsafeFunction "exp"
615 log = unsafeFunction "ln"
615 log = unsafeFunction "ln"
@@ -632,18 +632,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
633-- | >>> :{
633-- | >>> :{
635−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
635+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
636-- expression = atan2_ pi 2
636-- expression = atan2_ pi 2
637-- in printSQL expression
637-- in printSQL expression
639-- atan2(pi(), 2)
639-- atan2(pi(), 2)
641 :: float `In` PGFloating
641 :: float `In` PGFloating
642− => Expression commons schemas params grp from (nullity float)
642+ => Expression grp commons schemas params from (nullity float)
643 -- ^ numerator
643 -- ^ numerator
644− -> Expression commons schemas params grp from (nullity float)
644+ -> Expression grp commons schemas params from (nullity float)
645 -- ^ denominator
645 -- ^ denominator
646− -> Expression commons schemas params grp from (nullity float)
646+ -> Expression grp commons schemas params from (nullity float)
647atan2_ y x = UnsafeExpression $
647atan2_ y x = UnsafeExpression $
648 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
648 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
@@ -656,9 +656,9 @@ atan2_ y x = UnsafeExpression $
657 :: TypeExpression schemas ty1
657 :: TypeExpression schemas ty1
658 -- ^ type to cast as
658 -- ^ type to cast as
659− -> Expression commons schemas params grp from ty0
659+ -> Expression grp commons schemas params from ty0
660 -- ^ value to convert
660 -- ^ value to convert
661− -> Expression commons schemas params grp from ty1
661+ -> Expression grp commons schemas params from ty1
662cast ty x = UnsafeExpression $ parenthesized $
662cast ty x = UnsafeExpression $ parenthesized $
663 renderSQL x <+> "::" <+> renderSQL ty
663 renderSQL x <+> "::" <+> renderSQL ty
@@ -666,136 +666,136 @@ cast ty x = UnsafeExpression $ parenthesized $
669−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
669+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
670-- expression = 5 `quot_` 2
670-- expression = 5 `quot_` 2
671-- in printSQL expression
671-- in printSQL expression
673-- (5 / 2)
673-- (5 / 2)
675 :: int `In` PGIntegral
675 :: int `In` PGIntegral
676− => Expression commons schemas params grp from (nullity int)
676+ => Expression grp commons schemas params from (nullity int)
677 -- ^ numerator
677 -- ^ numerator
678− -> Expression commons schemas params grp from (nullity int)
678+ -> Expression grp commons schemas params from (nullity int)
679 -- ^ denominator
679 -- ^ denominator
680− -> Expression commons schemas params grp from (nullity int)
680+ -> Expression grp commons schemas params from (nullity int)
681quot_ = unsafeBinaryOp "/"
681quot_ = unsafeBinaryOp "/"
683-- | remainder upon integer division
683-- | remainder upon integer division
687−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
687+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
688-- expression = 5 `rem_` 2
688-- expression = 5 `rem_` 2
689-- in printSQL expression
689-- in printSQL expression
691-- (5 % 2)
691-- (5 % 2)
693 :: int `In` PGIntegral
693 :: int `In` PGIntegral
694− => Expression commons schemas params grp from (nullity int)
694+ => Expression grp commons schemas params from (nullity int)
695 -- ^ numerator
695 -- ^ numerator
696− -> Expression commons schemas params grp from (nullity int)
696+ -> Expression grp commons schemas params from (nullity int)
697 -- ^ denominator
697 -- ^ denominator
698− -> Expression commons schemas params grp from (nullity int)
698+ -> Expression grp commons schemas params from (nullity int)
699rem_ = unsafeBinaryOp "%"
699rem_ = unsafeBinaryOp "%"
701-- | >>> :{
701-- | >>> :{
703−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
703+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
704-- expression = trunc pi
704-- expression = trunc pi
705-- in printSQL expression
705-- in printSQL expression
707-- trunc(pi())
707-- trunc(pi())
709 :: frac `In` PGFloating
709 :: frac `In` PGFloating
710− => Expression commons schemas params grp from (nullity frac)
710+ => Expression grp commons schemas params from (nullity frac)
711 -- ^ fractional number
711 -- ^ fractional number
712− -> Expression commons schemas params grp from (nullity frac)
712+ -> Expression grp commons schemas params from (nullity frac)
713trunc = unsafeFunction "trunc"
713trunc = unsafeFunction "trunc"
715-- | >>> :{
715-- | >>> :{
717−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
717+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
718-- expression = round_ pi
718-- expression = round_ pi
719-- in printSQL expression
719-- in printSQL expression
721-- round(pi())
721-- round(pi())
723 :: frac `In` PGFloating
723 :: frac `In` PGFloating
724− => Expression commons schemas params grp from (nullity frac)
724+ => Expression grp commons schemas params from (nullity frac)
725 -- ^ fractional number
725 -- ^ fractional number
726− -> Expression commons schemas params grp from (nullity frac)
726+ -> Expression grp commons schemas params from (nullity frac)
727round_ = unsafeFunction "round"
727round_ = unsafeFunction "round"
729-- | >>> :{
729-- | >>> :{
731−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
731+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
732-- expression = ceiling_ pi
732-- expression = ceiling_ pi
733-- in printSQL expression
733-- in printSQL expression
735-- ceiling(pi())
735-- ceiling(pi())
737 :: frac `In` PGFloating
737 :: frac `In` PGFloating
738− => Expression commons schemas params grp from (nullity frac)
738+ => Expression grp commons schemas params from (nullity frac)
739 -- ^ fractional number
739 -- ^ fractional number
740− -> Expression commons schemas params grp from (nullity frac)
740+ -> Expression grp commons schemas params from (nullity frac)
741ceiling_ = unsafeFunction "ceiling"
741ceiling_ = unsafeFunction "ceiling"
743-- | A `Condition` is an `Expression`, which can evaluate
743-- | A `Condition` is an `Expression`, which can evaluate
744-- to `true`, `false` or `null_`. This is because SQL uses
744-- to `true`, `false` or `null_`. This is because SQL uses
745-- a three valued logic.
745-- a three valued logic.
746−type Condition commons schemas params grp from =
746+type Condition grp commons schemas params from =
747− Expression commons schemas params grp from ('Null 'PGbool)
747+ Expression grp commons schemas params from ('Null 'PGbool)
749-- | >>> printSQL true
749-- | >>> printSQL true
751−true :: Expression commons schemas params grp from (nullity 'PGbool)
751+true :: Expression grp commons schemas params from (nullity 'PGbool)
752true = UnsafeExpression "TRUE"
752true = UnsafeExpression "TRUE"
754-- | >>> printSQL false
754-- | >>> printSQL false
756−false :: Expression commons schemas params grp from (nullity 'PGbool)
756+false :: Expression grp commons schemas params from (nullity 'PGbool)
757false = UnsafeExpression "FALSE"
757false = UnsafeExpression "FALSE"
759-- | >>> printSQL $ not_ true
759-- | >>> printSQL $ not_ true
760-- (NOT TRUE)
760-- (NOT TRUE)
762− :: Expression commons schemas params grp from (nullity 'PGbool)
762+ :: Expression grp commons schemas params from (nullity 'PGbool)
763− -> Expression commons schemas params grp from (nullity 'PGbool)
763+ -> Expression grp commons schemas params from (nullity 'PGbool)
764not_ = unsafeUnaryOp "NOT"
764not_ = unsafeUnaryOp "NOT"
766-- | >>> printSQL $ true .&& false
766-- | >>> printSQL $ true .&& false
767-- (TRUE AND FALSE)
767-- (TRUE AND FALSE)
769− :: Expression commons schemas params grp from (nullity 'PGbool)
769+ :: Expression grp commons schemas params from (nullity 'PGbool)
770− -> Expression commons schemas params grp from (nullity 'PGbool)
770+ -> Expression grp commons schemas params from (nullity 'PGbool)
771− -> Expression commons schemas params grp from (nullity 'PGbool)
771+ -> Expression grp commons schemas params from (nullity 'PGbool)
772infixr 3 .&&
772infixr 3 .&&
773(.&&) = unsafeBinaryOp "AND"
773(.&&) = unsafeBinaryOp "AND"
775-- | >>> printSQL $ true .|| false
775-- | >>> printSQL $ true .|| false
776-- (TRUE OR FALSE)
776-- (TRUE OR FALSE)
778− :: Expression commons schemas params grp from (nullity 'PGbool)
778+ :: Expression grp commons schemas params from (nullity 'PGbool)
779− -> Expression commons schemas params grp from (nullity 'PGbool)
779+ -> Expression grp commons schemas params from (nullity 'PGbool)
780− -> Expression commons schemas params grp from (nullity 'PGbool)
780+ -> Expression grp commons schemas params from (nullity 'PGbool)
781infixr 2 .||
781infixr 2 .||
782(.||) = unsafeBinaryOp "OR"
782(.||) = unsafeBinaryOp "OR"
784-- | >>> :{
784-- | >>> :{
786−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
786+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
787-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
787-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
788-- in printSQL expression
788-- in printSQL expression
790-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
790-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
791caseWhenThenElse
791caseWhenThenElse
792− :: [ ( Condition commons schemas params grp from
792+ :: [ ( Condition grp commons schemas params from
793− , Expression commons schemas params grp from ty
793+ , Expression grp commons schemas params from ty
795 -- ^ whens and thens
795 -- ^ whens and thens
796− -> Expression commons schemas params grp from ty
796+ -> Expression grp commons schemas params from ty
797 -- ^ else
797 -- ^ else
798− -> Expression commons schemas params grp from ty
798+ -> Expression grp commons schemas params from ty
799caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
799caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
801 , mconcat
801 , mconcat
@@ -811,16 +811,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
812-- | >>> :{
812-- | >>> :{
814−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
814+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
815-- expression = ifThenElse true 1 0
815-- expression = ifThenElse true 1 0
816-- in printSQL expression
816-- in printSQL expression
818-- CASE WHEN TRUE THEN 1 ELSE 0 END
818-- CASE WHEN TRUE THEN 1 ELSE 0 END
819ifThenElse
819ifThenElse
820− :: Condition commons schemas params grp from
820+ :: Condition grp commons schemas params from
821− -> Expression commons schemas params grp from ty -- ^ then
821+ -> Expression grp commons schemas params from ty -- ^ then
822− -> Expression commons schemas params grp from ty -- ^ else
822+ -> Expression grp commons schemas params from ty -- ^ else
823− -> Expression commons schemas params grp from ty
823+ -> Expression grp commons schemas params from ty
824ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
824ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
826-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
826-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -829,85 +829,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
829-- >>> printSQL $ true .== null_
829-- >>> printSQL $ true .== null_
830-- (TRUE = NULL)
830-- (TRUE = NULL)
832− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
832+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
833− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
833+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
834− -> Condition commons schemas params grp from
834+ -> Condition grp commons schemas params from
835(.==) = unsafeBinaryOp "="
835(.==) = unsafeBinaryOp "="
836infix 4 .==
836infix 4 .==
838-- | >>> printSQL $ true ./= null_
838-- | >>> printSQL $ true ./= null_
839-- (TRUE <> NULL)
839-- (TRUE <> NULL)
841− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
841+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
842− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
842+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
843− -> Condition commons schemas params grp from
843+ -> Condition grp commons schemas params from
844(./=) = unsafeBinaryOp "<>"
844(./=) = unsafeBinaryOp "<>"
845infix 4 ./=
845infix 4 ./=
847-- | >>> printSQL $ true .>= null_
847-- | >>> printSQL $ true .>= null_
848-- (TRUE >= NULL)
848-- (TRUE >= NULL)
850− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
850+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
851− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
851+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
852− -> Condition commons schemas params grp from
852+ -> Condition grp commons schemas params from
853(.>=) = unsafeBinaryOp ">="
853(.>=) = unsafeBinaryOp ">="
854infix 4 .>=
854infix 4 .>=
856-- | >>> printSQL $ true .< null_
856-- | >>> printSQL $ true .< null_
857-- (TRUE < NULL)
857-- (TRUE < NULL)
859− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
859+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
860− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
860+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
861− -> Condition commons schemas params grp from
861+ -> Condition grp commons schemas params from
862(.<) = unsafeBinaryOp "<"
862(.<) = unsafeBinaryOp "<"
863infix 4 .<
863infix 4 .<
865-- | >>> printSQL $ true .<= null_
865-- | >>> printSQL $ true .<= null_
866-- (TRUE <= NULL)
866-- (TRUE <= NULL)
868− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
868+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
869− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
869+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
870− -> Condition commons schemas params grp from
870+ -> Condition grp commons schemas params from
871(.<=) = unsafeBinaryOp "<="
871(.<=) = unsafeBinaryOp "<="
872infix 4 .<=
872infix 4 .<=
874-- | >>> printSQL $ true .> null_
874-- | >>> printSQL $ true .> null_
875-- (TRUE > NULL)
875-- (TRUE > NULL)
877− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
877+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
878− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
878+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
879− -> Condition commons schemas params grp from
879+ -> Condition grp commons schemas params from
880(.>) = unsafeBinaryOp ">"
880(.>) = unsafeBinaryOp ">"
881infix 4 .>
881infix 4 .>
883-- | >>> printSQL currentDate
883-- | >>> printSQL currentDate
884-- CURRENT_DATE
884-- CURRENT_DATE
885currentDate
885currentDate
886− :: Expression commons schemas params grp from (nullity 'PGdate)
886+ :: Expression grp commons schemas params from (nullity 'PGdate)
887currentDate = UnsafeExpression "CURRENT_DATE"
887currentDate = UnsafeExpression "CURRENT_DATE"
889-- | >>> printSQL currentTime
889-- | >>> printSQL currentTime
890-- CURRENT_TIME
890-- CURRENT_TIME
891currentTime
891currentTime
892− :: Expression commons schemas params grp from (nullity 'PGtimetz)
892+ :: Expression grp commons schemas params from (nullity 'PGtimetz)
893currentTime = UnsafeExpression "CURRENT_TIME"
893currentTime = UnsafeExpression "CURRENT_TIME"
895-- | >>> printSQL currentTimestamp
895-- | >>> printSQL currentTimestamp
896-- CURRENT_TIMESTAMP
896-- CURRENT_TIMESTAMP
897currentTimestamp
897currentTimestamp
898− :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
898+ :: Expression grp commons schemas params from (nullity 'PGtimestamptz)
899currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
899currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
901-- | >>> printSQL localTime
901-- | >>> printSQL localTime
902-- LOCALTIME
902-- LOCALTIME
904− :: Expression commons schemas params grp from (nullity 'PGtime)
904+ :: Expression grp commons schemas params from (nullity 'PGtime)
905localTime = UnsafeExpression "LOCALTIME"
905localTime = UnsafeExpression "LOCALTIME"
907-- | >>> printSQL localTimestamp
907-- | >>> printSQL localTimestamp
908-- LOCALTIMESTAMP
908-- LOCALTIMESTAMP
909localTimestamp
909localTimestamp
910− :: Expression commons schemas params grp from (nullity 'PGtimestamp)
910+ :: Expression grp commons schemas params from (nullity 'PGtimestamp)
911localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
911localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
913{-----------------------------------------
913{-----------------------------------------
@@ -915,7 +915,7 @@ text
915-----------------------------------------}
915-----------------------------------------}
917instance IsString
917instance IsString
918− (Expression commons schemas params grp from (nullity 'PGtext)) where
918+ (Expression grp commons schemas params from (nullity 'PGtext)) where
919 fromString str = UnsafeExpression $
919 fromString str = UnsafeExpression $
920 "E\'" <> fromString (escape =<< str) <> "\'"
920 "E\'" <> fromString (escape =<< str) <> "\'"
@@ -931,36 +931,36 @@ instance IsString
933instance Semigroup
933instance Semigroup
934− (Expression commons schemas params grp from (nullity 'PGtext)) where
934+ (Expression grp commons schemas params from (nullity 'PGtext)) where
935 (<>) = unsafeBinaryOp "||"
935 (<>) = unsafeBinaryOp "||"
937instance Monoid
937instance Monoid
938− (Expression commons schemas params grp from (nullity 'PGtext)) where
938+ (Expression grp commons schemas params from (nullity 'PGtext)) where
939 mempty = fromString ""
939 mempty = fromString ""
940 mappend = (<>)
940 mappend = (<>)
942-- | >>> printSQL $ lower "ARRRGGG"
942-- | >>> printSQL $ lower "ARRRGGG"
943-- lower(E'ARRRGGG')
943-- lower(E'ARRRGGG')
945− :: Expression commons schemas params grp from (nullity 'PGtext)
945+ :: Expression grp commons schemas params from (nullity 'PGtext)
946 -- ^ string to lower case
946 -- ^ string to lower case
947− -> Expression commons schemas params grp from (nullity 'PGtext)
947+ -> Expression grp commons schemas params from (nullity 'PGtext)
948lower = unsafeFunction "lower"
948lower = unsafeFunction "lower"
950-- | >>> printSQL $ upper "eeee"
950-- | >>> printSQL $ upper "eeee"
951-- upper(E'eeee')
951-- upper(E'eeee')
953− :: Expression commons schemas params grp from (nullity 'PGtext)
953+ :: Expression grp commons schemas params from (nullity 'PGtext)
954 -- ^ string to upper case
954 -- ^ string to upper case
955− -> Expression commons schemas params grp from (nullity 'PGtext)
955+ -> Expression grp commons schemas params from (nullity 'PGtext)
956upper = unsafeFunction "upper"
956upper = unsafeFunction "upper"
958-- | >>> printSQL $ charLength "four"
958-- | >>> printSQL $ charLength "four"
959-- char_length(E'four')
959-- char_length(E'four')
960charLength
960charLength
961− :: Expression commons schemas params grp from (nullity 'PGtext)
961+ :: Expression grp commons schemas params from (nullity 'PGtext)
962 -- ^ string to measure
962 -- ^ string to measure
963− -> Expression commons schemas params grp from (nullity 'PGint4)
963+ -> Expression grp commons schemas params from (nullity 'PGint4)
964charLength = unsafeFunction "char_length"
964charLength = unsafeFunction "char_length"
966-- | The `like` expression returns true if the @string@ matches
966-- | The `like` expression returns true if the @string@ matches
@@ -973,11 +973,11 @@ charLength = unsafeFunction "char_length"
973-- >>> printSQL $ "abc" `like` "a%"
973-- >>> printSQL $ "abc" `like` "a%"
974-- (E'abc' LIKE E'a%')
974-- (E'abc' LIKE E'a%')
976− :: Expression commons schemas params grp from (nullity 'PGtext)
976+ :: Expression grp commons schemas params from (nullity 'PGtext)
977 -- ^ string
977 -- ^ string
978− -> Expression commons schemas params grp from (nullity 'PGtext)
978+ -> Expression grp commons schemas params from (nullity 'PGtext)
979 -- ^ pattern
979 -- ^ pattern
980− -> Expression commons schemas params grp from (nullity 'PGbool)
980+ -> Expression grp commons schemas params from (nullity 'PGbool)
981like = unsafeBinaryOp "LIKE"
981like = unsafeBinaryOp "LIKE"
983-- | The key word ILIKE can be used instead of LIKE to make the
983-- | The key word ILIKE can be used instead of LIKE to make the
@@ -986,11 +986,11 @@ like = unsafeBinaryOp "LIKE"
986-- >>> printSQL $ "abc" `ilike` "a%"
986-- >>> printSQL $ "abc" `ilike` "a%"
987-- (E'abc' ILIKE E'a%')
987-- (E'abc' ILIKE E'a%')
989− :: Expression commons schemas params grp from (nullity 'PGtext)
989+ :: Expression grp commons schemas params from (nullity 'PGtext)
990 -- ^ string
990 -- ^ string
991− -> Expression commons schemas params grp from (nullity 'PGtext)
991+ -> Expression grp commons schemas params from (nullity 'PGtext)
992 -- ^ pattern
992 -- ^ pattern
993− -> Expression commons schemas params grp from (nullity 'PGbool)
993+ -> Expression grp commons schemas params from (nullity 'PGbool)
994ilike = unsafeBinaryOp "ILIKE"
994ilike = unsafeBinaryOp "ILIKE"
996{-----------------------------------------
996{-----------------------------------------
@@ -1005,36 +1005,36 @@ Table 9.44: json and jsonb operators
1005-- | Get JSON value (object field or array element) at a key.
1005-- | Get JSON value (object field or array element) at a key.
1007 :: (json `In` PGJsonType, key `In` PGJsonKey)
1007 :: (json `In` PGJsonType, key `In` PGJsonKey)
1008− => Expression commons schemas params grp from (nullity json)
1008+ => Expression grp commons schemas params from (nullity json)
1009− -> Expression commons schemas params grp from (nullity key)
1009+ -> Expression grp commons schemas params from (nullity key)
1010− -> Expression commons schemas params grp from ('Null json)
1010+ -> Expression grp commons schemas params from ('Null json)
1011infixl 8 .->
1011infixl 8 .->
1012(.->) = unsafeBinaryOp "->"
1012(.->) = unsafeBinaryOp "->"
1014-- | Get JSON value (object field or array element) at a key, as text.
1014-- | Get JSON value (object field or array element) at a key, as text.
1016 :: (json `In` PGJsonType, key `In` PGJsonKey)
1016 :: (json `In` PGJsonType, key `In` PGJsonKey)
1017− => Expression commons schemas params grp from (nullity json)
1017+ => Expression grp commons schemas params from (nullity json)
1018− -> Expression commons schemas params grp from (nullity key)
1018+ -> Expression grp commons schemas params from (nullity key)
1019− -> Expression commons schemas params grp from ('Null 'PGtext)
1019+ -> Expression grp commons schemas params from ('Null 'PGtext)
1020infixl 8 .->>
1020infixl 8 .->>
1021(.->>) = unsafeBinaryOp "->>"
1021(.->>) = unsafeBinaryOp "->>"
1023-- | Get JSON value at a specified path.
1023-- | Get JSON value at a specified path.
1025 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1025 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1026− => Expression commons schemas params grp from (nullity json)
1026+ => Expression grp commons schemas params from (nullity json)
1027− -> Expression commons schemas params grp from (nullity path)
1027+ -> Expression grp commons schemas params from (nullity path)
1028− -> Expression commons schemas params grp from ('Null json)
1028+ -> Expression grp commons schemas params from ('Null json)
1029infixl 8 .#>
1029infixl 8 .#>
1030(.#>) = unsafeBinaryOp "#>"
1030(.#>) = unsafeBinaryOp "#>"
1032-- | Get JSON value at a specified path as text.
1032-- | Get JSON value at a specified path as text.
1034 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1034 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1035− => Expression commons schemas params grp from (nullity json)
1035+ => Expression grp commons schemas params from (nullity json)
1036− -> Expression commons schemas params grp from (nullity path)
1036+ -> Expression grp commons schemas params from (nullity path)
1037− -> Expression commons schemas params grp from ('Null 'PGtext)
1037+ -> Expression grp commons schemas params from ('Null 'PGtext)
1038infixl 8 .#>>
1038infixl 8 .#>>
1039(.#>>) = unsafeBinaryOp "#>>"
1039(.#>>) = unsafeBinaryOp "#>>"
@@ -1043,42 +1043,42 @@ infixl 8 .#>>
1043-- | Does the left JSON value contain the right JSON path/value entries at the
1043-- | Does the left JSON value contain the right JSON path/value entries at the
1044-- top level?
1044-- top level?
1046− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1046+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1047− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1047+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1048− -> Condition commons schemas params grp from
1048+ -> Condition grp commons schemas params from
1049infixl 9 .@>
1049infixl 9 .@>
1050(.@>) = unsafeBinaryOp "@>"
1050(.@>) = unsafeBinaryOp "@>"
1052-- | Are the left JSON path/value entries contained at the top level within the
1052-- | Are the left JSON path/value entries contained at the top level within the
1053-- right JSON value?
1053-- right JSON value?
1055− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1055+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1056− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1056+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1057− -> Condition commons schemas params grp from
1057+ -> Condition grp commons schemas params from
1058infixl 9 .<@
1058infixl 9 .<@
1059(.<@) = unsafeBinaryOp "<@"
1059(.<@) = unsafeBinaryOp "<@"
1061-- | Does the string exist as a top-level key within the JSON value?
1061-- | Does the string exist as a top-level key within the JSON value?
1063− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1063+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1064− -> Expression commons schemas params grp from (nullity 'PGtext)
1064+ -> Expression grp commons schemas params from (nullity 'PGtext)
1065− -> Condition commons schemas params grp from
1065+ -> Condition grp commons schemas params from
1066infixl 9 .?
1066infixl 9 .?
1067(.?) = unsafeBinaryOp "?"
1067(.?) = unsafeBinaryOp "?"
1069-- | Do any of these array strings exist as top-level keys?
1069-- | Do any of these array strings exist as top-level keys?
1071− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1071+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1072− -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1072+ -> Expression grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1073− -> Condition commons schemas params grp from
1073+ -> Condition grp commons schemas params from
1074infixl 9 .?|
1074infixl 9 .?|
1075(.?|) = unsafeBinaryOp "?|"
1075(.?|) = unsafeBinaryOp "?|"
1077-- | Do all of these array strings exist as top-level keys?
1077-- | Do all of these array strings exist as top-level keys?
1079− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1079+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1080− -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1080+ -> Expression grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1081− -> Condition commons schemas params grp from
1081+ -> Condition grp commons schemas params from
1082infixl 9 .?&
1082infixl 9 .?&
1083(.?&) = unsafeBinaryOp "?&"
1083(.?&) = unsafeBinaryOp "?&"
@@ -1101,9 +1101,9 @@ instance
1101-- count from the end). Throws an error if top level container is not an array.
1101-- count from the end). Throws an error if top level container is not an array.
1103 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1103 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1104− => Expression commons schemas params grp from (nullity 'PGjsonb)
1104+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1105− -> Expression commons schemas params grp from (nullity key)
1105+ -> Expression grp commons schemas params from (nullity key)
1106− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1106+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1107infixl 6 .-.
1107infixl 6 .-.
1108(.-.) = unsafeBinaryOp "-"
1108(.-.) = unsafeBinaryOp "-"
@@ -1111,9 +1111,9 @@ infixl 6 .-.
1111-- integers count from the end)
1111-- integers count from the end)
1113 :: PGTextArray "(#-.)" arrayty
1113 :: PGTextArray "(#-.)" arrayty
1114− => Expression commons schemas params grp from (nullity 'PGjsonb)
1114+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1115− -> Expression commons schemas params grp from (nullity arrayty)
1115+ -> Expression grp commons schemas params from (nullity arrayty)
1116− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1116+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1117infixl 6 #-.
1117infixl 6 #-.
1118(#-.) = unsafeBinaryOp "#-"
1118(#-.) = unsafeBinaryOp "#-"
@@ -1124,14 +1124,14 @@ Table 9.45: JSON creation functions
1124-- | Literal binary JSON
1124-- | Literal binary JSON
1126 :: JSON.ToJSON x
1126 :: JSON.ToJSON x
1127− => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
1127+ => x -> Expression grp commons schemas params from (nullity 'PGjsonb)
1128jsonbLit = cast jsonb . UnsafeExpression
1128jsonbLit = cast jsonb . UnsafeExpression
1129 . singleQuotedUtf8 . toStrict . JSON.encode
1129 . singleQuotedUtf8 . toStrict . JSON.encode
1131-- | Literal JSON
1131-- | Literal JSON
1133 :: JSON.ToJSON x
1133 :: JSON.ToJSON x
1134− => x -> Expression commons schemas params grp from (nullity 'PGjson)
1134+ => x -> Expression grp commons schemas params from (nullity 'PGjson)
1135jsonLit = cast json . UnsafeExpression
1135jsonLit = cast json . UnsafeExpression
1136 . singleQuotedUtf8 . toStrict . JSON.encode
1136 . singleQuotedUtf8 . toStrict . JSON.encode
@@ -1142,8 +1142,8 @@ jsonLit = cast json . UnsafeExpression
1142-- number, a Boolean, or a null value, the text representation will be used, in
1142-- number, a Boolean, or a null value, the text representation will be used, in
1143-- such a fashion that it is a valid json value.
1143-- such a fashion that it is a valid json value.
1145− :: Expression commons schemas params grp from (nullity ty)
1145+ :: Expression grp commons schemas params from (nullity ty)
1146− -> Expression commons schemas params grp from (nullity 'PGjson)
1146+ -> Expression grp commons schemas params from (nullity 'PGjson)
1147toJson = unsafeFunction "to_json"
1147toJson = unsafeFunction "to_json"
1149-- | Returns the value as jsonb. Arrays and composites are converted
1149-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1153,43 +1153,43 @@ toJson = unsafeFunction "to_json"
1153-- number, a Boolean, or a null value, the text representation will be used, in
1153-- number, a Boolean, or a null value, the text representation will be used, in
1154-- such a fashion that it is a valid jsonb value.
1154-- such a fashion that it is a valid jsonb value.
1156− :: Expression commons schemas params grp from (nullity ty)
1156+ :: Expression grp commons schemas params from (nullity ty)
1157− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1157+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1158toJsonb = unsafeFunction "to_jsonb"
1158toJsonb = unsafeFunction "to_jsonb"
1160-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1160-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1161-- becomes a JSON array of arrays.
1161-- becomes a JSON array of arrays.
1162arrayToJson
1162arrayToJson
1163 :: PGArray "arrayToJson" arr
1163 :: PGArray "arrayToJson" arr
1164− => Expression commons schemas params grp from (nullity arr)
1164+ => Expression grp commons schemas params from (nullity arr)
1165− -> Expression commons schemas params grp from (nullity 'PGjson)
1165+ -> Expression grp commons schemas params from (nullity 'PGjson)
1166arrayToJson = unsafeFunction "array_to_json"
1166arrayToJson = unsafeFunction "array_to_json"
1168-- | Returns the row as a JSON object.
1168-- | Returns the row as a JSON object.
1169rowToJson
1169rowToJson
1170− :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1170+ :: Expression grp commons schemas params from (nullity ('PGcomposite ty))
1171− -> Expression commons schemas params grp from (nullity 'PGjson)
1171+ -> Expression grp commons schemas params from (nullity 'PGjson)
1172rowToJson = unsafeFunction "row_to_json"
1172rowToJson = unsafeFunction "row_to_json"
1174-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1174-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1175-- argument list.
1175-- argument list.
1176jsonBuildArray
1176jsonBuildArray
1177 :: SListI elems
1177 :: SListI elems
1178− => NP (Expression commons schemas params grp from) elems
1178+ => NP (Expression grp commons schemas params from) elems
1179− -> Expression commons schemas params grp from (nullity 'PGjson)
1179+ -> Expression grp commons schemas params from (nullity 'PGjson)
1180jsonBuildArray = unsafeVariadicFunction "json_build_array"
1180jsonBuildArray = unsafeVariadicFunction "json_build_array"
1182-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1182-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1183-- variadic argument list.
1183-- variadic argument list.
1184jsonbBuildArray
1184jsonbBuildArray
1185 :: SListI elems
1185 :: SListI elems
1186− => NP (Expression commons schemas params grp from) elems
1186+ => NP (Expression grp commons schemas params from) elems
1187− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1187+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1188jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1188jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1190unsafeRowFunction
1190unsafeRowFunction
1191 :: All Top elems
1191 :: All Top elems
1192− => NP (Aliased (Expression commons schemas params grp from)) elems
1192+ => NP (Aliased (Expression grp commons schemas params from)) elems
1193 -> [ByteString]
1193 -> [ByteString]
1194unsafeRowFunction =
1194unsafeRowFunction =
1195 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1195 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1204,8 +1204,8 @@ unsafeRowFunction =
1204-- and values.
1204-- and values.
1205jsonBuildObject
1205jsonBuildObject
1206 :: All Top elems
1206 :: All Top elems
1207− => NP (Aliased (Expression commons schemas params grp from)) elems
1207+ => NP (Aliased (Expression grp commons schemas params from)) elems
1208− -> Expression commons schemas params grp from (nullity 'PGjson)
1208+ -> Expression grp commons schemas params from (nullity 'PGjson)
1209jsonBuildObject
1209jsonBuildObject
1210 = unsafeFunction "json_build_object"
1210 = unsafeFunction "json_build_object"
1211 . UnsafeExpression
1211 . UnsafeExpression
@@ -1217,8 +1217,8 @@ jsonBuildObject
1217-- between text and values.
1217-- between text and values.
1218jsonbBuildObject
1218jsonbBuildObject
1219 :: All Top elems
1219 :: All Top elems
1220− => NP (Aliased (Expression commons schemas params grp from)) elems
1220+ => NP (Aliased (Expression grp commons schemas params from)) elems
1221− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1221+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1222jsonbBuildObject
1222jsonbBuildObject
1223 = unsafeFunction "jsonb_build_object"
1223 = unsafeFunction "jsonb_build_object"
1224 . UnsafeExpression
1224 . UnsafeExpression
@@ -1231,8 +1231,8 @@ jsonbBuildObject
1231-- array has exactly two elements, which are taken as a key/value pair.
1231-- array has exactly two elements, which are taken as a key/value pair.
1232jsonObject
1232jsonObject
1233 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1233 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1234− => Expression commons schemas params grp from (nullity arr)
1234+ => Expression grp commons schemas params from (nullity arr)
1235− -> Expression commons schemas params grp from (nullity 'PGjson)
1235+ -> Expression grp commons schemas params from (nullity 'PGjson)
1236jsonObject = unsafeFunction "json_object"
1236jsonObject = unsafeFunction "json_object"
1238-- | Builds a binary JSON object out of a text array. The array must have either
1238-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1241,8 +1241,8 @@ jsonObject = unsafeFunction "json_object"
1241-- array has exactly two elements, which are taken as a key/value pair.
1241-- array has exactly two elements, which are taken as a key/value pair.
1242jsonbObject
1242jsonbObject
1243 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1243 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1244− => Expression commons schemas params grp from (nullity arr)
1244+ => Expression grp commons schemas params from (nullity arr)
1245− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1245+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1246jsonbObject = unsafeFunction "jsonb_object"
1246jsonbObject = unsafeFunction "jsonb_object"
1248-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1248-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1250,9 +1250,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1250jsonZipObject
1250jsonZipObject
1251 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1251 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1252 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1252 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1253− => Expression commons schemas params grp from (nullity keysArray)
1253+ => Expression grp commons schemas params from (nullity keysArray)
1254− -> Expression commons schemas params grp from (nullity valuesArray)
1254+ -> Expression grp commons schemas params from (nullity valuesArray)
1255− -> Expression commons schemas params grp from (nullity 'PGjson)
1255+ -> Expression grp commons schemas params from (nullity 'PGjson)
1256jsonZipObject ks vs =
1256jsonZipObject ks vs =
1257 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1257 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
@@ -1262,9 +1262,9 @@ jsonZipObject ks vs =
1262jsonbZipObject
1262jsonbZipObject
1263 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1263 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1264 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1264 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1265− => Expression commons schemas params grp from (nullity keysArray)
1265+ => Expression grp commons schemas params from (nullity keysArray)
1266− -> Expression commons schemas params grp from (nullity valuesArray)
1266+ -> Expression grp commons schemas params from (nullity valuesArray)
1267− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1267+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1268jsonbZipObject ks vs =
1268jsonbZipObject ks vs =
1269 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1269 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
@@ -1274,23 +1274,23 @@ Table 9.46: JSON processing functions
1275-- | Returns the number of elements in the outermost JSON array.
1275-- | Returns the number of elements in the outermost JSON array.
1276jsonArrayLength
1276jsonArrayLength
1277− :: Expression commons schemas params grp from (nullity 'PGjson)
1277+ :: Expression grp commons schemas params from (nullity 'PGjson)
1278− -> Expression commons schemas params grp from (nullity 'PGint4)
1278+ -> Expression grp commons schemas params from (nullity 'PGint4)
1279jsonArrayLength = unsafeFunction "json_array_length"
1279jsonArrayLength = unsafeFunction "json_array_length"
1281-- | Returns the number of elements in the outermost binary JSON array.
1281-- | Returns the number of elements in the outermost binary JSON array.
1282jsonbArrayLength
1282jsonbArrayLength
1283− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1283+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1284− -> Expression commons schemas params grp from (nullity 'PGint4)
1284+ -> Expression grp commons schemas params from (nullity 'PGint4)
1285jsonbArrayLength = unsafeFunction "jsonb_array_length"
1285jsonbArrayLength = unsafeFunction "jsonb_array_length"
1287-- | Returns JSON value pointed to by the given path (equivalent to #>
1287-- | Returns JSON value pointed to by the given path (equivalent to #>
1288-- operator).
1288-- operator).
1289jsonExtractPath
1289jsonExtractPath
1290 :: SListI elems
1290 :: SListI elems
1291− => Expression commons schemas params grp from (nullity 'PGjson)
1291+ => Expression grp commons schemas params from (nullity 'PGjson)
1292− -> NP (Expression commons schemas params grp from) elems
1292+ -> NP (Expression grp commons schemas params from) elems
1293− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1293+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1294jsonExtractPath x xs =
1294jsonExtractPath x xs =
1295 unsafeVariadicFunction "json_extract_path" (x :* xs)
1295 unsafeVariadicFunction "json_extract_path" (x :* xs)
@@ -1298,9 +1298,9 @@ jsonExtractPath x xs =
1298-- operator).
1298-- operator).
1299jsonbExtractPath
1299jsonbExtractPath
1300 :: SListI elems
1300 :: SListI elems
1301− => Expression commons schemas params grp from (nullity 'PGjsonb)
1301+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1302− -> NP (Expression commons schemas params grp from) elems
1302+ -> NP (Expression grp commons schemas params from) elems
1303− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1303+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1304jsonbExtractPath x xs =
1304jsonbExtractPath x xs =
1305 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1305 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
@@ -1308,9 +1308,9 @@ jsonbExtractPath x xs =
1308-- operator), as text.
1308-- operator), as text.
1309jsonExtractPathAsText
1309jsonExtractPathAsText
1310 :: SListI elems
1310 :: SListI elems
1311− => Expression commons schemas params grp from (nullity 'PGjson)
1311+ => Expression grp commons schemas params from (nullity 'PGjson)
1312− -> NP (Expression commons schemas params grp from) elems
1312+ -> NP (Expression grp commons schemas params from) elems
1313− -> Expression commons schemas params grp from (nullity 'PGjson)
1313+ -> Expression grp commons schemas params from (nullity 'PGjson)
1314jsonExtractPathAsText x xs =
1314jsonExtractPathAsText x xs =
1315 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1315 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
@@ -1318,38 +1318,38 @@ jsonExtractPathAsText x xs =
1318-- operator), as text.
1318-- operator), as text.
1319jsonbExtractPathAsText
1319jsonbExtractPathAsText
1320 :: SListI elems
1320 :: SListI elems
1321− => Expression commons schemas params grp from (nullity 'PGjsonb)
1321+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1322− -> NP (Expression commons schemas params grp from) elems
1322+ -> NP (Expression grp commons schemas params from) elems
1323− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1323+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1324jsonbExtractPathAsText x xs =
1324jsonbExtractPathAsText x xs =
1325 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1325 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1327-- | Returns the type of the outermost JSON value as a text string. Possible
1327-- | Returns the type of the outermost JSON value as a text string. Possible
1328-- types are object, array, string, number, boolean, and null.
1328-- types are object, array, string, number, boolean, and null.
1329jsonTypeof
1329jsonTypeof
1330− :: Expression commons schemas params grp from (nullity 'PGjson)
1330+ :: Expression grp commons schemas params from (nullity 'PGjson)
1331− -> Expression commons schemas params grp from (nullity 'PGtext)
1331+ -> Expression grp commons schemas params from (nullity 'PGtext)
1332jsonTypeof = unsafeFunction "json_typeof"
1332jsonTypeof = unsafeFunction "json_typeof"
1334-- | Returns the type of the outermost binary JSON value as a text string.
1334-- | Returns the type of the outermost binary JSON value as a text string.
1335-- Possible types are object, array, string, number, boolean, and null.
1335-- Possible types are object, array, string, number, boolean, and null.
1336jsonbTypeof
1336jsonbTypeof
1337− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1337+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1338− -> Expression commons schemas params grp from (nullity 'PGtext)
1338+ -> Expression grp commons schemas params from (nullity 'PGtext)
1339jsonbTypeof = unsafeFunction "jsonb_typeof"
1339jsonbTypeof = unsafeFunction "jsonb_typeof"
1341-- | Returns its argument with all object fields that have null values omitted.
1341-- | Returns its argument with all object fields that have null values omitted.
1342-- Other null values are untouched.
1342-- Other null values are untouched.
1343jsonStripNulls
1343jsonStripNulls
1344− :: Expression commons schemas params grp from (nullity 'PGjson)
1344+ :: Expression grp commons schemas params from (nullity 'PGjson)
1345− -> Expression commons schemas params grp from (nullity 'PGjson)
1345+ -> Expression grp commons schemas params from (nullity 'PGjson)
1346jsonStripNulls = unsafeFunction "json_strip_nulls"
1346jsonStripNulls = unsafeFunction "json_strip_nulls"
1348-- | Returns its argument with all object fields that have null values omitted.
1348-- | Returns its argument with all object fields that have null values omitted.
1349-- Other null values are untouched.
1349-- Other null values are untouched.
1350jsonbStripNulls
1350jsonbStripNulls
1351− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1351+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1352− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1352+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1353jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1353jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1355-- | @ jsonbSet target path new_value create_missing @
1355-- | @ jsonbSet target path new_value create_missing @
@@ -1361,11 +1361,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1361-- arrays.
1361-- arrays.
1363 :: PGTextArray "jsonbSet" arr
1363 :: PGTextArray "jsonbSet" arr
1364− => Expression commons schemas params grp from (nullity 'PGjsonb)
1364+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1365− -> Expression commons schemas params grp from (nullity arr)
1365+ -> Expression grp commons schemas params from (nullity arr)
1366− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1366+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1367− -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1367+ -> Maybe (Expression grp commons schemas params from (nullity 'PGbool))
1368− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1368+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1369jsonbSet tgt path val createMissing = case createMissing of
1369jsonbSet tgt path val createMissing = case createMissing of
1370 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1370 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1371 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1371 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1380,19 +1380,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1380-- in path count from the end of JSON arrays.
1380-- in path count from the end of JSON arrays.
1381jsonbInsert
1381jsonbInsert
1382 :: PGTextArray "jsonbInsert" arr
1382 :: PGTextArray "jsonbInsert" arr
1383− => Expression commons schemas params grp from (nullity 'PGjsonb)
1383+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1384− -> Expression commons schemas params grp from (nullity arr)
1384+ -> Expression grp commons schemas params from (nullity arr)
1385− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1385+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1386− -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1386+ -> Maybe (Expression grp commons schemas params from (nullity 'PGbool))
1387− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1387+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1388jsonbInsert tgt path val insertAfter = case insertAfter of
1388jsonbInsert tgt path val insertAfter = case insertAfter of
1389 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1389 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1390 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1390 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1392-- | Returns its argument as indented JSON text.
1392-- | Returns its argument as indented JSON text.
1393jsonbPretty
1393jsonbPretty
1394− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1394+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1395− -> Expression commons schemas params grp from (nullity 'PGtext)
1395+ -> Expression grp commons schemas params from (nullity 'PGtext)
1396jsonbPretty = unsafeFunction "jsonb_pretty"
1396jsonbPretty = unsafeFunction "jsonb_pretty"
1398{-----------------------------------------
1398{-----------------------------------------
@@ -1402,54 +1402,54 @@ aggregation
1402-- | escape hatch to define aggregate functions
1402-- | escape hatch to define aggregate functions
1403unsafeAggregate
1403unsafeAggregate
1404 :: ByteString -- ^ aggregate function
1404 :: ByteString -- ^ aggregate function
1405− -> Expression commons schemas from 'Ungrouped params (xty)
1405+ -> Expression 'Ungrouped commons schemas params from xty
1406− -> Expression commons schemas from ('Grouped bys) params (yty)
1406+ -> Expression ('Grouped bys) commons schemas params from yty
1407unsafeAggregate fun x = UnsafeExpression $ mconcat
1407unsafeAggregate fun x = UnsafeExpression $ mconcat
1408 [fun, "(", renderSQL x, ")"]
1408 [fun, "(", renderSQL x, ")"]
1410-- | escape hatch to define aggregate functions over distinct values
1410-- | escape hatch to define aggregate functions over distinct values
1411unsafeAggregateDistinct
1411unsafeAggregateDistinct
1412 :: ByteString -- ^ aggregate function
1412 :: ByteString -- ^ aggregate function
1413− -> Expression commons schemas from 'Ungrouped params (xty)
1413+ -> Expression 'Ungrouped commons schemas params from xty
1414− -> Expression commons schemas from ('Grouped bys) params (yty)
1414+ -> Expression ('Grouped bys) commons schemas params from yty
1415unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1415unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1416 [fun, "(DISTINCT ", renderSQL x, ")"]
1416 [fun, "(DISTINCT ", renderSQL x, ")"]
1418-- | >>> :{
1418-- | >>> :{
1420−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1420+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1421-- expression = sum_ #col
1421-- expression = sum_ #col
1422-- in printSQL expression
1422-- in printSQL expression
1424-- sum("col")
1424-- sum("col")
1426 :: ty `In` PGNum
1426 :: ty `In` PGNum
1427− => Expression commons schemas from 'Ungrouped params (nullity ty)
1427+ => Expression 'Ungrouped commons schemas params from (nullity ty)
1428 -- ^ what to sum
1428 -- ^ what to sum
1429− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1429+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
1430sum_ = unsafeAggregate "sum"
1430sum_ = unsafeAggregate "sum"
1432-- | >>> :{
1432-- | >>> :{
1434−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1434+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1435-- expression = sumDistinct #col
1435-- expression = sumDistinct #col
1436-- in printSQL expression
1436-- in printSQL expression
1438-- sum(DISTINCT "col")
1438-- sum(DISTINCT "col")
1439sumDistinct
1439sumDistinct
1440 :: ty `In` PGNum
1440 :: ty `In` PGNum
1441− => Expression commons schemas from 'Ungrouped params (nullity ty)
1441+ => Expression 'Ungrouped commons schemas params from (nullity ty)
1442 -- ^ what to sum
1442 -- ^ what to sum
1443− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1443+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
1444sumDistinct = unsafeAggregateDistinct "sum"
1444sumDistinct = unsafeAggregateDistinct "sum"
1446-- | A constraint for `PGType`s that you can take averages of and the resulting
1446-- | A constraint for `PGType`s that you can take averages of and the resulting
1447-- `PGType`.
1447-- `PGType`.
1448class PGAvg ty avg | ty -> avg where
1448class PGAvg ty avg | ty -> avg where
1449 avg, avgDistinct
1449 avg, avgDistinct
1450− :: Expression commons schemas from 'Ungrouped params (nullity ty)
1450+ :: Expression 'Ungrouped commons schemas params from (nullity ty)
1451 -- ^ what to average
1451 -- ^ what to average
1452− -> Expression commons schemas from ('Grouped bys) params (nullity avg)
1452+ -> Expression ('Grouped bys) commons schemas params from (nullity avg)
1453 avg = unsafeAggregate "avg"
1453 avg = unsafeAggregate "avg"
1454 avgDistinct = unsafeAggregateDistinct "avg"
1454 avgDistinct = unsafeAggregateDistinct "avg"
1455instance PGAvg 'PGint2 'PGnumeric
1455instance PGAvg 'PGint2 'PGnumeric
@@ -1469,37 +1469,37 @@ instance PGAvg 'PGinterval 'PGinterval
1469-- bit_and("col")
1469-- bit_and("col")
1471 :: int `In` PGIntegral
1471 :: int `In` PGIntegral
1472− => Expression commons schemas from 'Ungrouped params (nullity int)
1472+ => Expression 'Ungrouped commons schemas params from (nullity int)
1473 -- ^ what to aggregate
1473 -- ^ what to aggregate
1474− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1474+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1475bitAnd = unsafeAggregate "bit_and"
1475bitAnd = unsafeAggregate "bit_and"
1477-- | >>> :{
1477-- | >>> :{
1479−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1479+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1480-- expression = bitOr #col
1480-- expression = bitOr #col
1481-- in printSQL expression
1481-- in printSQL expression
1483-- bit_or("col")
1483-- bit_or("col")
1485 :: int `In` PGIntegral
1485 :: int `In` PGIntegral
1486− => Expression commons schemas from 'Ungrouped params (nullity int)
1486+ => Expression 'Ungrouped commons schemas params from (nullity int)
1487 -- ^ what to aggregate
1487 -- ^ what to aggregate
1488− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1488+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1489bitOr = unsafeAggregate "bit_or"
1489bitOr = unsafeAggregate "bit_or"
1491-- | >>> :{
1491-- | >>> :{
1493−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1493+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1494-- expression = bitAndDistinct #col
1494-- expression = bitAndDistinct #col
1495-- in printSQL expression
1495-- in printSQL expression
1497-- bit_and(DISTINCT "col")
1497-- bit_and(DISTINCT "col")
1498bitAndDistinct
1498bitAndDistinct
1499 :: int `In` PGIntegral
1499 :: int `In` PGIntegral
1500− => Expression commons schemas from 'Ungrouped params (nullity int)
1500+ => Expression 'Ungrouped commons schemas params from (nullity int)
1501 -- ^ what to aggregate
1501 -- ^ what to aggregate
1502− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1502+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1503bitAndDistinct = unsafeAggregateDistinct "bit_and"
1503bitAndDistinct = unsafeAggregateDistinct "bit_and"
1505-- | >>> :{
1505-- | >>> :{
@@ -1511,9 +1511,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
1511-- bit_or(DISTINCT "col")
1511-- bit_or(DISTINCT "col")
1512bitOrDistinct
1512bitOrDistinct
1513 :: int `In` PGIntegral
1513 :: int `In` PGIntegral
1514− => Expression commons schemas from 'Ungrouped params (nullity int)
1514+ => Expression 'Ungrouped commons schemas params from (nullity int)
1515 -- ^ what to aggregate
1515 -- ^ what to aggregate
1516− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1516+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1517bitOrDistinct = unsafeAggregateDistinct "bit_or"
1517bitOrDistinct = unsafeAggregateDistinct "bit_or"
1519-- | >>> :{
1519-- | >>> :{
@@ -1524,9 +1524,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
1525-- bool_and("col")
1525-- bool_and("col")
1527− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1527+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1528 -- ^ what to aggregate
1528 -- ^ what to aggregate
1529− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1529+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1530boolAnd = unsafeAggregate "bool_and"
1530boolAnd = unsafeAggregate "bool_and"
1532-- | >>> :{
1532-- | >>> :{
@@ -1537,9 +1537,9 @@ boolAnd = unsafeAggregate "bool_and"
1538-- bool_or("col")
1538-- bool_or("col")
1540− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1540+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1541 -- ^ what to aggregate
1541 -- ^ what to aggregate
1542− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1542+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1543boolOr = unsafeAggregate "bool_or"
1543boolOr = unsafeAggregate "bool_or"
1545-- | >>> :{
1545-- | >>> :{
@@ -1550,9 +1550,9 @@ boolOr = unsafeAggregate "bool_or"
1551-- bool_and(DISTINCT "col")
1551-- bool_and(DISTINCT "col")
1552boolAndDistinct
1552boolAndDistinct
1553− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1553+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1554 -- ^ what to aggregate
1554 -- ^ what to aggregate
1555− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1555+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1556boolAndDistinct = unsafeAggregateDistinct "bool_and"
1556boolAndDistinct = unsafeAggregateDistinct "bool_and"
1558-- | >>> :{
1558-- | >>> :{
@@ -1563,9 +1563,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
1564-- bool_or(DISTINCT "col")
1564-- bool_or(DISTINCT "col")
1565boolOrDistinct
1565boolOrDistinct
1566− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1566+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1567 -- ^ what to aggregate
1567 -- ^ what to aggregate
1568− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1568+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1569boolOrDistinct = unsafeAggregateDistinct "bool_or"
1569boolOrDistinct = unsafeAggregateDistinct "bool_or"
1571-- | A special aggregation that does not require an input
1571-- | A special aggregation that does not require an input
@@ -1573,7 +1573,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1573-- >>> printSQL countStar
1573-- >>> printSQL countStar
1574-- count(*)
1574-- count(*)
1575countStar
1575countStar
1576− :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1576+ :: Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1577countStar = UnsafeExpression $ "count(*)"
1577countStar = UnsafeExpression $ "count(*)"
1579-- | >>> :{
1579-- | >>> :{
@@ -1584,9 +1584,9 @@ countStar = UnsafeExpression $ "count(*)"
1585-- count("col")
1585-- count("col")
1587− :: Expression commons schemas from 'Ungrouped params ty
1587+ :: Expression 'Ungrouped commons schemas params from ty
1588 -- ^ what to count
1588 -- ^ what to count
1589− -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1589+ -> Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1590count = unsafeAggregate "count"
1590count = unsafeAggregate "count"
1592-- | >>> :{
1592-- | >>> :{
@@ -1597,9 +1597,9 @@ count = unsafeAggregate "count"
1598-- count(DISTINCT "col")
1598-- count(DISTINCT "col")
1599countDistinct
1599countDistinct
1600− :: Expression commons schemas from 'Ungrouped params ty
1600+ :: Expression 'Ungrouped commons schemas params from ty
1601 -- ^ what to count
1601 -- ^ what to count
1602− -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1602+ -> Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1603countDistinct = unsafeAggregateDistinct "count"
1603countDistinct = unsafeAggregateDistinct "count"
1605-- | synonym for `boolAnd`
1605-- | synonym for `boolAnd`
@@ -1612,9 +1612,9 @@ countDistinct = unsafeAggregateDistinct "count"
1613-- every("col")
1613-- every("col")
1615− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1615+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1616 -- ^ what to aggregate
1616 -- ^ what to aggregate
1617− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1617+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1618every = unsafeAggregate "every"
1618every = unsafeAggregate "every"
1620-- | synonym for `boolAndDistinct`
1620-- | synonym for `boolAndDistinct`
@@ -1627,16 +1627,16 @@ every = unsafeAggregate "every"
1628-- every(DISTINCT "col")
1628-- every(DISTINCT "col")
1629everyDistinct
1629everyDistinct
1630− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1630+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1631 -- ^ what to aggregate
1631 -- ^ what to aggregate
1632− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1632+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1633everyDistinct = unsafeAggregateDistinct "every"
1633everyDistinct = unsafeAggregateDistinct "every"
1635-- | minimum and maximum aggregation
1635-- | minimum and maximum aggregation
1636max_, min_, maxDistinct, minDistinct
1636max_, min_, maxDistinct, minDistinct
1637− :: Expression commons schemas from 'Ungrouped params (nullity ty)
1637+ :: Expression 'Ungrouped commons schemas params from (nullity ty)
1638 -- ^ what to aggregate
1638 -- ^ what to aggregate
1639− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1639+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
1640max_ = unsafeAggregate "max"
1640max_ = unsafeAggregate "max"
1641min_ = unsafeAggregate "min"
1641min_ = unsafeAggregate "min"
1642maxDistinct = unsafeAggregateDistinct "max"
1642maxDistinct = unsafeAggregateDistinct "max"
@@ -1822,35 +1822,35 @@ Sorting
1822-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
1822-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
1823-- determine whether nulls appear before or after non-null values in the sort
1823-- determine whether nulls appear before or after non-null values in the sort
1824-- ordering of a `Null` result column.
1824-- ordering of a `Null` result column.
1825−data SortExpression commons schemas params grp from where
1825+data SortExpression grp commons schemas params from where
1827− :: Expression commons schemas params grp from ('NotNull ty)
1827+ :: Expression grp commons schemas params from ('NotNull ty)
1828− -> SortExpression commons schemas params grp from
1828+ -> SortExpression grp commons schemas params from
1830− :: Expression commons schemas params grp from ('NotNull ty)
1830+ :: Expression grp commons schemas params from ('NotNull ty)
1831− -> SortExpression commons schemas params grp from
1831+ -> SortExpression grp commons schemas params from
1832 AscNullsFirst
1832 AscNullsFirst
1833− :: Expression commons schemas params grp from ('Null ty)
1833+ :: Expression grp commons schemas params from ('Null ty)
1834− -> SortExpression commons schemas params grp from
1834+ -> SortExpression grp commons schemas params from
1835 AscNullsLast
1835 AscNullsLast
1836− :: Expression commons schemas params grp from ('Null ty)
1836+ :: Expression grp commons schemas params from ('Null ty)
1837− -> SortExpression commons schemas params grp from
1837+ -> SortExpression grp commons schemas params from
1838 DescNullsFirst
1838 DescNullsFirst
1839− :: Expression commons schemas params grp from ('Null ty)
1839+ :: Expression grp commons schemas params from ('Null ty)
1840− -> SortExpression commons schemas params grp from
1840+ -> SortExpression grp commons schemas params from
1841 DescNullsLast
1841 DescNullsLast
1842− :: Expression commons schemas params grp from ('Null ty)
1842+ :: Expression grp commons schemas params from ('Null ty)
1843− -> SortExpression commons schemas params grp from
1843+ -> SortExpression grp commons schemas params from
1844−deriving instance Show (SortExpression commons schemas params grp from)
1844+deriving instance Show (SortExpression grp commons schemas params from)
1846class OrderBy expr where
1846class OrderBy expr where
1848− :: [SortExpression commons schemas params grp from]
1848+ :: [SortExpression grp commons schemas params from]
1849− -> expr commons schemas params grp from
1849+ -> expr grp commons schemas params from
1850− -> expr commons schemas params grp from
1850+ -> expr grp commons schemas params from
1852-- | Render a `SortExpression`.
1852-- | Render a `SortExpression`.
1853−instance RenderSQL (SortExpression commons schemas params grp from) where
1853+instance RenderSQL (SortExpression grp commons schemas params from) where
1854 renderSQL = \case
1854 renderSQL = \case
1855 Asc expression -> renderSQL expression <+> "ASC"
1855 Asc expression -> renderSQL expression <+> "ASC"
1856 Desc expression -> renderSQL expression <+> "DESC"
1856 Desc expression -> renderSQL expression <+> "DESC"
@@ -1861,12 +1861,12 @@ instance RenderSQL (SortExpression commons schemas params grp from) where
1861 AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
1861 AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
1862 DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
1862 DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
1864−data WindowDefinition commons schemas params grp from where
1864+data WindowDefinition grp commons schemas params from where
1865 WindowDefinition
1865 WindowDefinition
1866 :: SListI bys
1866 :: SListI bys
1867− => NP (Expression commons schemas params grp from) bys
1867+ => NP (Expression grp commons schemas params from) bys
1868− -> [SortExpression commons schemas params grp from]
1868+ -> [SortExpression grp commons schemas params from]
1869− -> WindowDefinition commons schemas params grp from
1869+ -> WindowDefinition grp commons schemas params from
1871instance OrderBy WindowDefinition where
1871instance OrderBy WindowDefinition where
1872 orderBy sortsR (WindowDefinition parts sortsL)
1872 orderBy sortsR (WindowDefinition parts sortsL)
@@ -1886,49 +1886,49 @@ instance RenderSQL (WindowDefinition commons schemas from grp params) where
1887partitionBy
1887partitionBy
1888 :: SListI bys
1888 :: SListI bys
1889− => NP (Expression commons schemas params grp from) bys
1889+ => NP (Expression grp commons schemas params from) bys
1890− -> WindowDefinition commons schemas params grp from
1890+ -> WindowDefinition grp commons schemas params from
1891partitionBy bys = WindowDefinition bys []
1891partitionBy bys = WindowDefinition bys []
1893newtype WindowFunction
1893newtype WindowFunction
1894 (commons :: FromType)
1895 (commons :: FromType)
1895 (schemas :: SchemasType)
1896 (schemas :: SchemasType)
1896 (params :: [NullityType])
1897 (params :: [NullityType])
1898 (from :: FromType)
1898 (from :: FromType)
1899 (ty :: NullityType)
1899 (ty :: NullityType)
1900 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
1900 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
1901 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1901 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1903−instance RenderSQL (WindowFunction commons schemas params grp from ty) where
1903+instance RenderSQL (WindowFunction grp commons schemas params from ty) where
1904 renderSQL = renderWindowFunction
1904 renderSQL = renderWindowFunction
1906{- | rank of the current row with gaps; same as `rowNumber` of its first peer
1906{- | rank of the current row with gaps; same as `rowNumber` of its first peer
1907>>> printSQL rank
1907>>> printSQL rank
1910−rank :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1910+rank :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
1911rank = UnsafeWindowFunction "rank()"
1911rank = UnsafeWindowFunction "rank()"
1913{- | number of the current row within its partition, counting from 1
1913{- | number of the current row within its partition, counting from 1
1914>>> printSQL rowNumber
1914>>> printSQL rowNumber
1915row_number()
1915row_number()
1917−rowNumber :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1917+rowNumber :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
1918rowNumber = UnsafeWindowFunction "row_number()"
1918rowNumber = UnsafeWindowFunction "row_number()"
1920{- | rank of the current row without gaps; this function counts peer groups
1920{- | rank of the current row without gaps; this function counts peer groups
1921>>> printSQL denseRank
1921>>> printSQL denseRank
1922dense_rank()
1922dense_rank()
1924−denseRank :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1924+denseRank :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
1925denseRank = UnsafeWindowFunction "dense_rank()"
1925denseRank = UnsafeWindowFunction "dense_rank()"
1927{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
1927{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
1928>>> printSQL percentRank
1928>>> printSQL percentRank
1929percent_rank()
1929percent_rank()
1931−percentRank :: WindowFunction commons schemas from grp params ('NotNull 'PGfloat8)
1931+percentRank :: WindowFunction grp commons schemas params from ('NotNull 'PGfloat8)
1932percentRank = UnsafeWindowFunction "percent_rank()"
1932percentRank = UnsafeWindowFunction "percent_rank()"
1934{- | cumulative distribution: (number of partition rows
1934{- | cumulative distribution: (number of partition rows
@@ -1936,16 +1936,16 @@ preceding or peer with current row) / total partition rows
1936>>> printSQL cumeDist
1936>>> printSQL cumeDist
1937cume_dist()
1937cume_dist()
1939−cumeDist :: WindowFunction commons schemas from grp params ('NotNull 'PGfloat8)
1939+cumeDist :: WindowFunction grp commons schemas params from ('NotNull 'PGfloat8)
1940cumeDist = UnsafeWindowFunction "cume_dist()"
1940cumeDist = UnsafeWindowFunction "cume_dist()"
1942{- | integer ranging from 1 to the argument value,
1942{- | integer ranging from 1 to the argument value,
1943dividing the partition as equally as possible
1943dividing the partition as equally as possible
1946− :: Expression commons schemas from grp params ('NotNull 'PGint4)
1946+ :: Expression grp commons schemas params from ('NotNull 'PGint4)
1947 -- ^ numuckets
1947 -- ^ numuckets
1948− -> WindowFunction commons schemas from grp params ('NotNull 'PGint4)
1948+ -> WindowFunction grp commons schemas params from ('NotNull 'PGint4)
1949ntile numBuckets = UnsafeWindowFunction $ "ntile"
1949ntile numBuckets = UnsafeWindowFunction $ "ntile"
1950 <> parenthesized (renderSQL numBuckets)
1950 <> parenthesized (renderSQL numBuckets)
@@ -1955,13 +1955,13 @@ row within the partition; if there is no such row, instead return default
1955evaluated with respect to the current row.
1955evaluated with respect to the current row.
1958− :: Expression commons schemas from grp params ty
1958+ :: Expression grp commons schemas params from ty
1959 -- ^ value
1959 -- ^ value
1960− -> Expression commons schemas from grp params ('NotNull 'PGint4)
1960+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
1961 -- ^ offset
1961 -- ^ offset
1962− -> Expression commons schemas from grp params ty
1962+ -> Expression grp commons schemas params from ty
1963 -- ^ default
1963 -- ^ default
1964− -> WindowFunction commons schemas from grp params ty
1964+ -> WindowFunction grp commons schemas params from ty
1965lag value offset def = UnsafeWindowFunction $ "lag"
1965lag value offset def = UnsafeWindowFunction $ "lag"
1966 <> parenthesized
1966 <> parenthesized
1967 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
1967 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
@@ -1972,13 +1972,13 @@ row within the partition; if there is no such row, instead return default
1972evaluated with respect to the current row.
1972evaluated with respect to the current row.
1975− :: Expression commons schemas from grp params ty
1975+ :: Expression grp commons schemas params from ty
1976 -- ^ value
1976 -- ^ value
1977− -> Expression commons schemas from grp params ('NotNull 'PGint4)
1977+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
1978 -- ^ offset
1978 -- ^ offset
1979− -> Expression commons schemas from grp params ty
1979+ -> Expression grp commons schemas params from ty
1980 -- ^ default
1980 -- ^ default
1981− -> WindowFunction commons schemas from grp params ty
1981+ -> WindowFunction grp commons schemas params from ty
1982lead value offset def = UnsafeWindowFunction $ "lag"
1982lead value offset def = UnsafeWindowFunction $ "lag"
1983 <> parenthesized
1983 <> parenthesized
1984 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
1984 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
@@ -1987,9 +1987,9 @@ lead value offset def = UnsafeWindowFunction $ "lag"
1987first row of the window frame
1987first row of the window frame
1989firstValue
1989firstValue
1990− :: Expression commons schemas from grp params ty
1990+ :: Expression grp commons schemas params from ty
1991 -- ^ value
1991 -- ^ value
1992− -> WindowFunction commons schemas from grp params ty
1992+ -> WindowFunction grp commons schemas params from ty
1993firstValue value = UnsafeWindowFunction $ "first_value"
1993firstValue value = UnsafeWindowFunction $ "first_value"
1994 <> parenthesized (renderSQL value)
1994 <> parenthesized (renderSQL value)
@@ -1997,9 +1997,9 @@ firstValue value = UnsafeWindowFunction $ "first_value"
1997last row of the window frame
1997last row of the window frame
1999lastValue
1999lastValue
2000− :: Expression commons schemas from grp params ty
2000+ :: Expression grp commons schemas params from ty
2001 -- ^ value
2001 -- ^ value
2002− -> WindowFunction commons schemas from grp params ty
2002+ -> WindowFunction grp commons schemas params from ty
2003lastValue value = UnsafeWindowFunction $ "last_value"
2003lastValue value = UnsafeWindowFunction $ "last_value"
2004 <> parenthesized (renderSQL value)
2004 <> parenthesized (renderSQL value)
@@ -2007,10 +2007,10 @@ lastValue value = UnsafeWindowFunction $ "last_value"
2007row of the window frame (counting from 1); null if no such row
2007row of the window frame (counting from 1); null if no such row
2010− :: Expression commons schemas from grp params (nullity ty)
2010+ :: Expression grp commons schemas params from (nullity ty)
2011 -- ^ value
2011 -- ^ value
2012− -> Expression commons schemas from grp params ('NotNull 'PGint4)
2012+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
2013 -- ^ nth
2013 -- ^ nth
2014− -> WindowFunction commons schemas from grp params ('Null ty)
2014+ -> WindowFunction grp commons schemas params from ('Null ty)
2015nthValue value nth = UnsafeWindowFunction $ "nth_value"
2015nthValue value nth = UnsafeWindowFunction $ "nth_value"
2016 <> parenthesized (commaSeparated [renderSQL value, renderSQL nth])
2016 <> parenthesized (commaSeparated [renderSQL value, renderSQL nth])