@@ -293,15 +293,15 @@ and other operations.
294newtype Expression
294newtype Expression
295 (outer :: FromType)
295 (outer :: FromType)
297 (commons :: FromType)
296 (commons :: FromType)
298 (schemas :: SchemasType)
298 (schemas :: SchemasType)
299 (params :: [NullityType])
299 (params :: [NullityType])
300 (from :: FromType)
300 (from :: FromType)
301 (ty :: NullityType)
301 (ty :: NullityType)
302 = UnsafeExpression { renderExpression :: ByteString }
302 = UnsafeExpression { renderExpression :: ByteString }
303 deriving (GHC.Generic,Show,Eq,Ord,NFData)
303 deriving (GHC.Generic,Show,Eq,Ord,NFData)
304−instance RenderSQL (Expression outer grp commons schemas params from ty) where
304+instance RenderSQL (Expression outer commons grp schemas params from ty) where
305 renderSQL = renderExpression
305 renderSQL = renderExpression
307-- | An `Expr` is a closed `Expression`.
307-- | An `Expr` is a closed `Expression`.
@@ -311,18 +311,18 @@ instance RenderSQL (Expression outer grp commons schemas params from ty) where
311-- or alias references. It can be used as
311-- or alias references. It can be used as
312-- a simple piece of more complex `Expression`s.
312-- a simple piece of more complex `Expression`s.
313type Expr x
313type Expr x
314− = forall outer grp commons schemas params from
314+ = forall outer commons grp schemas params from
315− . Expression outer grp commons schemas params from x
315+ . Expression outer commons grp schemas params from x
316 -- ^ cannot reference aliases
316 -- ^ cannot reference aliases
318-- | A `RankNType` for binary operators.
318-- | A `RankNType` for binary operators.
319type Operator x1 x2 y
319type Operator x1 x2 y
320− = forall outer grp commons schemas params from
320+ = forall outer commons grp schemas params from
321− . Expression outer grp commons schemas params from x1
321+ . Expression outer commons grp schemas params from x1
322 -- ^ left input
322 -- ^ left input
323− -> Expression outer grp commons schemas params from x2
323+ -> Expression outer commons grp schemas params from x2
324 -- ^ right input
324 -- ^ right input
325− -> Expression outer grp commons schemas params from y
325+ -> Expression outer commons grp schemas params from y
326 -- ^ output
326 -- ^ output
328-- | A `RankNType` for functions with a single argument.
328-- | A `RankNType` for functions with a single argument.
@@ -331,10 +331,10 @@ type Operator x1 x2 y
331-- indeed a subcategory as it is closed under the usual
331-- indeed a subcategory as it is closed under the usual
332-- `Prelude..` and `Prelude.id`.
332-- `Prelude..` and `Prelude.id`.
333type (:-->) x y
333type (:-->) x y
334− = forall outer grp commons schemas params from
334+ = forall outer commons grp schemas params from
335− . Expression outer grp commons schemas params from x
335+ . Expression outer commons grp schemas params from x
336 -- ^ input
336 -- ^ input
337− -> Expression outer grp commons schemas params from y
337+ -> Expression outer commons grp schemas params from y
338 -- ^ output
338 -- ^ output
340{- | A `RankNType` for functions with a fixed-length list of heterogeneous arguments.
340{- | A `RankNType` for functions with a fixed-length list of heterogeneous arguments.
@@ -344,22 +344,22 @@ Use the `*:` operator to end your argument lists, like so.
344fun(TRUE, FALSE, LOCALTIME, TRUE)
344fun(TRUE, FALSE, LOCALTIME, TRUE)
346type FunctionHet xs y
346type FunctionHet xs y
347− = forall outer grp commons schemas params from
347+ = forall outer commons grp schemas params from
348− . NP (Expression outer grp commons schemas params from) xs
348+ . NP (Expression outer commons grp schemas params from) xs
349 -- ^ inputs
349 -- ^ inputs
350− -> Expression outer grp commons schemas params from y
350+ -> Expression outer commons grp schemas params from y
351 -- ^ output
351 -- ^ output
353{- | A `RankNType` for functions with a variable-length list of
353{- | A `RankNType` for functions with a variable-length list of
354homogeneous arguments and at least 1 more argument.
354homogeneous arguments and at least 1 more argument.
356type FunctionHom x0 x1 y
356type FunctionHom x0 x1 y
357− = forall outer grp commons schemas params from
357+ = forall outer commons grp schemas params from
358− . [Expression outer grp commons schemas params from x0]
358+ . [Expression outer commons grp schemas params from x0]
359 -- ^ inputs
359 -- ^ inputs
360− -> Expression outer grp commons schemas params from x1
360+ -> Expression outer commons grp schemas params from x1
361 -- ^ must have at least 1 input
361 -- ^ must have at least 1 input
362− -> Expression outer grp commons schemas params from y
362+ -> Expression outer commons grp schemas params from y
363 -- ^ output
363 -- ^ output
365{- | >>> printSQL (unsafeFunctionHom "greatest" [true, null_] false)
365{- | >>> printSQL (unsafeFunctionHom "greatest" [true, null_] false)
@@ -384,12 +384,12 @@ class KnownNat n => HasParameter
384 | n params -> ty where
384 | n params -> ty where
385 -- | `parameter` takes a `Nat` using type application and a `TypeExpression`.
385 -- | `parameter` takes a `Nat` using type application and a `TypeExpression`.
387− -- >>> let expr = parameter @1 int4 :: Expression outer grp '[] schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
387+ -- >>> let expr = parameter @1 int4 :: Expression outer '[] grp schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
388 -- >>> printSQL expr
388 -- >>> printSQL expr
389 -- ($1 :: int4)
389 -- ($1 :: int4)
390 parameter
390 parameter
391 :: TypeExpression schemas ty
391 :: TypeExpression schemas ty
392− -> Expression outer grp commons schemas params from ty
392+ -> Expression outer commons grp schemas params from ty
393 parameter ty = UnsafeExpression $ parenthesized $
393 parameter ty = UnsafeExpression $ parenthesized $
394 "$" <> renderNat @n <+> "::"
394 "$" <> renderNat @n <+> "::"
395 <+> renderSQL ty
395 <+> renderSQL ty
@@ -400,44 +400,44 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
400-- | `param` takes a `Nat` using type application and for basic types,
400-- | `param` takes a `Nat` using type application and for basic types,
401-- infers a `TypeExpression`.
401-- infers a `TypeExpression`.
403−-- >>> let expr = param @1 :: Expression outer grp commons schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
403+-- >>> let expr = param @1 :: Expression outer commons grp schemas '[ 'Null 'PGint4] from ('Null 'PGint4)
404-- >>> printSQL expr
404-- >>> printSQL expr
405-- ($1 :: int4)
405-- ($1 :: int4)
407 :: forall n outer commons schemas params from grp ty
407 :: forall n outer commons schemas params from grp ty
408 . (PGTyped schemas ty, HasParameter n params ty)
408 . (PGTyped schemas ty, HasParameter n params ty)
409− => Expression outer grp commons schemas params from ty -- ^ param
409+ => Expression outer commons grp schemas params from ty -- ^ param
410param = parameter @n (pgtype @schemas)
410param = parameter @n (pgtype @schemas)
412instance (HasUnique tab (Join outer from) row, Has col row ty)
412instance (HasUnique tab (Join outer from) row, Has col row ty)
413− => IsLabel col (Expression outer 'Ungrouped commons schemas params from ty) where
413+ => IsLabel col (Expression outer commons 'Ungrouped schemas params from ty) where
414 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
414 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
415instance (HasUnique tab (Join outer from) row, Has col row ty, tys ~ '[ty])
415instance (HasUnique tab (Join outer from) row, Has col row ty, tys ~ '[ty])
416− => IsLabel col (NP (Expression outer 'Ungrouped commons schemas params from) tys) where
416+ => IsLabel col (NP (Expression outer commons 'Ungrouped schemas params from) tys) where
417 fromLabel = fromLabel @col :* Nil
417 fromLabel = fromLabel @col :* Nil
418instance (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty))
418instance (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty))
419 => IsLabel col
419 => IsLabel col
420− (Aliased (Expression outer 'Ungrouped commons schemas params from) column) where
420+ (Aliased (Expression outer commons 'Ungrouped schemas params from) column) where
421 fromLabel = fromLabel @col `As` Alias
421 fromLabel = fromLabel @col `As` Alias
422instance (HasUnique tab (Join outer from) row, Has col row ty, columns ~ '[col ::: ty])
422instance (HasUnique tab (Join outer from) row, Has col row ty, columns ~ '[col ::: ty])
423 => IsLabel col
423 => IsLabel col
424− (NP (Aliased (Expression outer 'Ungrouped commons schemas params from)) columns) where
424+ (NP (Aliased (Expression outer commons 'Ungrouped schemas params from)) columns) where
425 fromLabel = fromLabel @col :* Nil
425 fromLabel = fromLabel @col :* Nil
427instance (Has tab (Join outer from) row, Has col row ty)
427instance (Has tab (Join outer from) row, Has col row ty)
428− => IsQualified tab col (Expression outer 'Ungrouped commons schemas params from ty) where
428+ => IsQualified tab col (Expression outer commons 'Ungrouped schemas params from ty) where
429 tab ! col = UnsafeExpression $
429 tab ! col = UnsafeExpression $
430 renderSQL tab <> "." <> renderSQL col
430 renderSQL tab <> "." <> renderSQL col
431instance (Has tab (Join outer from) row, Has col row ty, tys ~ '[ty])
431instance (Has tab (Join outer from) row, Has col row ty, tys ~ '[ty])
432− => IsQualified tab col (NP (Expression outer 'Ungrouped commons schemas params from) tys) where
432+ => IsQualified tab col (NP (Expression outer commons 'Ungrouped schemas params from) tys) where
433 tab ! col = tab ! col :* Nil
433 tab ! col = tab ! col :* Nil
434instance (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty))
434instance (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty))
435 => IsQualified tab col
435 => IsQualified tab col
436− (Aliased (Expression outer 'Ungrouped commons schemas params from) column) where
436+ (Aliased (Expression outer commons 'Ungrouped schemas params from) column) where
437 tab ! col = tab ! col `As` col
437 tab ! col = tab ! col `As` col
438instance (Has tab (Join outer from) row, Has col row ty, columns ~ '[col ::: ty])
438instance (Has tab (Join outer from) row, Has col row ty, columns ~ '[col ::: ty])
439 => IsQualified tab col
439 => IsQualified tab col
440− (NP (Aliased (Expression outer 'Ungrouped commons schemas params from)) columns) where
440+ (NP (Aliased (Expression outer commons 'Ungrouped schemas params from)) columns) where
441 tab ! col = tab ! col :* Nil
441 tab ! col = tab ! col :* Nil
@@ -445,7 +445,7 @@ instance
445 , Has col row ty
445 , Has col row ty
446 , GroupedBy tab col bys
446 , GroupedBy tab col bys
447 ) => IsLabel col
447 ) => IsLabel col
448− (Expression outer ('Grouped bys) commons schemas params from ty) where
448+ (Expression outer commons ('Grouped bys) schemas params from ty) where
449 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
449 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
451 ( HasUnique tab (Join outer from) row
451 ( HasUnique tab (Join outer from) row
@@ -453,7 +453,7 @@ instance
453 , GroupedBy tab col bys
453 , GroupedBy tab col bys
454 , tys ~ '[ty]
454 , tys ~ '[ty]
455 ) => IsLabel col
455 ) => IsLabel col
456− (NP (Expression outer ('Grouped bys) commons schemas params from) tys) where
456+ (NP (Expression outer commons ('Grouped bys) schemas params from) tys) where
457 fromLabel = fromLabel @col :* Nil
457 fromLabel = fromLabel @col :* Nil
459 ( HasUnique tab (Join outer from) row
459 ( HasUnique tab (Join outer from) row
@@ -461,7 +461,7 @@ instance
461 , GroupedBy tab col bys
461 , GroupedBy tab col bys
462 , column ~ (col ::: ty)
462 , column ~ (col ::: ty)
463 ) => IsLabel col
463 ) => IsLabel col
464− (Aliased (Expression outer ('Grouped bys) commons schemas params from) column) where
464+ (Aliased (Expression outer commons ('Grouped bys) schemas params from) column) where
465 fromLabel = fromLabel @col `As` Alias
465 fromLabel = fromLabel @col `As` Alias
467 ( HasUnique tab (Join outer from) row
467 ( HasUnique tab (Join outer from) row
@@ -469,7 +469,7 @@ instance
469 , GroupedBy tab col bys
469 , GroupedBy tab col bys
470 , columns ~ '[col ::: ty]
470 , columns ~ '[col ::: ty]
471 ) => IsLabel col
471 ) => IsLabel col
472− (NP (Aliased (Expression outer ('Grouped bys) commons schemas params from)) columns) where
472+ (NP (Aliased (Expression outer commons ('Grouped bys) schemas params from)) columns) where
473 fromLabel = fromLabel @col :* Nil
473 fromLabel = fromLabel @col :* Nil
@@ -477,7 +477,7 @@ instance
477 , Has col row ty
477 , Has col row ty
478 , GroupedBy tab col bys
478 , GroupedBy tab col bys
479 ) => IsQualified tab col
479 ) => IsQualified tab col
480− (Expression outer ('Grouped bys) commons schemas params from ty) where
480+ (Expression outer commons ('Grouped bys) schemas params from ty) where
481 tab ! col = UnsafeExpression $
481 tab ! col = UnsafeExpression $
482 renderSQL tab <> "." <> renderSQL col
482 renderSQL tab <> "." <> renderSQL col
@@ -486,7 +486,7 @@ instance
486 , GroupedBy tab col bys
486 , GroupedBy tab col bys
487 , tys ~ '[ty]
487 , tys ~ '[ty]
488 ) => IsQualified tab col
488 ) => IsQualified tab col
489− (NP (Expression outer ('Grouped bys) commons schemas params from) tys) where
489+ (NP (Expression outer commons ('Grouped bys) schemas params from) tys) where
490 tab ! col = tab ! col :* Nil
490 tab ! col = tab ! col :* Nil
492 ( Has tab (Join outer from) row
492 ( Has tab (Join outer from) row
@@ -494,7 +494,7 @@ instance
494 , GroupedBy tab col bys
494 , GroupedBy tab col bys
495 , column ~ (col ::: ty)
495 , column ~ (col ::: ty)
496 ) => IsQualified tab col
496 ) => IsQualified tab col
497− (Aliased (Expression outer ('Grouped bys) commons schemas params from) column) where
497+ (Aliased (Expression outer commons ('Grouped bys) schemas params from) column) where
498 tab ! col = tab ! col `As` col
498 tab ! col = tab ! col `As` col
500 ( Has tab (Join outer from) row
500 ( Has tab (Join outer from) row
@@ -502,7 +502,7 @@ instance
502 , GroupedBy tab col bys
502 , GroupedBy tab col bys
503 , columns ~ '[col ::: ty]
503 , columns ~ '[col ::: ty]
504 ) => IsQualified tab col
504 ) => IsQualified tab col
505− (NP (Aliased (Expression outer ('Grouped bys) commons schemas params from)) columns) where
505+ (NP (Aliased (Expression outer commons ('Grouped bys) schemas params from)) columns) where
506 tab ! col = tab ! col :* Nil
506 tab ! col = tab ! col :* Nil
508-- | analagous to `Nothing`
508-- | analagous to `Nothing`
@@ -533,10 +533,10 @@ coalesce nullxs notNullx = UnsafeExpression $
533-- >>> printSQL $ fromNull true null_
533-- >>> printSQL $ fromNull true null_
534-- COALESCE(NULL, TRUE)
534-- COALESCE(NULL, TRUE)
536− :: Expression outer grp commons schemas params from ('NotNull ty)
536+ :: Expression outer commons grp schemas params from ('NotNull ty)
537 -- ^ what to convert @NULL@ to
537 -- ^ what to convert @NULL@ to
538− -> Expression outer grp commons schemas params from ('Null ty)
538+ -> Expression outer commons grp schemas params from ('Null ty)
539− -> Expression outer grp commons schemas params from ('NotNull ty)
539+ -> Expression outer commons grp schemas params from ('NotNull ty)
540fromNull notNullx nullx = coalesce [nullx] notNullx
540fromNull notNullx nullx = coalesce [nullx] notNullx
542-- | >>> printSQL $ null_ & isNull
542-- | >>> printSQL $ null_ & isNull
@@ -554,13 +554,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
554-- >>> printSQL $ matchNull true not_ null_
554-- >>> printSQL $ matchNull true not_ null_
555-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
555-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
557− :: Expression outer grp commons schemas params from (nullty)
557+ :: Expression outer commons grp schemas params from (nullty)
558 -- ^ what to convert @NULL@ to
558 -- ^ what to convert @NULL@ to
559− -> ( Expression outer grp commons schemas params from ('NotNull ty)
559+ -> ( Expression outer commons grp schemas params from ('NotNull ty)
560− -> Expression outer grp commons schemas params from (nullty) )
560+ -> Expression outer commons grp schemas params from (nullty) )
561 -- ^ function to perform when @NULL@ is absent
561 -- ^ function to perform when @NULL@ is absent
562− -> Expression outer grp commons schemas params from ('Null ty)
562+ -> Expression outer commons grp schemas params from ('Null ty)
563− -> Expression outer grp commons schemas params from (nullty)
563+ -> Expression outer commons grp schemas params from (nullty)
564matchNull y f x = ifThenElse (isNull x) y
564matchNull y f x = ifThenElse (isNull x) y
565 (f (UnsafeExpression (renderSQL x)))
565 (f (UnsafeExpression (renderSQL x)))
@@ -568,7 +568,7 @@ matchNull y f x = ifThenElse (isNull x) y
568`nullIf` gives @NULL@.
568`nullIf` gives @NULL@.
570>>> :set -XTypeApplications -XDataKinds
570>>> :set -XTypeApplications -XDataKinds
571−>>> let expr = nullIf (false *: param @1) :: Expression outer grp commons schemas '[ 'NotNull 'PGbool] from ('Null 'PGbool)
571+>>> let expr = nullIf (false *: param @1) :: Expression outer commons grp schemas '[ 'NotNull 'PGbool] from ('Null 'PGbool)
572>>> printSQL expr
572>>> printSQL expr
573NULLIF(FALSE, ($1 :: bool))
573NULLIF(FALSE, ($1 :: bool))
@@ -578,9 +578,9 @@ nullIf = unsafeFunctionHet "NULLIF"
578-- | >>> printSQL $ array [null_, false, true]
578-- | >>> printSQL $ array [null_, false, true]
579-- ARRAY[NULL, FALSE, TRUE]
579-- ARRAY[NULL, FALSE, TRUE]
581− :: [Expression outer grp commons schemas params from ty]
581+ :: [Expression outer commons grp schemas params from ty]
582 -- ^ array elements
582 -- ^ array elements
583− -> Expression outer grp commons schemas params from (null ('PGvararray ty))
583+ -> Expression outer commons grp schemas params from (null ('PGvararray ty))
584array xs = UnsafeExpression $ "ARRAY" <>
584array xs = UnsafeExpression $ "ARRAY" <>
585 bracketed (commaSeparated (renderSQL <$> xs))
585 bracketed (commaSeparated (renderSQL <$> xs))
@@ -593,8 +593,8 @@ ARRAY[NULL, FALSE, TRUE]
593array1 (null_ :* false *: true)
593array1 (null_ :* false *: true)
594 :: Expression
594 :: Expression
@@ -602,8 +602,8 @@ array1 (null_ :* false *: true)
604 :: (n ~ Length tys, SOP.All ((~) ty) tys)
604 :: (n ~ Length tys, SOP.All ((~) ty) tys)
605− => NP (Expression outer grp commons schemas params from) tys
605+ => NP (Expression outer commons grp schemas params from) tys
606− -> Expression outer grp commons schemas params from (null ('PGfixarray '[n] ty))
606+ -> Expression outer commons grp schemas params from (null ('PGfixarray '[n] ty))
607array1 xs = UnsafeExpression $ "ARRAY" <>
607array1 xs = UnsafeExpression $ "ARRAY" <>
608 bracketed (renderCommaSeparated renderSQL xs)
608 bracketed (renderCommaSeparated renderSQL xs)
@@ -616,8 +616,8 @@ ARRAY[[NULL, FALSE, TRUE], [FALSE, NULL, TRUE]]
616array2 ((null_ :* false *: true) *: (false :* null_ *: true))
616array2 ((null_ :* false *: true) *: (false :* null_ *: true))
617 :: Expression
617 :: Expression
@@ -629,8 +629,8 @@ array2
629 , Length tyss ~ n1
629 , Length tyss ~ n1
630 , SOP.All ((~) ty) tys
630 , SOP.All ((~) ty) tys
631 , Length tys ~ n2 )
631 , Length tys ~ n2 )
632− => NP (NP (Expression outer grp commons schemas params from)) tyss
632+ => NP (NP (Expression outer commons grp schemas params from)) tyss
633− -> Expression outer grp commons schemas params from (null ('PGfixarray '[n1,n2] ty))
633+ -> Expression outer commons grp schemas params from (null ('PGfixarray '[n1,n2] ty))
634array2 xss = UnsafeExpression $ "ARRAY" <>
634array2 xss = UnsafeExpression $ "ARRAY" <>
635 bracketed (renderCommaSeparatedConstraint @SOP.SListI (bracketed . renderCommaSeparated renderSQL) xss)
635 bracketed (renderCommaSeparatedConstraint @SOP.SListI (bracketed . renderCommaSeparated renderSQL) xss)
@@ -648,7 +648,7 @@ index n expr = UnsafeExpression $
648 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
648 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
650instance (KnownSymbol label, label `In` labels) => IsPGlabel label
650instance (KnownSymbol label, label `In` labels) => IsPGlabel label
651− (Expression outer grp commons schemas params from (null ('PGenum labels))) where
651+ (Expression outer commons grp schemas params from (null ('PGenum labels))) where
652 label = UnsafeExpression $ renderSQL (PGlabel @label)
652 label = UnsafeExpression $ renderSQL (PGlabel @label)
654-- | A row constructor is an expression that builds a row value
654-- | A row constructor is an expression that builds a row value
@@ -660,14 +660,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
660-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
660-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
663−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer grp commons schemas params from ('NotNull Complex)
663+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer commons grp schemas params from ('NotNull Complex)
664-- >>> printSQL i
664-- >>> printSQL i
665-- ROW(0, 1)
665-- ROW(0, 1)
667 :: SListI row
667 :: SListI row
668− => NP (Aliased (Expression outer grp commons schemas params from)) row
668+ => NP (Aliased (Expression outer commons grp schemas params from)) row
669 -- ^ zero or more expressions for the row field values
669 -- ^ zero or more expressions for the row field values
670− -> Expression outer grp commons schemas params from (null ('PGcomposite row))
670+ -> Expression outer commons grp schemas params from (null ('PGcomposite row))
671row exprs = UnsafeExpression $ "ROW" <> parenthesized
671row exprs = UnsafeExpression $ "ROW" <> parenthesized
672 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
672 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
@@ -678,7 +678,7 @@ row exprs = UnsafeExpression $ "ROW" <> parenthesized
678-- type Schema = '["complex" ::: 'Typedef Complex]
678-- type Schema = '["complex" ::: 'Typedef Complex]
681−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer grp '[] (Public Schema) from params ('NotNull Complex)
681+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression outer '[] grp (Public Schema) from params ('NotNull Complex)
682-- >>> printSQL $ i & field #complex #imaginary
682-- >>> printSQL $ i & field #complex #imaginary
683-- (ROW(0, 1)::"complex")."imaginary"
683-- (ROW(0, 1)::"complex")."imaginary"
@@ -687,22 +687,22 @@ field
687 , Has field row ty)
687 , Has field row ty)
688 => QualifiedAlias sch tydef -- ^ row type
688 => QualifiedAlias sch tydef -- ^ row type
689 -> Alias field -- ^ field name
689 -> Alias field -- ^ field name
690− -> Expression outer grp commons schemas params from ('NotNull ('PGcomposite row))
690+ -> Expression outer commons grp schemas params from ('NotNull ('PGcomposite row))
691− -> Expression outer grp commons schemas params from ty
691+ -> Expression outer commons grp schemas params from ty
692field td fld expr = UnsafeExpression $
692field td fld expr = UnsafeExpression $
693 parenthesized (renderSQL expr <> "::" <> renderSQL td)
693 parenthesized (renderSQL expr <> "::" <> renderSQL td)
694 <> "." <> renderSQL fld
694 <> "." <> renderSQL fld
696instance Semigroup
696instance Semigroup
697− (Expression outer grp commons schemas params from (null ('PGvararray ty))) where
697+ (Expression outer commons grp schemas params from (null ('PGvararray ty))) where
698 (<>) = unsafeBinaryOp "||"
698 (<>) = unsafeBinaryOp "||"
700instance Monoid
700instance Monoid
701− (Expression outer grp commons schemas params from (null ('PGvararray ty))) where
701+ (Expression outer commons grp schemas params from (null ('PGvararray ty))) where
702 mempty = array []
702 mempty = array []
703 mappend = (<>)
703 mappend = (<>)
705−-- | >>> let expr = greatest [param @1] currentTimestamp :: Expression outer grp commons schemas '[ 'NotNull 'PGtimestamptz] from ('NotNull 'PGtimestamptz)
705+-- | >>> let expr = greatest [param @1] currentTimestamp :: Expression outer commons grp schemas '[ 'NotNull 'PGtimestamptz] from ('NotNull 'PGtimestamptz)
706-- >>> printSQL expr
706-- >>> printSQL expr
707-- GREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)
707-- GREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)
708greatest :: FunctionHom ty ty ty
708greatest :: FunctionHom ty ty ty
@@ -745,7 +745,7 @@ unsafeFunctionHet fun xs = UnsafeExpression $
745 fun <> parenthesized (renderCommaSeparated renderSQL xs)
745 fun <> parenthesized (renderCommaSeparated renderSQL xs)
747instance ty `In` PGNum
747instance ty `In` PGNum
748− => Num (Expression outer grp commons schemas params from (null ty)) where
748+ => Num (Expression outer commons grp schemas params from (null ty)) where
749 (+) = unsafeBinaryOp "+"
749 (+) = unsafeBinaryOp "+"
750 (-) = unsafeBinaryOp "-"
750 (-) = unsafeBinaryOp "-"
751 (*) = unsafeBinaryOp "*"
751 (*) = unsafeBinaryOp "*"
@@ -757,7 +757,7 @@ instance ty `In` PGNum
759instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
759instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
760− (Expression outer grp commons schemas params from (null ty)) where
760+ (Expression outer commons grp schemas params from (null ty)) where
761 (/) = unsafeBinaryOp "/"
761 (/) = unsafeBinaryOp "/"
762 fromRational
762 fromRational
763 = UnsafeExpression
763 = UnsafeExpression
@@ -767,7 +767,7 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
767 . fromRat @Double
767 . fromRat @Double
769instance (ty `In` PGNum, ty `In` PGFloating) => Floating
769instance (ty `In` PGNum, ty `In` PGFloating) => Floating
770− (Expression outer grp commons schemas params from (null ty)) where
770+ (Expression outer commons grp schemas params from (null ty)) where
771 pi = UnsafeExpression "pi()"
771 pi = UnsafeExpression "pi()"
772 exp = unsafeFunction "exp"
772 exp = unsafeFunction "exp"
773 log = unsafeFunction "ln"
773 log = unsafeFunction "ln"
@@ -809,9 +809,9 @@ atan2_ = unsafeFunctionHet "atan2"
810 :: TypeExpression schemas ty1
810 :: TypeExpression schemas ty1
811 -- ^ type to cast as
811 -- ^ type to cast as
812− -> Expression outer grp commons schemas params from ty0
812+ -> Expression outer commons grp schemas params from ty0
813 -- ^ value to convert
813 -- ^ value to convert
814− -> Expression outer grp commons schemas params from ty1
814+ -> Expression outer commons grp schemas params from ty1
815cast ty x = UnsafeExpression $ parenthesized $
815cast ty x = UnsafeExpression $ parenthesized $
816 renderSQL x <+> "::" <+> renderSQL ty
816 renderSQL x <+> "::" <+> renderSQL ty
@@ -819,7 +819,7 @@ cast ty x = UnsafeExpression $ parenthesized $
822−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
822+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
823-- expression = 5 `quot_` 2
823-- expression = 5 `quot_` 2
824-- in printSQL expression
824-- in printSQL expression
@@ -833,7 +833,7 @@ quot_ = unsafeBinaryOp "/"
836−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
836+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
837-- expression = 5 `rem_` 2
837-- expression = 5 `rem_` 2
838-- in printSQL expression
838-- in printSQL expression
@@ -845,7 +845,7 @@ rem_ = unsafeBinaryOp "%"
846-- | >>> :{
846-- | >>> :{
848−-- expression :: Expression outer grp commons schemas params from (null 'PGfloat4)
848+-- expression :: Expression outer commons grp schemas params from (null 'PGfloat4)
849-- expression = trunc pi
849-- expression = trunc pi
850-- in printSQL expression
850-- in printSQL expression
@@ -855,7 +855,7 @@ trunc = unsafeFunction "trunc"
856-- | >>> :{
856-- | >>> :{
858−-- expression :: Expression outer grp commons schemas params from (null 'PGfloat4)
858+-- expression :: Expression outer commons grp schemas params from (null 'PGfloat4)
859-- expression = round_ pi
859-- expression = round_ pi
860-- in printSQL expression
860-- in printSQL expression
@@ -865,7 +865,7 @@ round_ = unsafeFunction "round"
866-- | >>> :{
866-- | >>> :{
868−-- expression :: Expression outer grp commons schemas params from (null 'PGfloat4)
868+-- expression :: Expression outer commons grp schemas params from (null 'PGfloat4)
869-- expression = ceiling_ pi
869-- expression = ceiling_ pi
870-- in printSQL expression
870-- in printSQL expression
@@ -876,8 +876,8 @@ ceiling_ = unsafeFunction "ceiling"
876-- | A `Condition` is an `Expression`, which can evaluate
876-- | A `Condition` is an `Expression`, which can evaluate
877-- to `true`, `false` or `null_`. This is because SQL uses
877-- to `true`, `false` or `null_`. This is because SQL uses
878-- a three valued logic.
878-- a three valued logic.
879−type Condition outer grp commons schemas params from =
879+type Condition outer commons grp schemas params from =
880− Expression outer grp commons schemas params from ('Null 'PGbool)
880+ Expression outer commons grp schemas params from ('Null 'PGbool)
882-- | >>> printSQL true
882-- | >>> printSQL true
@@ -908,19 +908,19 @@ infixr 2 .||
909-- | >>> :{
909-- | >>> :{
911−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
911+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
912-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
912-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
913-- in printSQL expression
913-- in printSQL expression
915-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
915-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
916caseWhenThenElse
916caseWhenThenElse
917− :: [ ( Condition outer grp commons schemas params from
917+ :: [ ( Condition outer commons grp schemas params from
918− , Expression outer grp commons schemas params from ty
918+ , Expression outer commons grp schemas params from ty
920 -- ^ whens and thens
920 -- ^ whens and thens
921− -> Expression outer grp commons schemas params from ty
921+ -> Expression outer commons grp schemas params from ty
922 -- ^ else
922 -- ^ else
923− -> Expression outer grp commons schemas params from ty
923+ -> Expression outer commons grp schemas params from ty
924caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
924caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
926 , mconcat
926 , mconcat
@@ -936,16 +936,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
937-- | >>> :{
937-- | >>> :{
939−-- expression :: Expression outer grp commons schemas params from (null 'PGint2)
939+-- expression :: Expression outer commons grp schemas params from (null 'PGint2)
940-- expression = ifThenElse true 1 0
940-- expression = ifThenElse true 1 0
941-- in printSQL expression
941-- in printSQL expression
943-- CASE WHEN TRUE THEN 1 ELSE 0 END
943-- CASE WHEN TRUE THEN 1 ELSE 0 END
944ifThenElse
944ifThenElse
945− :: Condition outer grp commons schemas params from
945+ :: Condition outer commons grp schemas params from
946− -> Expression outer grp commons schemas params from ty -- ^ then
946+ -> Expression outer commons grp schemas params from ty -- ^ then
947− -> Expression outer grp commons schemas params from ty -- ^ else
947+ -> Expression outer commons grp schemas params from ty -- ^ else
948− -> Expression outer grp commons schemas params from ty
948+ -> Expression outer commons grp schemas params from ty
949ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
949ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
951-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
951-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -991,10 +991,10 @@ infix 4 .>
991TRUE BETWEEN NULL AND FALSE
991TRUE BETWEEN NULL AND FALSE
994− :: Expression outer grp commons schemas params from (null ty)
994+ :: Expression outer commons grp schemas params from (null ty)
995− -> ( Expression outer grp commons schemas params from (null ty)
995+ -> ( Expression outer commons grp schemas params from (null ty)
996− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
996+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
997− -> Condition outer grp commons schemas params from
997+ -> Condition outer commons grp schemas params from
998between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
998between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
999 <+> renderSQL x <+> "AND" <+> renderSQL y
999 <+> renderSQL x <+> "AND" <+> renderSQL y
@@ -1002,10 +1002,10 @@ between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
1002TRUE NOT BETWEEN NULL AND FALSE
1002TRUE NOT BETWEEN NULL AND FALSE
1004notBetween
1004notBetween
1005− :: Expression outer grp commons schemas params from (null ty)
1005+ :: Expression outer commons grp schemas params from (null ty)
1006− -> ( Expression outer grp commons schemas params from (null ty)
1006+ -> ( Expression outer commons grp schemas params from (null ty)
1007− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
1007+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
1008− -> Condition outer grp commons schemas params from
1008+ -> Condition outer commons grp schemas params from
1009notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
1009notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
1010 <+> renderSQL x <+> "AND" <+> renderSQL y
1010 <+> renderSQL x <+> "AND" <+> renderSQL y
@@ -1015,10 +1015,10 @@ notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
1015TRUE BETWEEN SYMMETRIC NULL AND FALSE
1015TRUE BETWEEN SYMMETRIC NULL AND FALSE
1017betweenSymmetric
1017betweenSymmetric
1018− :: Expression outer grp commons schemas params from (null ty)
1018+ :: Expression outer commons grp schemas params from (null ty)
1019− -> ( Expression outer grp commons schemas params from (null ty)
1019+ -> ( Expression outer commons grp schemas params from (null ty)
1020− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
1020+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
1021− -> Condition outer grp commons schemas params from
1021+ -> Condition outer commons grp schemas params from
1022betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
1022betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
1023 <+> "BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
1023 <+> "BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
@@ -1028,10 +1028,10 @@ betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
1028TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE
1028TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE
1030notBetweenSymmetric
1030notBetweenSymmetric
1031− :: Expression outer grp commons schemas params from (null ty)
1031+ :: Expression outer commons grp schemas params from (null ty)
1032− -> ( Expression outer grp commons schemas params from (null ty)
1032+ -> ( Expression outer commons grp schemas params from (null ty)
1033− , Expression outer grp commons schemas params from (null ty) ) -- ^ bounds
1033+ , Expression outer commons grp schemas params from (null ty) ) -- ^ bounds
1034− -> Condition outer grp commons schemas params from
1034+ -> Condition outer commons grp schemas params from
1035notBetweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
1035notBetweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
1036 <+> "NOT BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
1036 <+> "NOT BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
@@ -1148,31 +1148,31 @@ escape = \case
1148 c -> [c]
1148 c -> [c]
1150instance IsString
1150instance IsString
1151− (Expression outer grp commons schemas params from (null 'PGtext)) where
1151+ (Expression outer commons grp schemas params from (null 'PGtext)) where
1152 fromString str = UnsafeExpression $
1152 fromString str = UnsafeExpression $
1153 "E\'" <> fromString (escape =<< str) <> "\'"
1153 "E\'" <> fromString (escape =<< str) <> "\'"
1154instance IsString
1154instance IsString
1155− (Expression outer grp commons schemas params from (null 'PGtsvector)) where
1155+ (Expression outer commons grp schemas params from (null 'PGtsvector)) where
1156 fromString str = cast tsvector . UnsafeExpression $
1156 fromString str = cast tsvector . UnsafeExpression $
1157 "E\'" <> fromString (escape =<< str) <> "\'"
1157 "E\'" <> fromString (escape =<< str) <> "\'"
1158instance IsString
1158instance IsString
1159− (Expression outer grp commons schemas params from (null 'PGtsquery)) where
1159+ (Expression outer commons grp schemas params from (null 'PGtsquery)) where
1160 fromString str = cast tsquery . UnsafeExpression $
1160 fromString str = cast tsquery . UnsafeExpression $
1161 "E\'" <> fromString (escape =<< str) <> "\'"
1161 "E\'" <> fromString (escape =<< str) <> "\'"
1163instance Semigroup
1163instance Semigroup
1164− (Expression outer grp commons schemas params from (null 'PGtext)) where
1164+ (Expression outer commons grp schemas params from (null 'PGtext)) where
1165 (<>) = unsafeBinaryOp "||"
1165 (<>) = unsafeBinaryOp "||"
1166instance Semigroup
1166instance Semigroup
1167− (Expression outer grp commons schemas params from (null 'PGtsvector)) where
1167+ (Expression outer commons grp schemas params from (null 'PGtsvector)) where
1168 (<>) = unsafeBinaryOp "||"
1168 (<>) = unsafeBinaryOp "||"
1170instance Monoid
1170instance Monoid
1171− (Expression outer grp commons schemas params from (null 'PGtext)) where
1171+ (Expression outer commons grp schemas params from (null 'PGtext)) where
1172 mempty = fromString ""
1172 mempty = fromString ""
1173 mappend = (<>)
1173 mappend = (<>)
1174instance Monoid
1174instance Monoid
1175− (Expression outer grp commons schemas params from (null 'PGtsvector)) where
1175+ (Expression outer commons grp schemas params from (null 'PGtsvector)) where
1176 mempty = fromString ""
1176 mempty = fromString ""
1177 mappend = (<>)
1177 mappend = (<>)
@@ -1282,7 +1282,7 @@ infixl 9 .?&
1283-- | Concatenate two jsonb values into a new jsonb value.
1283-- | Concatenate two jsonb values into a new jsonb value.
1284instance Semigroup
1284instance Semigroup
1285− (Expression outer grp commons schemas params from (null 'PGjsonb)) where
1285+ (Expression outer commons grp schemas params from (null 'PGjsonb)) where
1286 (<>) = unsafeBinaryOp "||"
1286 (<>) = unsafeBinaryOp "||"
1288-- | Delete a key or keys from a JSON object, or remove an array element.
1288-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1432,9 +1432,9 @@ jsonbArrayLength = unsafeFunction "jsonb_array_length"
1432-- operator).
1432-- operator).
1433jsonExtractPath
1433jsonExtractPath
1434 :: SListI elems
1434 :: SListI elems
1435− => Expression outer grp commons schemas params from (null 'PGjson)
1435+ => Expression outer commons grp schemas params from (null 'PGjson)
1436− -> NP (Expression outer grp commons schemas params from) elems
1436+ -> NP (Expression outer commons grp schemas params from) elems
1437− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1437+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1438jsonExtractPath x xs =
1438jsonExtractPath x xs =
1439 unsafeFunctionHet "json_extract_path" (x :* xs)
1439 unsafeFunctionHet "json_extract_path" (x :* xs)
@@ -1442,9 +1442,9 @@ jsonExtractPath x xs =
1442-- operator).
1442-- operator).
1443jsonbExtractPath
1443jsonbExtractPath
1444 :: SListI elems
1444 :: SListI elems
1445− => Expression outer grp commons schemas params from (null 'PGjsonb)
1445+ => Expression outer commons grp schemas params from (null 'PGjsonb)
1446− -> NP (Expression outer grp commons schemas params from) elems
1446+ -> NP (Expression outer commons grp schemas params from) elems
1447− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1447+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1448jsonbExtractPath x xs =
1448jsonbExtractPath x xs =
1449 unsafeFunctionHet "jsonb_extract_path" (x :* xs)
1449 unsafeFunctionHet "jsonb_extract_path" (x :* xs)
@@ -1452,9 +1452,9 @@ jsonbExtractPath x xs =
1452-- operator), as text.
1452-- operator), as text.
1453jsonExtractPathAsText
1453jsonExtractPathAsText
1454 :: SListI elems
1454 :: SListI elems
1455− => Expression outer grp commons schemas params from (null 'PGjson)
1455+ => Expression outer commons grp schemas params from (null 'PGjson)
1456− -> NP (Expression outer grp commons schemas params from) elems
1456+ -> NP (Expression outer commons grp schemas params from) elems
1457− -> Expression outer grp commons schemas params from (null 'PGjson)
1457+ -> Expression outer commons grp schemas params from (null 'PGjson)
1458jsonExtractPathAsText x xs =
1458jsonExtractPathAsText x xs =
1459 unsafeFunctionHet "json_extract_path_text" (x :* xs)
1459 unsafeFunctionHet "json_extract_path_text" (x :* xs)
@@ -1462,9 +1462,9 @@ jsonExtractPathAsText x xs =
1462-- operator), as text.
1462-- operator), as text.
1463jsonbExtractPathAsText
1463jsonbExtractPathAsText
1464 :: SListI elems
1464 :: SListI elems
1465− => Expression outer grp commons schemas params from (null 'PGjsonb)
1465+ => Expression outer commons grp schemas params from (null 'PGjsonb)
1466− -> NP (Expression outer grp commons schemas params from) elems
1466+ -> NP (Expression outer commons grp schemas params from) elems
1467− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1467+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1468jsonbExtractPathAsText x xs =
1468jsonbExtractPathAsText x xs =
1469 unsafeFunctionHet "jsonb_extract_path_text" (x :* xs)
1469 unsafeFunctionHet "jsonb_extract_path_text" (x :* xs)
@@ -1496,11 +1496,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1496-- operators, negative integers that appear in path count from the end of JSON
1496-- operators, negative integers that appear in path count from the end of JSON
1497-- arrays.
1497-- arrays.
1499− :: Expression outer grp commons schemas params from (null 'PGjsonb)
1499+ :: Expression outer commons grp schemas params from (null 'PGjsonb)
1500− -> Expression outer grp commons schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1500+ -> Expression outer commons grp schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1501− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1501+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1502− -> Maybe (Expression outer grp commons schemas params from (null 'PGbool))
1502+ -> Maybe (Expression outer commons grp schemas params from (null 'PGbool))
1503− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1503+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1504jsonbSet tgt path val createMissing = case createMissing of
1504jsonbSet tgt path val createMissing = case createMissing of
1505 Just m -> unsafeFunctionHet "jsonb_set" (tgt :* path :* val :* m :* Nil)
1505 Just m -> unsafeFunctionHet "jsonb_set" (tgt :* path :* val :* m :* Nil)
1506 Nothing -> unsafeFunctionHet "jsonb_set" (tgt :* path :* val :* Nil)
1506 Nothing -> unsafeFunctionHet "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1514,11 +1514,11 @@ jsonbSet tgt path val createMissing = case createMissing of
1514-- exist. As with the path orientated operators, negative integers that appear
1514-- exist. As with the path orientated operators, negative integers that appear
1515-- in path count from the end of JSON arrays.
1515-- in path count from the end of JSON arrays.
1516jsonbInsert
1516jsonbInsert
1517− :: Expression outer grp commons schemas params from (null 'PGjsonb)
1517+ :: Expression outer commons grp schemas params from (null 'PGjsonb)
1518− -> Expression outer grp commons schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1518+ -> Expression outer commons grp schemas params from (null ('PGvararray ('NotNull 'PGtext)))
1519− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1519+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1520− -> Maybe (Expression outer grp commons schemas params from (null 'PGbool))
1520+ -> Maybe (Expression outer commons grp schemas params from (null 'PGbool))
1521− -> Expression outer grp commons schemas params from (null 'PGjsonb)
1521+ -> Expression outer commons grp schemas params from (null 'PGjsonb)
1522jsonbInsert tgt path val insertAfter = case insertAfter of
1522jsonbInsert tgt path val insertAfter = case insertAfter of
1523 Just i -> unsafeFunctionHet "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1523 Just i -> unsafeFunctionHet "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1524 Nothing -> unsafeFunctionHet "jsonb_insert" (tgt :* path :* val :* Nil)
1524 Nothing -> unsafeFunctionHet "jsonb_insert" (tgt :* path :* val :* Nil)
@@ -1610,16 +1610,16 @@ aggregation
1611type AggrFun x y
1611type AggrFun x y
1612 = forall outer bys commons schemas params from
1612 = forall outer bys commons schemas params from
1613− . Distinction (Expression outer 'Ungrouped commons schemas params from) x
1613+ . Distinction (Expression outer commons 'Ungrouped schemas params from) x
1614 -- ^ input
1614 -- ^ input
1615− -> Expression outer ('Grouped bys) commons schemas params from y
1615+ -> Expression outer commons ('Grouped bys) schemas params from y
1616 -- ^ output
1616 -- ^ output
1618type AggrHet xs y
1618type AggrHet xs y
1619 = forall outer bys commons schemas params from
1619 = forall outer bys commons schemas params from
1620− . Distinction (NP (Expression outer 'Ungrouped commons schemas params from)) xs
1620+ . Distinction (NP (Expression outer commons 'Ungrouped schemas params from)) xs
1621 -- ^ inputs
1621 -- ^ inputs
1622− -> Expression outer ('Grouped bys) commons schemas params from y
1622+ -> Expression outer commons ('Grouped bys) schemas params from y
1623 -- ^ output
1623 -- ^ output
1625unsafeAggregateHet :: SOP.SListI xs => ByteString -> AggrHet xs y
1625unsafeAggregateHet :: SOP.SListI xs => ByteString -> AggrHet xs y
@@ -1638,7 +1638,7 @@ class Aggregate expr1 exprHet aggr
1639 -- >>> :{
1639 -- >>> :{
1641− -- expression :: Expression '[] ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1641+ -- expression :: Expression '[] commons ('Grouped bys) schemas params from ('NotNull 'PGint8)
1642 -- expression = countStar
1642 -- expression = countStar
1643 -- in printSQL expression
1643 -- in printSQL expression
@@ -1647,7 +1647,7 @@ class Aggregate expr1 exprHet aggr
1648 -- | >>> :{
1648 -- | >>> :{
1650− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8)
1650+ -- expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8)
1651 -- expression = count (All #col)
1651 -- expression = count (All #col)
1652 -- in printSQL expression
1652 -- in printSQL expression
@@ -1659,7 +1659,7 @@ class Aggregate expr1 exprHet aggr
1660 -- | >>> :{
1660 -- | >>> :{
1662− -- expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('NotNull 'PGnumeric)
1662+ -- expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('NotNull 'PGnumeric)
1663 -- expression = sum_ (Distinct #col)
1663 -- expression = sum_ (Distinct #col)
1664 -- in printSQL expression
1664 -- in printSQL expression
@@ -1688,7 +1688,7 @@ class Aggregate expr1 exprHet aggr
1688 the bitwise AND of all non-null input values, or null if none
1688 the bitwise AND of all non-null input values, or null if none
1691− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
1691+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
1692 expression = bitAnd (Distinct #col)
1692 expression = bitAnd (Distinct #col)
1693 in printSQL expression
1693 in printSQL expression
@@ -1705,7 +1705,7 @@ class Aggregate expr1 exprHet aggr
1708− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
1708+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4)
1709 expression = bitOr (All #col)
1709 expression = bitOr (All #col)
1710 in printSQL expression
1710 in printSQL expression
@@ -1722,7 +1722,7 @@ class Aggregate expr1 exprHet aggr
1725− winFun :: WindowFunction '[] 'Ungrouped commons schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1725+ winFun :: WindowFunction '[] commons 'Ungrouped schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1726 winFun = boolAnd #col
1726 winFun = boolAnd #col
1727 in printSQL winFun
1727 in printSQL winFun
@@ -1738,7 +1738,7 @@ class Aggregate expr1 exprHet aggr
1741− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1741+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1742 expression = boolOr (All #col)
1742 expression = boolOr (All #col)
1743 in printSQL expression
1743 in printSQL expression
@@ -1754,7 +1754,7 @@ class Aggregate expr1 exprHet aggr
1757− expression :: Expression '[] ('Grouped bys) commons schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1757+ expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool)
1758 expression = every (Distinct #col)
1758 expression = every (Distinct #col)
1759 in printSQL expression
1759 in printSQL expression
@@ -1786,7 +1786,7 @@ class Aggregate expr1 exprHet aggr
1786 {- | correlation coefficient
1786 {- | correlation coefficient
1789− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1789+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1790 expression = corr (All (#y *: #x))
1790 expression = corr (All (#y *: #x))
1791 in printSQL expression
1791 in printSQL expression
@@ -1799,7 +1799,7 @@ class Aggregate expr1 exprHet aggr
1799 {- | population covariance
1799 {- | population covariance
1802− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1802+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1803 expression = covarPop (All (#y *: #x))
1803 expression = covarPop (All (#y *: #x))
1804 in printSQL expression
1804 in printSQL expression
@@ -1812,7 +1812,7 @@ class Aggregate expr1 exprHet aggr
1812 {- | sample covariance
1812 {- | sample covariance
1815− winFun :: WindowFunction '[] 'Ungrouped c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1815+ winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1816 winFun = covarSamp (#y *: #x)
1816 winFun = covarSamp (#y *: #x)
1817 in printSQL winFun
1817 in printSQL winFun
@@ -1825,7 +1825,7 @@ class Aggregate expr1 exprHet aggr
1825 {- | average of the independent variable (sum(X)/N)
1825 {- | average of the independent variable (sum(X)/N)
1828− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1828+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1829 expression = regrAvgX (All (#y *: #x))
1829 expression = regrAvgX (All (#y *: #x))
1830 in printSQL expression
1830 in printSQL expression
@@ -1838,7 +1838,7 @@ class Aggregate expr1 exprHet aggr
1838 {- | average of the dependent variable (sum(Y)/N)
1838 {- | average of the dependent variable (sum(Y)/N)
1841− winFun :: WindowFunction '[] 'Ungrouped c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1841+ winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1842 winFun = regrAvgY (#y *: #x)
1842 winFun = regrAvgY (#y *: #x)
1843 in printSQL winFun
1843 in printSQL winFun
@@ -1851,7 +1851,7 @@ class Aggregate expr1 exprHet aggr
1851 {- | number of input rows in which both expressions are nonnull
1851 {- | number of input rows in which both expressions are nonnull
1854− winFun :: WindowFunction '[] 'Ungrouped c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8)
1854+ winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8)
1855 winFun = regrCount (#y *: #x)
1855 winFun = regrCount (#y *: #x)
1856 in printSQL winFun
1856 in printSQL winFun
@@ -1864,7 +1864,7 @@ class Aggregate expr1 exprHet aggr
1864 {- | y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs
1864 {- | y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs
1867− expression :: Expression '[] ('Grouped g) c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1867+ expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8)
1868 expression = regrIntercept (All (#y *: #x))
1868 expression = regrIntercept (All (#y *: #x))
1869 in printSQL expression
1869 in printSQL expression
@@ -1945,21 +1945,21 @@ data Distinction (expr :: kind -> Type) (ty :: kind)
1945 = All (expr ty)
1945 = All (expr ty)
1946 | Distinct (expr ty)
1946 | Distinct (expr ty)
1947 deriving (GHC.Generic,Show,Eq,Ord)
1947 deriving (GHC.Generic,Show,Eq,Ord)
1948−instance NFData (Distinction (Expression outer grp commons schemas params from) ty)
1948+instance NFData (Distinction (Expression outer commons grp schemas params from) ty)
1949−instance RenderSQL (Distinction (Expression outer grp commons schemas params from) ty) where
1949+instance RenderSQL (Distinction (Expression outer commons grp schemas params from) ty) where
1950 renderSQL = \case
1950 renderSQL = \case
1951 All x -> "ALL" <+> renderSQL x
1951 All x -> "ALL" <+> renderSQL x
1952 Distinct x -> "DISTINCT" <+> renderSQL x
1952 Distinct x -> "DISTINCT" <+> renderSQL x
1953instance SOP.SListI tys => RenderSQL
1953instance SOP.SListI tys => RenderSQL
1954− (Distinction (NP (Expression outer grp commons schemas params from)) tys) where
1954+ (Distinction (NP (Expression outer commons grp schemas params from)) tys) where
1955 renderSQL = \case
1955 renderSQL = \case
1956 All xs -> "ALL" <+> renderCommaSeparated renderSQL xs
1956 All xs -> "ALL" <+> renderCommaSeparated renderSQL xs
1957 Distinct xs -> "DISTINCT" <+> renderCommaSeparated renderSQL xs
1957 Distinct xs -> "DISTINCT" <+> renderCommaSeparated renderSQL xs
1959instance Aggregate
1959instance Aggregate
1960− (Distinction (Expression outer 'Ungrouped commons schemas params from))
1960+ (Distinction (Expression outer commons 'Ungrouped schemas params from))
1961− (Distinction (NP (Expression outer 'Ungrouped commons schemas params from)))
1961+ (Distinction (NP (Expression outer commons 'Ungrouped schemas params from)))
1962− (Expression outer ('Grouped bys) commons schemas params from) where
1962+ (Expression outer commons ('Grouped bys) schemas params from) where
1963 countStar = UnsafeExpression "count(*)"
1963 countStar = UnsafeExpression "count(*)"
1964 count = unsafeAggregate1 "count"
1964 count = unsafeAggregate1 "count"
1965 sum_ = unsafeAggregate1 "sum"
1965 sum_ = unsafeAggregate1 "sum"
@@ -1993,9 +1993,9 @@ instance Aggregate
1993 varPop = unsafeAggregate1 "var_pop"
1993 varPop = unsafeAggregate1 "var_pop"
1994 varSamp = unsafeAggregate1 "var_samp"
1994 varSamp = unsafeAggregate1 "var_samp"
1995instance Aggregate
1995instance Aggregate
1996− (Expression outer grp commons schemas params from)
1996+ (Expression outer commons grp schemas params from)
1997− (NP (Expression outer grp commons schemas params from))
1997+ (NP (Expression outer commons grp schemas params from))
1998− (WindowFunction outer grp commons schemas params from) where
1998+ (WindowFunction outer commons grp schemas params from) where
1999 countStar = UnsafeWindowFunction "count(*)"
1999 countStar = UnsafeWindowFunction "count(*)"
2000 count = unsafeWindowFunction1 "count"
2000 count = unsafeWindowFunction1 "count"
2001 sum_ = unsafeWindowFunction1 "sum"
2001 sum_ = unsafeWindowFunction1 "sum"
@@ -2240,26 +2240,26 @@ Sorting
2240-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
2240-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
2241-- determine whether nulls appear before or after non-null values in the sort
2241-- determine whether nulls appear before or after non-null values in the sort
2242-- ordering of a `Null` result column.
2242-- ordering of a `Null` result column.
2243−data SortExpression outer grp commons schemas params from where
2243+data SortExpression outer commons grp schemas params from where
2245− :: Expression outer grp commons schemas params from ('NotNull ty)
2245+ :: Expression outer commons grp schemas params from ('NotNull ty)
2246− -> SortExpression outer grp commons schemas params from
2246+ -> SortExpression outer commons grp schemas params from
2248− :: Expression outer grp commons schemas params from ('NotNull ty)
2248+ :: Expression outer commons grp schemas params from ('NotNull ty)
2249− -> SortExpression outer grp commons schemas params from
2249+ -> SortExpression outer commons grp schemas params from
2250 AscNullsFirst
2250 AscNullsFirst
2251− :: Expression outer grp commons schemas params from ('Null ty)
2251+ :: Expression outer commons grp schemas params from ('Null ty)
2252− -> SortExpression outer grp commons schemas params from
2252+ -> SortExpression outer commons grp schemas params from
2253 AscNullsLast
2253 AscNullsLast
2254− :: Expression outer grp commons schemas params from ('Null ty)
2254+ :: Expression outer commons grp schemas params from ('Null ty)
2255− -> SortExpression outer grp commons schemas params from
2255+ -> SortExpression outer commons grp schemas params from
2256 DescNullsFirst
2256 DescNullsFirst
2257− :: Expression outer grp commons schemas params from ('Null ty)
2257+ :: Expression outer commons grp schemas params from ('Null ty)
2258− -> SortExpression outer grp commons schemas params from
2258+ -> SortExpression outer commons grp schemas params from
2259 DescNullsLast
2259 DescNullsLast
2260− :: Expression outer grp commons schemas params from ('Null ty)
2260+ :: Expression outer commons grp schemas params from ('Null ty)
2261− -> SortExpression outer grp commons schemas params from
2261+ -> SortExpression outer commons grp schemas params from
2262−deriving instance Show (SortExpression outer grp commons schemas params from)
2262+deriving instance Show (SortExpression outer commons grp schemas params from)
2265The `orderBy` clause causes the result rows of a `Squeal.PostgreSQL.Query.TableExpression`
2265The `orderBy` clause causes the result rows of a `Squeal.PostgreSQL.Query.TableExpression`
@@ -2274,12 +2274,12 @@ using `orderBy` within `Squeal.PostgreSQL.Query.Over`.
2275class OrderBy expr where
2275class OrderBy expr where
2277− :: [SortExpression outer grp commons schemas params from]
2277+ :: [SortExpression outer commons grp schemas params from]
2278− -> expr outer grp commons schemas params from
2278+ -> expr outer commons grp schemas params from
2279− -> expr outer grp commons schemas params from
2279+ -> expr outer commons grp schemas params from
2281-- | Render a `SortExpression`.
2281-- | Render a `SortExpression`.
2282−instance RenderSQL (SortExpression outer grp commons schemas params from) where
2282+instance RenderSQL (SortExpression outer commons grp schemas params from) where
2283 renderSQL = \case
2283 renderSQL = \case
2284 Asc expression -> renderSQL expression <+> "ASC"
2284 Asc expression -> renderSQL expression <+> "ASC"
2285 Desc expression -> renderSQL expression <+> "DESC"
2285 Desc expression -> renderSQL expression <+> "DESC"
@@ -2292,12 +2292,12 @@ instance RenderSQL (SortExpression outer grp commons schemas params from) where
2293-- | A `WindowDefinition` is a set of table rows that are somehow related
2293-- | A `WindowDefinition` is a set of table rows that are somehow related
2294-- to the current row
2294-- to the current row
2295−data WindowDefinition outer grp commons schemas params from where
2295+data WindowDefinition outer commons grp schemas params from where
2296 WindowDefinition
2296 WindowDefinition
2297 :: SListI bys
2297 :: SListI bys
2298− => NP (Expression outer grp commons schemas params from) bys
2298+ => NP (Expression outer commons grp schemas params from) bys
2299− -> [SortExpression outer grp commons schemas params from]
2299+ -> [SortExpression outer commons grp schemas params from]
2300− -> WindowDefinition outer grp commons schemas params from
2300+ -> WindowDefinition outer commons grp schemas params from
2302instance OrderBy WindowDefinition where
2302instance OrderBy WindowDefinition where
2303 orderBy sortsR (WindowDefinition parts sortsL)
2303 orderBy sortsR (WindowDefinition parts sortsL)
@@ -2323,8 +2323,8 @@ the same partition as the current row.
2324partitionBy
2324partitionBy
2325 :: SListI bys
2325 :: SListI bys
2326− => NP (Expression outer grp commons schemas params from) bys
2326+ => NP (Expression outer commons grp schemas params from) bys
2327− -> WindowDefinition outer grp commons schemas params from
2327+ -> WindowDefinition outer commons grp schemas params from
2328partitionBy bys = WindowDefinition bys []
2328partitionBy bys = WindowDefinition bys []
@@ -2339,8 +2339,8 @@ just the current row of the query result.
2340newtype WindowFunction
2340newtype WindowFunction
2341 (outer :: FromType)
2341 (outer :: FromType)
2343 (commons :: FromType)
2342 (commons :: FromType)
2344 (schemas :: SchemasType)
2344 (schemas :: SchemasType)
2345 (params :: [NullityType])
2345 (params :: [NullityType])
2346 (from :: FromType)
2346 (from :: FromType)
@@ -2348,26 +2348,26 @@ newtype WindowFunction
2348 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
2348 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
2349 deriving (GHC.Generic,Show,Eq,Ord,NFData)
2349 deriving (GHC.Generic,Show,Eq,Ord,NFData)
2351−instance RenderSQL (WindowFunction outer grp commons schemas params from ty) where
2351+instance RenderSQL (WindowFunction outer commons grp schemas params from ty) where
2352 renderSQL = renderWindowFunction
2352 renderSQL = renderWindowFunction
2354type WinFun0 x
2354type WinFun0 x
2355− = forall outer grp commons schemas params from
2355+ = forall outer commons grp schemas params from
2356− . WindowFunction outer grp commons schemas params from x
2356+ . WindowFunction outer commons grp schemas params from x
2357 -- ^ cannot reference aliases
2357 -- ^ cannot reference aliases
2359type WinFun1 x y
2359type WinFun1 x y
2360− = forall outer grp commons schemas params from
2360+ = forall outer commons grp schemas params from
2361− . Expression outer grp commons schemas params from x
2361+ . Expression outer commons grp schemas params from x
2362 -- ^ input
2362 -- ^ input
2363− -> WindowFunction outer grp commons schemas params from y
2363+ -> WindowFunction outer commons grp schemas params from y
2364 -- ^ output
2364 -- ^ output
2366type WinFunHet xs y
2366type WinFunHet xs y
2367− = forall outer grp commons schemas params from
2367+ = forall outer commons grp schemas params from
2368− . NP (Expression outer grp commons schemas params from) xs
2368+ . NP (Expression outer commons grp schemas params from) xs
2369 -- ^ inputs
2369 -- ^ inputs
2370− -> WindowFunction outer grp commons schemas params from y
2370+ -> WindowFunction outer commons grp schemas params from y
2371 -- ^ output
2371 -- ^ output
2373unsafeWindowFunction1 :: ByteString -> WinFun1 x y
2373unsafeWindowFunction1 :: ByteString -> WinFun1 x y