on dev help sign in
move some type variables around
cabe722Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+4−4
@@ -298,7 +298,7 @@ check
298 , HasAll aliases (TableToRow table) subcolumns )
298 , HasAll aliases (TableToRow table) subcolumns )
299 => NP Alias aliases
299 => NP Alias aliases
300 -- ^ specify the subcolumns which are getting checked
300 -- ^ specify the subcolumns which are getting checked
301− -> (forall t. Condition '[] 'Ungrouped '[] schemas '[] '[t ::: subcolumns])
301+ -> (forall t. Condition '[] '[] 'Ungrouped schemas '[] '[t ::: subcolumns])
302 -- ^ a closed `Condition` on those subcolumns
302 -- ^ a closed `Condition` on those subcolumns
303 -> TableConstraintExpression sch tab schemas ('Check aliases)
303 -> TableConstraintExpression sch tab schemas ('Check aliases)
304check _cols condition = UnsafeTableConstraintExpression $
304check _cols condition = UnsafeTableConstraintExpression $
@@ -773,7 +773,7 @@ newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnT
773-- :}
773-- :}
774-- ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;
774-- ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;
775setDefault
775setDefault
776− :: Expression '[] 'Ungrouped '[] schemas '[] '[] ty -- ^ default value to set
776+ :: Expression '[] '[] 'Ungrouped schemas '[] '[] ty -- ^ default value to set
777 -> AlterColumn schemas (constraint :=> ty) ('Def :=> ty)
777 -> AlterColumn schemas (constraint :=> ty) ('Def :=> ty)
778setDefault expression = UnsafeAlterColumn $
778setDefault expression = UnsafeAlterColumn $
779 "SET DEFAULT" <+> renderExpression expression
779 "SET DEFAULT" <+> renderExpression expression
@@ -1003,7 +1003,7 @@ createDomain
1003 :: (Has sch schemas schema, KnownSymbol dom)
1003 :: (Has sch schemas schema, KnownSymbol dom)
1004 => QualifiedAlias sch dom
1004 => QualifiedAlias sch dom
1005 -> (forall nullity. TypeExpression schemas (nullity ty))
1005 -> (forall nullity. TypeExpression schemas (nullity ty))
1006− -> (forall tab. Condition '[] 'Ungrouped '[] schemas '[] '[tab ::: '["value" ::: 'Null ty]])
1006+ -> (forall tab. Condition '[] '[] 'Ungrouped schemas '[] '[tab ::: '["value" ::: 'Null ty]])
1007 -> Definition schemas (Alter sch (Create alias ('Typedef ty) schema) schemas)
1007 -> Definition schemas (Alter sch (Create alias ('Typedef ty) schema) schemas)
1008createDomain dom ty condition =
1008createDomain dom ty condition =
1009 UnsafeDefinition $ "CREATE DOMAIN" <+> renderSQL dom
1009 UnsafeDefinition $ "CREATE DOMAIN" <+> renderSQL dom
@@ -1053,7 +1053,7 @@ notNullable ty = UnsafeColumnTypeExpression $ renderSQL ty <+> "NOT NULL"
1053
1053
1054-- | used in `createTable` commands as a column constraint to give a default
1054-- | used in `createTable` commands as a column constraint to give a default
1055default_
1055default_
1056− :: Expression '[] 'Ungrouped '[] schemas '[] '[] ty
1056+ :: Expression '[] '[] 'Ungrouped schemas '[] '[] ty
1057 -> ColumnTypeExpression schemas ('NoDef :=> ty)
1057 -> ColumnTypeExpression schemas ('NoDef :=> ty)
1058 -> ColumnTypeExpression schemas ('Def :=> ty)
1058 -> ColumnTypeExpression schemas ('Def :=> ty)
1059default_ x ty = UnsafeColumnTypeExpression $
1059default_ x ty = UnsafeColumnTypeExpression $
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+195−195
@@ -293,15 +293,15 @@ and other operations.
293-}
293-}
294newtype Expression
294newtype Expression
295 (outer :: FromType)
295 (outer :: FromType)
296− (grp :: Grouping)
297 (commons :: FromType)
296 (commons :: FromType)
297+ (grp :: Grouping)
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
306
306
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
317
317
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
327
327
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
339
339
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)
345-}
345-}
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
352
352
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.
355-}
355-}
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
364
364
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`.
386 --
386 --
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`.
402--
402--
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)
406param
406param
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)
411
411
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
426
426
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
442
442
443instance
443instance
@@ -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)
450instance
450instance
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
458instance
458instance
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
466instance
466instance
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
474
474
475instance
475instance
@@ -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
483instance
483instance
@@ -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
491instance
491instance
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
499instance
499instance
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
507
507
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)
535fromNull
535fromNull
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
541
541
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
556matchNull
556matchNull
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)))
566
566
@@ -568,7 +568,7 @@ matchNull y f x = ifThenElse (isNull x) y
568`nullIf` gives @NULL@.
568`nullIf` gives @NULL@.
569
569
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))
574-}
574-}
@@ -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]
580array
580array
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))
586
586
@@ -593,8 +593,8 @@ ARRAY[NULL, FALSE, TRUE]
593array1 (null_ :* false *: true)
593array1 (null_ :* false *: true)
594 :: Expression
594 :: Expression
595 outer
595 outer
596− grp
597 commons
596 commons
597+ grp
598 schemas
598 schemas
599 params
599 params
600 from
600 from
@@ -602,8 +602,8 @@ array1 (null_ :* false *: true)
602-}
602-}
603array1
603array1
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)
609
609
@@ -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
618 outer
618 outer
619− grp
620 commons
619 commons
620+ grp
621 schemas
621 schemas
622 params
622 params
623 from
623 from
@@ -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)
636
636
@@ -648,7 +648,7 @@ index n expr = UnsafeExpression $
648 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
648 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
649
649
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)
653
653
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 ]
661-- :}
661-- :}
662--
662--
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)
666row
666row
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)
673
673
@@ -678,7 +678,7 @@ row exprs = UnsafeExpression $ "ROW" <> parenthesized
678-- type Schema = '["complex" ::: 'Typedef Complex]
678-- type Schema = '["complex" ::: 'Typedef Complex]
679-- :}
679-- :}
680--
680--
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"
684field
684field
@@ -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
695
695
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 "||"
699
699
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 = (<>)
704
704
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)
746
746
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
757 . show
757 . show
758
758
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
768
768
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"
809cast
809cast
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
817
817
@@ -819,7 +819,7 @@ cast ty x = UnsafeExpression $ parenthesized $
819--
819--
820-- >>> :{
820-- >>> :{
821-- let
821-- let
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
825-- :}
825-- :}
@@ -833,7 +833,7 @@ quot_ = unsafeBinaryOp "/"
833--
833--
834-- >>> :{
834-- >>> :{
835-- let
835-- let
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
839-- :}
839-- :}
@@ -845,7 +845,7 @@ rem_ = unsafeBinaryOp "%"
845
845
846-- | >>> :{
846-- | >>> :{
847-- let
847-- let
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
851-- :}
851-- :}
@@ -855,7 +855,7 @@ trunc = unsafeFunction "trunc"
855
855
856-- | >>> :{
856-- | >>> :{
857-- let
857-- let
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
861-- :}
861-- :}
@@ -865,7 +865,7 @@ round_ = unsafeFunction "round"
865
865
866-- | >>> :{
866-- | >>> :{
867-- let
867-- let
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
871-- :}
871-- :}
@@ -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)
881
881
882-- | >>> printSQL true
882-- | >>> printSQL true
883-- TRUE
883-- TRUE
@@ -908,19 +908,19 @@ infixr 2 .||
908
908
909-- | >>> :{
909-- | >>> :{
910-- let
910-- let
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
914-- :}
914-- :}
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
919 ) ]
919 ) ]
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
925 [ "CASE"
925 [ "CASE"
926 , mconcat
926 , mconcat
@@ -936,16 +936,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
936
936
937-- | >>> :{
937-- | >>> :{
938-- let
938-- let
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
942-- :}
942-- :}
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_
950
950
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
992-}
992-}
993between
993between
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
1000
1000
@@ -1002,10 +1002,10 @@ between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
1002TRUE NOT BETWEEN NULL AND FALSE
1002TRUE NOT BETWEEN NULL AND FALSE
1003-}
1003-}
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
1011
1011
@@ -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
1016-}
1016-}
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
1024
1024
@@ -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
1029-}
1029-}
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
1037
1037
@@ -1148,31 +1148,31 @@ escape = \case
1148 c -> [c]
1148 c -> [c]
1149
1149
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) <> "\'"
1162
1162
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 "||"
1169
1169
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 = (<>)
1178
1178
@@ -1282,7 +1282,7 @@ infixl 9 .?&
1282
1282
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 "||"
1287
1287
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)
1440
1440
@@ -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)
1450
1450
@@ -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)
1460
1460
@@ -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)
1470
1470
@@ -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.
1498jsonbSet
1498jsonbSet
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
1610
1610
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
1617
1617
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
1624
1624
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
1638 --
1638 --
1639 -- >>> :{
1639 -- >>> :{
1640 -- let
1640 -- let
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
1644 -- :}
1644 -- :}
@@ -1647,7 +1647,7 @@ class Aggregate expr1 exprHet aggr
1647
1647
1648 -- | >>> :{
1648 -- | >>> :{
1649 -- let
1649 -- let
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
1653 -- :}
1653 -- :}
@@ -1659,7 +1659,7 @@ class Aggregate expr1 exprHet aggr
1659
1659
1660 -- | >>> :{
1660 -- | >>> :{
1661 -- let
1661 -- let
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
1665 -- :}
1665 -- :}
@@ -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
1689 >>> :{
1689 >>> :{
1690 let
1690 let
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
1694 :}
1694 :}
@@ -1705,7 +1705,7 @@ class Aggregate expr1 exprHet aggr
1705
1705
1706 >>> :{
1706 >>> :{
1707 let
1707 let
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
1711 :}
1711 :}
@@ -1722,7 +1722,7 @@ class Aggregate expr1 exprHet aggr
1722
1722
1723 >>> :{
1723 >>> :{
1724 let
1724 let
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
1728 :}
1728 :}
@@ -1738,7 +1738,7 @@ class Aggregate expr1 exprHet aggr
1738
1738
1739 >>> :{
1739 >>> :{
1740 let
1740 let
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
1744 :}
1744 :}
@@ -1754,7 +1754,7 @@ class Aggregate expr1 exprHet aggr
1754
1754
1755 >>> :{
1755 >>> :{
1756 let
1756 let
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
1760 :}
1760 :}
@@ -1786,7 +1786,7 @@ class Aggregate expr1 exprHet aggr
1786 {- | correlation coefficient
1786 {- | correlation coefficient
1787 >>> :{
1787 >>> :{
1788 let
1788 let
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
1792 :}
1792 :}
@@ -1799,7 +1799,7 @@ class Aggregate expr1 exprHet aggr
1799 {- | population covariance
1799 {- | population covariance
1800 >>> :{
1800 >>> :{
1801 let
1801 let
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
1805 :}
1805 :}
@@ -1812,7 +1812,7 @@ class Aggregate expr1 exprHet aggr
1812 {- | sample covariance
1812 {- | sample covariance
1813 >>> :{
1813 >>> :{
1814 let
1814 let
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
1818 :}
1818 :}
@@ -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)
1826 >>> :{
1826 >>> :{
1827 let
1827 let
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
1831 :}
1831 :}
@@ -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)
1839 >>> :{
1839 >>> :{
1840 let
1840 let
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
1844 :}
1844 :}
@@ -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
1852 >>> :{
1852 >>> :{
1853 let
1853 let
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
1857 :}
1857 :}
@@ -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
1865 >>> :{
1865 >>> :{
1866 let
1866 let
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
1870 :}
1870 :}
@@ -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
1958
1958
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
2244 Asc
2244 Asc
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
2247 Desc
2247 Desc
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)
2263
2263
2264{- |
2264{- |
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`.
2274-}
2274-}
2275class OrderBy expr where
2275class OrderBy expr where
2276 orderBy
2276 orderBy
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
2280
2280
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
2292
2292
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
2301
2301
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.
2323-}
2323-}
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 []
2329
2329
2330{- |
2330{- |
@@ -2339,8 +2339,8 @@ just the current row of the query result.
2339-}
2339-}
2340newtype WindowFunction
2340newtype WindowFunction
2341 (outer :: FromType)
2341 (outer :: FromType)
2342− (grp :: Grouping)
2343 (commons :: FromType)
2342 (commons :: FromType)
2343+ (grp :: Grouping)
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)
2350
2350
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
2353
2353
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
2358
2358
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
2365
2365
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
2372
2372
2373unsafeWindowFunction1 :: ByteString -> WinFun1 x y
2373unsafeWindowFunction1 :: ByteString -> WinFun1 x y
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+11−11
@@ -269,7 +269,7 @@ data QueryClause commons schemas params columns where
269 Select
269 Select
270 :: SOP.SListI columns
270 :: SOP.SListI columns
271 => NP (ColumnExpression grp schemas params from) columns
271 => NP (ColumnExpression grp schemas params from) columns
272− -> TableExpression '[] grp commons schemas params from
272+ -> TableExpression '[] commons grp schemas params from
273 -> QueryClause commons schemas params columns
273 -> QueryClause commons schemas params columns
274 Subquery
274 Subquery
275 :: ColumnsToRow columns ~ row
275 :: ColumnsToRow columns ~ row
@@ -320,17 +320,17 @@ data ColumnExpression grp schemas params from column where
320 => Alias col
320 => Alias col
321 -> ColumnExpression grp schemas params from (col ::: 'Def :=> ty)
321 -> ColumnExpression grp schemas params from (col ::: 'Def :=> ty)
322 Specific
322 Specific
323− :: Aliased (Expression '[] grp '[] schemas params from) (col ::: ty)
323+ :: Aliased (Expression '[] '[] grp schemas params from) (col ::: ty)
324 -> ColumnExpression grp schemas params from (col ::: defness :=> ty)
324 -> ColumnExpression grp schemas params from (col ::: defness :=> ty)
325
325
326instance (KnownSymbol col, column ~ (col ::: defness :=> ty))
326instance (KnownSymbol col, column ~ (col ::: defness :=> ty))
327 => Aliasable col
327 => Aliasable col
328− (Expression '[] grp '[] schemas params from ty)
328+ (Expression '[] '[] grp schemas params from ty)
329 (ColumnExpression grp schemas params from column) where
329 (ColumnExpression grp schemas params from column) where
330 expression `as` col = Specific (expression `As` col)
330 expression `as` col = Specific (expression `As` col)
331instance (KnownSymbol col, columns ~ '[col ::: defness :=> ty])
331instance (KnownSymbol col, columns ~ '[col ::: defness :=> ty])
332 => Aliasable col
332 => Aliasable col
333− (Expression '[] grp '[] schemas params from ty)
333+ (Expression '[] '[] grp schemas params from ty)
334 (NP (ColumnExpression grp schemas params from) columns) where
334 (NP (ColumnExpression grp schemas params from) columns) where
335 expression `as` col = expression `as` col :* Nil
335 expression `as` col = expression `as` col :* Nil
336instance (KnownSymbol col, column ~ (col ::: 'Def :=> ty))
336instance (KnownSymbol col, column ~ (col ::: 'Def :=> ty))
@@ -407,7 +407,7 @@ instance RenderSQL (ColumnExpression grp schemas params from column) where
407-- in the row. Use @Returning Nil@ in the common case where no return
407-- in the row. Use @Returning Nil@ in the common case where no return
408-- values are desired.
408-- values are desired.
409newtype ReturningClause commons schemas params from row =
409newtype ReturningClause commons schemas params from row =
410− Returning (Selection '[] 'Ungrouped commons schemas params from row)
410+ Returning (Selection '[] commons 'Ungrouped schemas params from row)
411
411
412instance RenderSQL (ReturningClause commons schemas params from row) where
412instance RenderSQL (ReturningClause commons schemas params from row) where
413 renderSQL = \case
413 renderSQL = \case
@@ -416,7 +416,7 @@ instance RenderSQL (ReturningClause commons schemas params from row) where
416
416
417pattern Returning_
417pattern Returning_
418 :: SOP.SListI row
418 :: SOP.SListI row
419− => NP (Aliased (Expression '[] 'Ungrouped commons schemas params from)) row
419+ => NP (Aliased (Expression '[] commons 'Ungrouped schemas params from)) row
420 -> ReturningClause commons schemas params from row
420 -> ReturningClause commons schemas params from row
421pattern Returning_ list = Returning (List list)
421pattern Returning_ list = Returning (List list)
422
422
@@ -449,7 +449,7 @@ data ConflictAction tab commons schemas params columns where
449 , SOP.All (HasIn columns) subcolumns
449 , SOP.All (HasIn columns) subcolumns
450 , AllUnique subcolumns )
450 , AllUnique subcolumns )
451 => NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row, "excluded" ::: row]) subcolumns
451 => NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row, "excluded" ::: row]) subcolumns
452− -> [Condition '[] 'Ungrouped commons schemas params '[tab ::: row, "excluded" ::: row]]
452+ -> [Condition '[] commons 'Ungrouped schemas params '[tab ::: row, "excluded" ::: row]]
453 -> ConflictAction tab commons schemas params columns
453 -> ConflictAction tab commons schemas params columns
454
454
455instance RenderSQL (ConflictAction tab commons schemas params columns) where
455instance RenderSQL (ConflictAction tab commons schemas params columns) where
@@ -494,7 +494,7 @@ update
494 => QualifiedAlias sch tab -- ^ table to update
494 => QualifiedAlias sch tab -- ^ table to update
495 -> NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row0]) subcolumns
495 -> NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row0]) subcolumns
496 -- ^ modified values to replace old values
496 -- ^ modified values to replace old values
497− -> Condition '[] 'Ungrouped commons schemas params '[tab ::: row0]
497+ -> Condition '[] commons 'Ungrouped schemas params '[tab ::: row0]
498 -- ^ condition under which to perform update on a row
498 -- ^ condition under which to perform update on a row
499 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
499 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
500 -> Manipulation commons schemas params row1
500 -> Manipulation commons schemas params row1
@@ -519,7 +519,7 @@ update_
519 => QualifiedAlias sch tab -- ^ table to update
519 => QualifiedAlias sch tab -- ^ table to update
520 -> NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row]) subcolumns
520 -> NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row]) subcolumns
521 -- ^ modified values to replace old values
521 -- ^ modified values to replace old values
522− -> Condition '[] 'Ungrouped commons schemas params '[tab ::: row]
522+ -> Condition '[] commons 'Ungrouped schemas params '[tab ::: row]
523 -- ^ condition under which to perform update on a row
523 -- ^ condition under which to perform update on a row
524 -> Manipulation commons schemas params '[]
524 -> Manipulation commons schemas params '[]
525update_ tab columns wh = update tab columns wh (Returning_ Nil)
525update_ tab columns wh = update tab columns wh (Returning_ Nil)
@@ -544,7 +544,7 @@ deleteFrom
544 , columns ~ TableToColumns table )
544 , columns ~ TableToColumns table )
545 => QualifiedAlias sch tab -- ^ table to delete from
545 => QualifiedAlias sch tab -- ^ table to delete from
546 -> UsingClause commons schemas params from
546 -> UsingClause commons schemas params from
547− -> Condition '[] 'Ungrouped commons schemas params (tab ::: row0 ': from)
547+ -> Condition '[] commons 'Ungrouped schemas params (tab ::: row0 ': from)
548 -- ^ condition under which to delete a row
548 -- ^ condition under which to delete a row
549 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
549 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
550 -> Manipulation commons schemas params row1
550 -> Manipulation commons schemas params row1
@@ -565,7 +565,7 @@ deleteFrom_
565 , row ~ TableToRow table
565 , row ~ TableToRow table
566 , columns ~ TableToColumns table )
566 , columns ~ TableToColumns table )
567 => QualifiedAlias sch tab -- ^ table to delete from
567 => QualifiedAlias sch tab -- ^ table to delete from
568− -> Condition '[] 'Ungrouped commons schemas params '[tab ::: row]
568+ -> Condition '[] commons 'Ungrouped schemas params '[tab ::: row]
569 -- ^ condition under which to delete a row
569 -- ^ condition under which to delete a row
570 -> Manipulation commons schemas params '[]
570 -> Manipulation commons schemas params '[]
571deleteFrom_ tab wh = deleteFrom tab NoUsing wh (Returning_ Nil)
571deleteFrom_ tab wh = deleteFrom tab NoUsing wh (Returning_ Nil)
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+91−91
@@ -403,35 +403,35 @@ q1 `exceptAll` q2 = UnsafeQuery $
403SELECT queries
403SELECT queries
404-----------------------------------------}
404-----------------------------------------}
405
405
406−data Selection outer grp commons schemas params from row where
406+data Selection outer commons grp schemas params from row where
407 List
407 List
408 :: SListI row
408 :: SListI row
409− => NP (Aliased (Expression outer grp commons schemas params from)) row
409+ => NP (Aliased (Expression outer commons grp schemas params from)) row
410− -> Selection outer grp commons schemas params from row
410+ -> Selection outer commons grp schemas params from row
411 Star
411 Star
412 :: HasUnique tab from row
412 :: HasUnique tab from row
413− => Selection outer 'Ungrouped commons schemas params from row
413+ => Selection outer commons 'Ungrouped schemas params from row
414 DotStar
414 DotStar
415 :: Has tab from row
415 :: Has tab from row
416 => Alias tab
416 => Alias tab
417− -> Selection outer 'Ungrouped commons schemas params from row
417+ -> Selection outer commons 'Ungrouped schemas params from row
418 Also
418 Also
419− :: Selection outer grp commons schemas params from right
419+ :: Selection outer commons grp schemas params from right
420− -> Selection outer grp commons schemas params from left
420+ -> Selection outer commons grp schemas params from left
421− -> Selection outer grp commons schemas params from (Join left right)
421+ -> Selection outer commons grp schemas params from (Join left right)
422 Over
422 Over
423 :: SListI row
423 :: SListI row
424− => NP (Aliased (WindowFunction outer grp commons schemas params from)) row
424+ => NP (Aliased (WindowFunction outer commons grp schemas params from)) row
425− -> WindowDefinition outer grp commons schemas params from
425+ -> WindowDefinition outer commons grp schemas params from
426− -> Selection outer grp commons schemas params from row
426+ -> Selection outer commons grp schemas params from row
427instance (KnownSymbol col, row ~ '[col ::: ty])
427instance (KnownSymbol col, row ~ '[col ::: ty])
428 => Aliasable col
428 => Aliasable col
429− (Expression outer grp commons schemas params from ty)
429+ (Expression outer commons grp schemas params from ty)
430− (Selection outer grp commons schemas params from row) where
430+ (Selection outer commons grp schemas params from row) where
431 expr `as` col = List (expr `as` col)
431 expr `as` col = List (expr `as` col)
432instance (Has tab (Join outer from) row0, Has col row0 ty, row1 ~ '[col ::: ty])
432instance (Has tab (Join outer from) row0, Has col row0 ty, row1 ~ '[col ::: ty])
433 => IsQualified tab col
433 => IsQualified tab col
434− (Selection outer 'Ungrouped commons schemas params from row1) where
434+ (Selection outer commons 'Ungrouped schemas params from row1) where
435 tab ! col = tab ! col `as` col
435 tab ! col = tab ! col `as` col
436instance
436instance
437 ( Has tab (Join outer from) row0
437 ( Has tab (Join outer from) row0
@@ -439,11 +439,11 @@ instance
439 , row1 ~ '[col ::: ty]
439 , row1 ~ '[col ::: ty]
440 , GroupedBy tab col bys )
440 , GroupedBy tab col bys )
441 => IsQualified tab col
441 => IsQualified tab col
442− (Selection outer ('Grouped bys) commons schemas params from row1) where
442+ (Selection outer commons ('Grouped bys) schemas params from row1) where
443 tab ! col = tab ! col `as` col
443 tab ! col = tab ! col `as` col
444instance (HasUnique tab (Join outer from) row0, Has col row0 ty, row1 ~ '[col ::: ty])
444instance (HasUnique tab (Join outer from) row0, Has col row0 ty, row1 ~ '[col ::: ty])
445 => IsLabel col
445 => IsLabel col
446− (Selection outer 'Ungrouped commons schemas params from row1) where
446+ (Selection outer commons 'Ungrouped schemas params from row1) where
447 fromLabel = fromLabel @col `as` Alias
447 fromLabel = fromLabel @col `as` Alias
448instance
448instance
449 ( HasUnique tab (Join outer from) row0
449 ( HasUnique tab (Join outer from) row0
@@ -451,10 +451,10 @@ instance
451 , row1 ~ '[col ::: ty]
451 , row1 ~ '[col ::: ty]
452 , GroupedBy tab col bys )
452 , GroupedBy tab col bys )
453 => IsLabel col
453 => IsLabel col
454− (Selection outer ('Grouped bys) commons schemas params from row1) where
454+ (Selection outer commons ('Grouped bys) schemas params from row1) where
455 fromLabel = fromLabel @col `as` Alias
455 fromLabel = fromLabel @col `as` Alias
456
456
457−instance RenderSQL (Selection outer grp commons schemas params from row) where
457+instance RenderSQL (Selection outer commons grp schemas params from row) where
458 renderSQL = \case
458 renderSQL = \case
459 List list -> renderCommaSeparated (renderAliased renderSQL) list
459 List list -> renderCommaSeparated (renderAliased renderSQL) list
460 Star -> "*"
460 Star -> "*"
@@ -463,7 +463,7 @@ instance RenderSQL (Selection outer grp commons schemas params from row) where
463 Over winFns winDef ->
463 Over winFns winDef ->
464 let
464 let
465 renderOver
465 renderOver
466− :: Aliased (WindowFunction outer grp commons schemas params from) field
466+ :: Aliased (WindowFunction outer commons grp schemas params from) field
467 -> ByteString
467 -> ByteString
468 renderOver (winFn `As` col) = renderSQL winFn
468 renderOver (winFn `As` col) = renderSQL winFn
469 <+> "OVER" <+> parenthesized (renderSQL winDef)
469 <+> "OVER" <+> parenthesized (renderSQL winDef)
@@ -472,7 +472,7 @@ instance RenderSQL (Selection outer grp commons schemas params from row) where
472 renderCommaSeparated renderOver winFns
472 renderCommaSeparated renderOver winFns
473
473
474instance IsString
474instance IsString
475− (Selection outer grp commons schemas params from '["fromOnly" ::: 'NotNull 'PGtext]) where
475+ (Selection outer commons grp schemas params from '["fromOnly" ::: 'NotNull 'PGtext]) where
476 fromString str = fromString str `as` Alias
476 fromString str = fromString str `as` Alias
477
477
478-- | the `TableExpression` in the `select` command constructs an intermediate
478-- | the `TableExpression` in the `select` command constructs an intermediate
@@ -482,9 +482,9 @@ instance IsString
482-- the intermediate table are actually output.
482-- the intermediate table are actually output.
483select
483select
484 :: (SListI row, row ~ (x ': xs))
484 :: (SListI row, row ~ (x ': xs))
485− => Selection outer grp commons schemas params from row
485+ => Selection outer commons grp schemas params from row
486 -- ^ select list
486 -- ^ select list
487− -> TableExpression outer grp commons schemas params from
487+ -> TableExpression outer commons grp schemas params from
488 -- ^ intermediate virtual table
488 -- ^ intermediate virtual table
489 -> Query outer commons schemas params row
489 -> Query outer commons schemas params row
490select selection tabexpr = UnsafeQuery $
490select selection tabexpr = UnsafeQuery $
@@ -494,8 +494,8 @@ select selection tabexpr = UnsafeQuery $
494
494
495select_
495select_
496 :: (SListI row, row ~ (x ': xs))
496 :: (SListI row, row ~ (x ': xs))
497− => NP (Aliased (Expression outer grp commons schemas params from)) row
497+ => NP (Aliased (Expression outer commons grp schemas params from)) row
498− -> TableExpression outer grp commons schemas params from
498+ -> TableExpression outer commons grp schemas params from
499 -> Query outer commons schemas params row
499 -> Query outer commons schemas params row
500select_ list = select (List list)
500select_ list = select (List list)
501
501
@@ -503,9 +503,9 @@ select_ list = select (List list)
503-- be subject to the elimination of duplicate rows using `selectDistinct`.
503-- be subject to the elimination of duplicate rows using `selectDistinct`.
504selectDistinct
504selectDistinct
505 :: (SListI columns, columns ~ (col ': cols))
505 :: (SListI columns, columns ~ (col ': cols))
506− => Selection outer 'Ungrouped commons schemas params from columns
506+ => Selection outer commons 'Ungrouped schemas params from columns
507 -- ^ select list
507 -- ^ select list
508− -> TableExpression outer 'Ungrouped commons schemas params from
508+ -> TableExpression outer commons 'Ungrouped schemas params from
509 -- ^ intermediate virtual table
509 -- ^ intermediate virtual table
510 -> Query outer commons schemas params columns
510 -> Query outer commons schemas params columns
511selectDistinct selection tabexpr = UnsafeQuery $
511selectDistinct selection tabexpr = UnsafeQuery $
@@ -515,9 +515,9 @@ selectDistinct selection tabexpr = UnsafeQuery $
515
515
516selectDistinct_
516selectDistinct_
517 :: (SListI columns, columns ~ (col ': cols))
517 :: (SListI columns, columns ~ (col ': cols))
518− => NP (Aliased (Expression outer 'Ungrouped commons schemas params from)) columns
518+ => NP (Aliased (Expression outer commons 'Ungrouped schemas params from)) columns
519 -- ^ select list
519 -- ^ select list
520− -> TableExpression outer 'Ungrouped commons schemas params from
520+ -> TableExpression outer commons 'Ungrouped schemas params from
521 -- ^ intermediate virtual table
521 -- ^ intermediate virtual table
522 -> Query outer commons schemas params columns
522 -> Query outer commons schemas params columns
523selectDistinct_ list = select (List list)
523selectDistinct_ list = select (List list)
@@ -533,8 +533,8 @@ selectDistinct_ list = select (List list)
533-- SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
533-- SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
534values
534values
535 :: SListI cols
535 :: SListI cols
536− => NP (Aliased (Expression outer 'Ungrouped commons schemas params '[] )) cols
536+ => NP (Aliased (Expression outer commons 'Ungrouped schemas params '[] )) cols
537− -> [NP (Aliased (Expression outer 'Ungrouped commons schemas params '[] )) cols]
537+ -> [NP (Aliased (Expression outer commons 'Ungrouped schemas params '[] )) cols]
538 -- ^ When more than one row is specified, all the rows must
538 -- ^ When more than one row is specified, all the rows must
539 -- must have the same number of elements
539 -- must have the same number of elements
540 -> Query outer commons schemas params cols
540 -> Query outer commons schemas params cols
@@ -548,7 +548,7 @@ values rw rws = UnsafeQuery $ "SELECT * FROM"
548 <+> parenthesized (renderCommaSeparated renderAliasPart rw)
548 <+> parenthesized (renderCommaSeparated renderAliasPart rw)
549 where
549 where
550 renderAliasPart, renderValuePart
550 renderAliasPart, renderValuePart
551− :: Aliased (Expression outer 'Ungrouped commons schemas params '[] ) ty -> ByteString
551+ :: Aliased (Expression outer commons 'Ungrouped schemas params '[] ) ty -> ByteString
552 renderAliasPart (_ `As` name) = renderSQL name
552 renderAliasPart (_ `As` name) = renderSQL name
553 renderValuePart (value `As` _) = renderSQL value
553 renderValuePart (value `As` _) = renderSQL value
554
554
@@ -556,7 +556,7 @@ values rw rws = UnsafeQuery $ "SELECT * FROM"
556-- specified by value expressions.
556-- specified by value expressions.
557values_
557values_
558 :: SListI cols
558 :: SListI cols
559− => NP (Aliased (Expression outer 'Ungrouped commons schemas params '[] )) cols
559+ => NP (Aliased (Expression outer commons 'Ungrouped schemas params '[] )) cols
560 -- ^ one row of values
560 -- ^ one row of values
561 -> Query outer commons schemas params cols
561 -> Query outer commons schemas params cols
562values_ rw = values rw []
562values_ rw = values rw []
@@ -573,8 +573,8 @@ Table Expressions
573-- can be used to modify or combine base tables in various ways.
573-- can be used to modify or combine base tables in various ways.
574data TableExpression
574data TableExpression
575 (outer :: FromType)
575 (outer :: FromType)
576− (grp :: Grouping)
577 (commons :: FromType)
576 (commons :: FromType)
577+ (grp :: Grouping)
578 (schemas :: SchemasType)
578 (schemas :: SchemasType)
579 (params :: [NullityType])
579 (params :: [NullityType])
580 (from :: FromType)
580 (from :: FromType)
@@ -582,7 +582,7 @@ data TableExpression
582 { fromClause :: FromClause outer commons schemas params from
582 { fromClause :: FromClause outer commons schemas params from
583 -- ^ A table reference that can be a table name, or a derived table such
583 -- ^ A table reference that can be a table name, or a derived table such
584 -- as a subquery, a @JOIN@ construct, or complex combinations of these.
584 -- as a subquery, a @JOIN@ construct, or complex combinations of these.
585− , whereClause :: [Condition outer 'Ungrouped commons schemas params from]
585+ , whereClause :: [Condition outer commons 'Ungrouped schemas params from]
586 -- ^ optional search coditions, combined with `.&&`. After the processing
586 -- ^ optional search coditions, combined with `.&&`. After the processing
587 -- of the `fromClause` is done, each row of the derived virtual table
587 -- of the `fromClause` is done, each row of the derived virtual table
588 -- is checked against the search condition. If the result of the
588 -- is checked against the search condition. If the result of the
@@ -598,13 +598,13 @@ data TableExpression
598 -- set of rows having common values into one group row that represents all
598 -- set of rows having common values into one group row that represents all
599 -- rows in the group. This is done to eliminate redundancy in the output
599 -- rows in the group. This is done to eliminate redundancy in the output
600 -- and/or compute aggregates that apply to these groups.
600 -- and/or compute aggregates that apply to these groups.
601− , havingClause :: HavingClause outer grp commons schemas params from
601+ , havingClause :: HavingClause outer commons grp schemas params from
602 -- ^ If a table has been grouped using `groupBy`, but only certain groups
602 -- ^ If a table has been grouped using `groupBy`, but only certain groups
603 -- are of interest, the `havingClause` can be used, much like a
603 -- are of interest, the `havingClause` can be used, much like a
604 -- `whereClause`, to eliminate groups from the result. Expressions in the
604 -- `whereClause`, to eliminate groups from the result. Expressions in the
605 -- `havingClause` can refer both to grouped expressions and to ungrouped
605 -- `havingClause` can refer both to grouped expressions and to ungrouped
606 -- expressions (which necessarily involve an aggregate function).
606 -- expressions (which necessarily involve an aggregate function).
607− , orderByClause :: [SortExpression outer grp commons schemas params from]
607+ , orderByClause :: [SortExpression outer commons grp schemas params from]
608 -- ^ The `orderByClause` is for optional sorting. When more than one
608 -- ^ The `orderByClause` is for optional sorting. When more than one
609 -- `SortExpression` is specified, the later (right) values are used to sort
609 -- `SortExpression` is specified, the later (right) values are used to sort
610 -- rows that are equal according to the earlier (left) values.
610 -- rows that are equal according to the earlier (left) values.
@@ -621,7 +621,7 @@ data TableExpression
621 } deriving (GHC.Generic)
621 } deriving (GHC.Generic)
622
622
623-- | Render a `TableExpression`
623-- | Render a `TableExpression`
624−instance RenderSQL (TableExpression outer grp commons schemas params from) where
624+instance RenderSQL (TableExpression outer commons grp schemas params from) where
625 renderSQL
625 renderSQL
626 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
626 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
627 [ "FROM ", renderSQL frm'
627 [ "FROM ", renderSQL frm'
@@ -654,15 +654,15 @@ instance RenderSQL (TableExpression outer grp commons schemas params from) where
654-- to match the left-to-right sequencing of their placement in SQL.
654-- to match the left-to-right sequencing of their placement in SQL.
655from
655from
656 :: FromClause outer commons schemas params from -- ^ table reference
656 :: FromClause outer commons schemas params from -- ^ table reference
657− -> TableExpression outer 'Ungrouped commons schemas params from
657+ -> TableExpression outer commons 'Ungrouped schemas params from
658from tab = TableExpression tab [] NoGroups NoHaving [] [] []
658from tab = TableExpression tab [] NoGroups NoHaving [] [] []
659
659
660-- | A `where_` is an endomorphism of `TableExpression`s which adds a
660-- | A `where_` is an endomorphism of `TableExpression`s which adds a
661-- search condition to the `whereClause`.
661-- search condition to the `whereClause`.
662where_
662where_
663− :: Condition outer 'Ungrouped commons schemas params from -- ^ filtering condition
663+ :: Condition outer commons 'Ungrouped schemas params from -- ^ filtering condition
664− -> TableExpression outer grp commons schemas params from
664+ -> TableExpression outer commons grp schemas params from
665− -> TableExpression outer grp commons schemas params from
665+ -> TableExpression outer commons grp schemas params from
666where_ wh rels = rels {whereClause = wh : whereClause rels}
666where_ wh rels = rels {whereClause = wh : whereClause rels}
667
667
668-- | A `groupBy` is a transformation of `TableExpression`s which switches
668-- | A `groupBy` is a transformation of `TableExpression`s which switches
@@ -671,8 +671,8 @@ where_ wh rels = rels {whereClause = wh : whereClause rels}
671groupBy
671groupBy
672 :: SListI bys
672 :: SListI bys
673 => NP (By from) bys -- ^ grouped columns
673 => NP (By from) bys -- ^ grouped columns
674− -> TableExpression outer 'Ungrouped commons schemas params from
674+ -> TableExpression outer commons 'Ungrouped schemas params from
675− -> TableExpression outer ('Grouped bys) commons schemas params from
675+ -> TableExpression outer commons ('Grouped bys) schemas params from
676groupBy bys rels = TableExpression
676groupBy bys rels = TableExpression
677 { fromClause = fromClause rels
677 { fromClause = fromClause rels
678 , whereClause = whereClause rels
678 , whereClause = whereClause rels
@@ -686,9 +686,9 @@ groupBy bys rels = TableExpression
686-- | A `having` is an endomorphism of `TableExpression`s which adds a
686-- | A `having` is an endomorphism of `TableExpression`s which adds a
687-- search condition to the `havingClause`.
687-- search condition to the `havingClause`.
688having
688having
689− :: Condition outer ('Grouped bys) commons schemas params from -- ^ having condition
689+ :: Condition outer commons ('Grouped bys) schemas params from -- ^ having condition
690− -> TableExpression outer ('Grouped bys) commons schemas params from
690+ -> TableExpression outer commons ('Grouped bys) schemas params from
691− -> TableExpression outer ('Grouped bys) commons schemas params from
691+ -> TableExpression outer commons ('Grouped bys) schemas params from
692having hv rels = rels
692having hv rels = rels
693 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
693 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
694
694
@@ -699,16 +699,16 @@ instance OrderBy TableExpression where
699-- `limitClause`.
699-- `limitClause`.
700limit
700limit
701 :: Word64 -- ^ limit parameter
701 :: Word64 -- ^ limit parameter
702− -> TableExpression outer grp commons schemas params from
702+ -> TableExpression outer commons grp schemas params from
703− -> TableExpression outer grp commons schemas params from
703+ -> TableExpression outer commons grp schemas params from
704limit lim rels = rels {limitClause = lim : limitClause rels}
704limit lim rels = rels {limitClause = lim : limitClause rels}
705
705
706-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
706-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
707-- `offsetClause`.
707-- `offsetClause`.
708offset
708offset
709 :: Word64 -- ^ offset parameter
709 :: Word64 -- ^ offset parameter
710− -> TableExpression outer grp commons schemas params from
710+ -> TableExpression outer commons grp schemas params from
711− -> TableExpression outer grp commons schemas params from
711+ -> TableExpression outer commons grp schemas params from
712offset off rels = rels {offsetClause = off : offsetClause rels}
712offset off rels = rels {offsetClause = off : offsetClause rels}
713
713
714{-----------------------------------------
714{-----------------------------------------
@@ -717,14 +717,14 @@ JSON stuff
717
717
718unsafeSetOfFunction
718unsafeSetOfFunction
719 :: ByteString
719 :: ByteString
720− -> Expression outer 'Ungrouped commons schemas params '[] ty
720+ -> Expression outer commons 'Ungrouped schemas params '[] ty
721 -> FromClause outer commons schemas params from
721 -> FromClause outer commons schemas params from
722unsafeSetOfFunction fun expr = UnsafeFromClause $
722unsafeSetOfFunction fun expr = UnsafeFromClause $
723 fun <> "(" <> renderSQL expr <> ")"
723 fun <> "(" <> renderSQL expr <> ")"
724
724
725-- | Expand an array to a set of rows
725-- | Expand an array to a set of rows
726unnest
726unnest
727− :: Expression outer 'Ungrouped commons schemas params '[] (nullity ('PGvararray ty))
727+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity ('PGvararray ty))
728 -> FromClause outer commons schemas params '["unnest" ::: '["unnest" ::: ty]]
728 -> FromClause outer commons schemas params '["unnest" ::: '["unnest" ::: ty]]
729unnest = unsafeSetOfFunction "unnest"
729unnest = unsafeSetOfFunction "unnest"
730
730
@@ -733,7 +733,7 @@ unnest = unsafeSetOfFunction "unnest"
733-- >>> printSQL (select Star (from (jsonEach (jsonLit (object ["a" .= "foo", "b" .= "bar"])))))
733-- >>> printSQL (select Star (from (jsonEach (jsonLit (object ["a" .= "foo", "b" .= "bar"])))))
734-- SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))
734-- SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))
735jsonEach
735jsonEach
736− :: Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
736+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json object
737 -> FromClause outer commons schemas params
737 -> FromClause outer commons schemas params
738 '["json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]]
738 '["json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]]
739jsonEach = unsafeSetOfFunction "json_each"
739jsonEach = unsafeSetOfFunction "json_each"
@@ -743,7 +743,7 @@ jsonEach = unsafeSetOfFunction "json_each"
743-- >>> printSQL (select Star (from (jsonbEach (jsonbLit (object ["a" .= "foo", "b" .= "bar"])))))
743-- >>> printSQL (select Star (from (jsonbEach (jsonbLit (object ["a" .= "foo", "b" .= "bar"])))))
744-- SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))
744-- SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))
745jsonbEach
745jsonbEach
746− :: Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
746+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
747 -> FromClause outer commons schemas params
747 -> FromClause outer commons schemas params
748 '["jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]]
748 '["jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]]
749jsonbEach = unsafeSetOfFunction "jsonb_each"
749jsonbEach = unsafeSetOfFunction "jsonb_each"
@@ -753,7 +753,7 @@ jsonbEach = unsafeSetOfFunction "jsonb_each"
753-- >>> printSQL (select Star (from (jsonEachText (jsonLit (object ["a" .= "foo", "b" .= "bar"])))))
753-- >>> printSQL (select Star (from (jsonEachText (jsonLit (object ["a" .= "foo", "b" .= "bar"])))))
754-- SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))
754-- SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))
755jsonEachText
755jsonEachText
756− :: Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
756+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json object
757 -> FromClause outer commons schemas params
757 -> FromClause outer commons schemas params
758 '["json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]]
758 '["json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]]
759jsonEachText = unsafeSetOfFunction "json_each_text"
759jsonEachText = unsafeSetOfFunction "json_each_text"
@@ -763,7 +763,7 @@ jsonEachText = unsafeSetOfFunction "json_each_text"
763-- >>> printSQL (select Star (from (jsonbEachText (jsonbLit (object ["a" .= "foo", "b" .= "bar"])))))
763-- >>> printSQL (select Star (from (jsonbEachText (jsonbLit (object ["a" .= "foo", "b" .= "bar"])))))
764-- SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))
764-- SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))
765jsonbEachText
765jsonbEachText
766− :: Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
766+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
767 -> FromClause outer commons schemas params
767 -> FromClause outer commons schemas params
768 '["jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]]
768 '["jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]]
769jsonbEachText = unsafeSetOfFunction "jsonb_each_text"
769jsonbEachText = unsafeSetOfFunction "jsonb_each_text"
@@ -773,7 +773,7 @@ jsonbEachText = unsafeSetOfFunction "jsonb_each_text"
773-- >>> printSQL (jsonObjectKeys (jsonLit (object ["a" .= "foo", "b" .= "bar"])))
773-- >>> printSQL (jsonObjectKeys (jsonLit (object ["a" .= "foo", "b" .= "bar"])))
774-- json_object_keys(('{"a":"foo","b":"bar"}' :: json))
774-- json_object_keys(('{"a":"foo","b":"bar"}' :: json))
775jsonObjectKeys
775jsonObjectKeys
776− :: Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
776+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json object
777 -> FromClause outer commons schemas params
777 -> FromClause outer commons schemas params
778 '["json_object_keys" ::: '["json_object_keys" ::: 'NotNull 'PGtext]]
778 '["json_object_keys" ::: '["json_object_keys" ::: 'NotNull 'PGtext]]
779jsonObjectKeys = unsafeSetOfFunction "json_object_keys"
779jsonObjectKeys = unsafeSetOfFunction "json_object_keys"
@@ -783,7 +783,7 @@ jsonObjectKeys = unsafeSetOfFunction "json_object_keys"
783-- >>> printSQL (jsonbObjectKeys (jsonbLit (object ["a" .= "foo", "b" .= "bar"])))
783-- >>> printSQL (jsonbObjectKeys (jsonbLit (object ["a" .= "foo", "b" .= "bar"])))
784-- jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))
784-- jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))
785jsonbObjectKeys
785jsonbObjectKeys
786− :: Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
786+ :: Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
787 -> FromClause outer commons schemas params
787 -> FromClause outer commons schemas params
788 '["jsonb_object_keys" ::: '["jsonb_object_keys" ::: 'NotNull 'PGtext]]
788 '["jsonb_object_keys" ::: '["jsonb_object_keys" ::: 'NotNull 'PGtext]]
789jsonbObjectKeys = unsafeSetOfFunction "jsonb_object_keys"
789jsonbObjectKeys = unsafeSetOfFunction "jsonb_object_keys"
@@ -792,7 +792,7 @@ unsafePopulateFunction
792 :: KnownSymbol fun
792 :: KnownSymbol fun
793 => Alias fun
793 => Alias fun
794 -> TypeExpression schemas (nullity ('PGcomposite row))
794 -> TypeExpression schemas (nullity ('PGcomposite row))
795− -> Expression outer 'Ungrouped commons schemas params '[] ty
795+ -> Expression outer commons 'Ungrouped schemas params '[] ty
796 -> FromClause outer commons schemas params '[fun ::: row]
796 -> FromClause outer commons schemas params '[fun ::: row]
797unsafePopulateFunction fun ty expr = UnsafeFromClause $ renderSQL fun
797unsafePopulateFunction fun ty expr = UnsafeFromClause $ renderSQL fun
798 <> parenthesized ("null::" <> renderSQL ty <> ", " <> renderSQL expr)
798 <> parenthesized ("null::" <> renderSQL ty <> ", " <> renderSQL expr)
@@ -801,7 +801,7 @@ unsafePopulateFunction fun ty expr = UnsafeFromClause $ renderSQL fun
801-- type defined by the given table.
801-- type defined by the given table.
802jsonPopulateRecord
802jsonPopulateRecord
803 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
803 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
804− -> Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
804+ -> Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json object
805 -> FromClause outer commons schemas params '["json_populate_record" ::: row]
805 -> FromClause outer commons schemas params '["json_populate_record" ::: row]
806jsonPopulateRecord = unsafePopulateFunction #json_populate_record
806jsonPopulateRecord = unsafePopulateFunction #json_populate_record
807
807
@@ -809,7 +809,7 @@ jsonPopulateRecord = unsafePopulateFunction #json_populate_record
809-- type defined by the given table.
809-- type defined by the given table.
810jsonbPopulateRecord
810jsonbPopulateRecord
811 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
811 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
812− -> Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
812+ -> Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
813 -> FromClause outer commons schemas params '["jsonb_populate_record" ::: row]
813 -> FromClause outer commons schemas params '["jsonb_populate_record" ::: row]
814jsonbPopulateRecord = unsafePopulateFunction #jsonb_populate_record
814jsonbPopulateRecord = unsafePopulateFunction #jsonb_populate_record
815
815
@@ -817,7 +817,7 @@ jsonbPopulateRecord = unsafePopulateFunction #jsonb_populate_record
817-- set of rows whose columns match the record type defined by the given table.
817-- set of rows whose columns match the record type defined by the given table.
818jsonPopulateRecordSet
818jsonPopulateRecordSet
819 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
819 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
820− -> Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json array
820+ -> Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json array
821 -> FromClause outer commons schemas params '["json_populate_record_set" ::: row]
821 -> FromClause outer commons schemas params '["json_populate_record_set" ::: row]
822jsonPopulateRecordSet = unsafePopulateFunction #json_populate_record_set
822jsonPopulateRecordSet = unsafePopulateFunction #json_populate_record_set
823
823
@@ -826,14 +826,14 @@ jsonPopulateRecordSet = unsafePopulateFunction #json_populate_record_set
826-- table.
826-- table.
827jsonbPopulateRecordSet
827jsonbPopulateRecordSet
828 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
828 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
829− -> Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb array
829+ -> Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb array
830 -> FromClause outer commons schemas params '["jsonb_populate_record_set" ::: row]
830 -> FromClause outer commons schemas params '["jsonb_populate_record_set" ::: row]
831jsonbPopulateRecordSet = unsafePopulateFunction #jsonb_populate_record_set
831jsonbPopulateRecordSet = unsafePopulateFunction #jsonb_populate_record_set
832
832
833unsafeRecordFunction
833unsafeRecordFunction
834 :: (SListI record, json `In` PGJsonType)
834 :: (SListI record, json `In` PGJsonType)
835 => ByteString
835 => ByteString
836− -> Expression outer 'Ungrouped commons schemas params '[] (nullity json)
836+ -> Expression outer commons 'Ungrouped schemas params '[] (nullity json)
837 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
837 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
838 -> FromClause outer commons schemas params '[tab ::: record]
838 -> FromClause outer commons schemas params '[tab ::: record]
839unsafeRecordFunction fun expr (types `As` tab) = UnsafeFromClause $
839unsafeRecordFunction fun expr (types `As` tab) = UnsafeFromClause $
@@ -846,7 +846,7 @@ unsafeRecordFunction fun expr (types `As` tab) = UnsafeFromClause $
846-- | Builds an arbitrary record from a JSON object.
846-- | Builds an arbitrary record from a JSON object.
847jsonToRecord
847jsonToRecord
848 :: SListI record
848 :: SListI record
849− => Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
849+ => Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json object
850 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
850 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
851 -> FromClause outer commons schemas params '[tab ::: record]
851 -> FromClause outer commons schemas params '[tab ::: record]
852jsonToRecord = unsafeRecordFunction "json_to_record"
852jsonToRecord = unsafeRecordFunction "json_to_record"
@@ -854,7 +854,7 @@ jsonToRecord = unsafeRecordFunction "json_to_record"
854-- | Builds an arbitrary record from a binary JSON object.
854-- | Builds an arbitrary record from a binary JSON object.
855jsonbToRecord
855jsonbToRecord
856 :: SListI record
856 :: SListI record
857− => Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
857+ => Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
858 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
858 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
859 -> FromClause outer commons schemas params '[tab ::: record]
859 -> FromClause outer commons schemas params '[tab ::: record]
860jsonbToRecord = unsafeRecordFunction "jsonb_to_record"
860jsonbToRecord = unsafeRecordFunction "jsonb_to_record"
@@ -862,7 +862,7 @@ jsonbToRecord = unsafeRecordFunction "jsonb_to_record"
862-- | Builds an arbitrary set of records from a JSON array of objects.
862-- | Builds an arbitrary set of records from a JSON array of objects.
863jsonToRecordSet
863jsonToRecordSet
864 :: SListI record
864 :: SListI record
865− => Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json array
865+ => Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjson) -- ^ json array
866 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
866 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
867 -> FromClause outer commons schemas params '[tab ::: record]
867 -> FromClause outer commons schemas params '[tab ::: record]
868jsonToRecordSet = unsafeRecordFunction "json_to_record_set"
868jsonToRecordSet = unsafeRecordFunction "json_to_record_set"
@@ -870,7 +870,7 @@ jsonToRecordSet = unsafeRecordFunction "json_to_record_set"
870-- | Builds an arbitrary set of records from a binary JSON array of objects.
870-- | Builds an arbitrary set of records from a binary JSON array of objects.
871jsonbToRecordSet
871jsonbToRecordSet
872 :: SListI record
872 :: SListI record
873− => Expression outer 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb array
873+ => Expression outer commons 'Ungrouped schemas params '[] (nullity 'PGjsonb) -- ^ jsonb array
874 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
874 -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: record)
875 -> FromClause outer commons schemas params '[tab ::: record]
875 -> FromClause outer commons schemas params '[tab ::: record]
876jsonbToRecordSet = unsafeRecordFunction "jsonb_to_record_set"
876jsonbToRecordSet = unsafeRecordFunction "jsonb_to_record_set"
@@ -940,7 +940,7 @@ the @on@ condition.
940innerJoin
940innerJoin
941 :: FromClause outer commons schemas params right
941 :: FromClause outer commons schemas params right
942 -- ^ right
942 -- ^ right
943− -> Condition outer 'Ungrouped commons schemas params (Join left right)
943+ -> Condition outer commons 'Ungrouped schemas params (Join left right)
944 -- ^ @on@ condition
944 -- ^ @on@ condition
945 -> FromClause outer commons schemas params left
945 -> FromClause outer commons schemas params left
946 -- ^ left
946 -- ^ left
@@ -957,7 +957,7 @@ innerJoin right on left = UnsafeFromClause $
957leftOuterJoin
957leftOuterJoin
958 :: FromClause outer commons schemas params right
958 :: FromClause outer commons schemas params right
959 -- ^ right
959 -- ^ right
960− -> Condition outer 'Ungrouped commons schemas params (Join left right)
960+ -> Condition outer commons 'Ungrouped schemas params (Join left right)
961 -- ^ @on@ condition
961 -- ^ @on@ condition
962 -> FromClause outer commons schemas params left
962 -> FromClause outer commons schemas params left
963 -- ^ left
963 -- ^ left
@@ -975,7 +975,7 @@ leftOuterJoin right on left = UnsafeFromClause $
975rightOuterJoin
975rightOuterJoin
976 :: FromClause outer commons schemas params right
976 :: FromClause outer commons schemas params right
977 -- ^ right
977 -- ^ right
978− -> Condition outer 'Ungrouped commons schemas params (Join left right)
978+ -> Condition outer commons 'Ungrouped schemas params (Join left right)
979 -- ^ @on@ condition
979 -- ^ @on@ condition
980 -> FromClause outer commons schemas params left
980 -> FromClause outer commons schemas params left
981 -- ^ left
981 -- ^ left
@@ -994,7 +994,7 @@ rightOuterJoin right on left = UnsafeFromClause $
994fullOuterJoin
994fullOuterJoin
995 :: FromClause outer commons schemas params right
995 :: FromClause outer commons schemas params right
996 -- ^ right
996 -- ^ right
997− -> Condition outer 'Ungrouped commons schemas params (Join left right)
997+ -> Condition outer commons 'Ungrouped schemas params (Join left right)
998 -- ^ @on@ condition
998 -- ^ @on@ condition
999 -> FromClause outer commons schemas params left
999 -> FromClause outer commons schemas params left
1000 -- ^ left
1000 -- ^ left
@@ -1067,17 +1067,17 @@ instance RenderSQL (GroupByClause grp from) where
1067-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1067-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1068-- `TableExpression` must use `Having` whose conditions are combined with
1068-- `TableExpression` must use `Having` whose conditions are combined with
1069-- `.&&`.
1069-- `.&&`.
1070−data HavingClause outer grp commons schemas params from where
1070+data HavingClause outer commons grp schemas params from where
1071− NoHaving :: HavingClause outer 'Ungrouped commons schemas params from
1071+ NoHaving :: HavingClause outer commons 'Ungrouped schemas params from
1072 Having
1072 Having
1073− :: [Condition outer ('Grouped bys) commons schemas params from]
1073+ :: [Condition outer commons ('Grouped bys) schemas params from]
1074− -> HavingClause outer ('Grouped bys) commons schemas params from
1074+ -> HavingClause outer commons ('Grouped bys) schemas params from
1075−deriving instance Show (HavingClause outer grp commons schemas params from)
1075+deriving instance Show (HavingClause outer commons grp schemas params from)
1076−deriving instance Eq (HavingClause outer grp commons schemas params from)
1076+deriving instance Eq (HavingClause outer commons grp schemas params from)
1077−deriving instance Ord (HavingClause outer grp commons schemas params from)
1077+deriving instance Ord (HavingClause outer commons grp schemas params from)
1078
1078
1079-- | Render a `HavingClause`.
1079-- | Render a `HavingClause`.
1080−instance RenderSQL (HavingClause outer grp commons schemas params from) where
1080+instance RenderSQL (HavingClause outer commons grp schemas params from) where
1081 renderSQL = \case
1081 renderSQL = \case
1082 NoHaving -> ""
1082 NoHaving -> ""
1083 Having [] -> ""
1083 Having [] -> ""
@@ -1098,7 +1098,7 @@ at least one row is returned, not all the way to completion.
1098-}
1098-}
1099exists
1099exists
1100 :: Query (Join outer from) commons schemas params row
1100 :: Query (Join outer from) commons schemas params row
1101− -> Condition outer grp commons schemas params from
1101+ -> Condition outer commons grp schemas params from
1102exists query = UnsafeExpression $ "EXISTS" <+> parenthesized (renderSQL query)
1102exists query = UnsafeExpression $ "EXISTS" <+> parenthesized (renderSQL query)
1103
1103
1104{- |
1104{- |
@@ -1115,10 +1115,10 @@ and at least one comparison returns `null_`.
1115(TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo")))
1115(TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo")))
1116-}
1116-}
1117subAll
1117subAll
1118− :: Expression outer grp commons schemas params from ty1 -- ^ expression
1118+ :: Expression outer commons grp schemas params from ty1 -- ^ expression
1119 -> Operator ty1 ty2 ('Null 'PGbool) -- ^ operator
1119 -> Operator ty1 ty2 ('Null 'PGbool) -- ^ operator
1120 -> Query (Join outer from) commons schemas params '[col ::: ty2] -- ^ subquery
1120 -> Query (Join outer from) commons schemas params '[col ::: ty2] -- ^ subquery
1121− -> Condition outer grp commons schemas params from
1121+ -> Condition outer commons grp schemas params from
1122subAll expr (?) qry = expr ?
1122subAll expr (?) qry = expr ?
1123 (UnsafeExpression $ "ALL" <+> parenthesized (renderSQL qry))
1123 (UnsafeExpression $ "ALL" <+> parenthesized (renderSQL qry))
1124
1124
@@ -1133,10 +1133,10 @@ if any `true` result is obtained. The result is `false` if no true result is fou
1133(E'foo' LIKE ALL (SELECT * FROM (VALUES (E'foobar')) AS t ("foo")))
1133(E'foo' LIKE ALL (SELECT * FROM (VALUES (E'foobar')) AS t ("foo")))
1134-}
1134-}
1135subAny
1135subAny
1136− :: Expression outer grp commons schemas params from ty1 -- ^ expression
1136+ :: Expression outer commons grp schemas params from ty1 -- ^ expression
1137 -> Operator ty1 ty2 ('Null 'PGbool) -- ^ operator
1137 -> Operator ty1 ty2 ('Null 'PGbool) -- ^ operator
1138 -> Query (Join outer from) commons schemas params '[col ::: ty2] -- ^ subquery
1138 -> Query (Join outer from) commons schemas params '[col ::: ty2] -- ^ subquery
1139− -> Condition outer grp commons schemas params from
1139+ -> Condition outer commons grp schemas params from
1140subAny expr (?) qry = expr ?
1140subAny expr (?) qry = expr ?
1141 (UnsafeExpression $ "ANY" <+> parenthesized (renderSQL qry))
1141 (UnsafeExpression $ "ANY" <+> parenthesized (renderSQL qry))
1142
1142
@@ -1148,9 +1148,9 @@ to any of the right-hand expressions.
1148TRUE IN (TRUE, FALSE, NULL)
1148TRUE IN (TRUE, FALSE, NULL)
1149-}
1149-}
1150in_
1150in_
1151− :: Expression outer grp commons schemas params from ty -- ^ expression
1151+ :: Expression outer commons grp schemas params from ty -- ^ expression
1152− -> [Expression outer grp commons schemas params from ty]
1152+ -> [Expression outer commons grp schemas params from ty]
1153− -> Condition outer grp commons schemas params from
1153+ -> Condition outer commons grp schemas params from
1154expr `in_` exprs = UnsafeExpression $ renderSQL expr <+> "IN"
1154expr `in_` exprs = UnsafeExpression $ renderSQL expr <+> "IN"
1155 <+> parenthesized (commaSeparated (renderSQL <$> exprs))
1155 <+> parenthesized (commaSeparated (renderSQL <$> exprs))
1156
1156
@@ -1162,9 +1162,9 @@ to any of the right-hand expressions.
1162TRUE NOT IN (FALSE, NULL)
1162TRUE NOT IN (FALSE, NULL)
1163-}
1163-}
1164notIn
1164notIn
1165− :: Expression outer grp commons schemas params from ty -- ^ expression
1165+ :: Expression outer commons grp schemas params from ty -- ^ expression
1166− -> [Expression outer grp commons schemas params from ty]
1166+ -> [Expression outer commons grp schemas params from ty]
1167− -> Condition outer grp commons schemas params from
1167+ -> Condition outer commons grp schemas params from
1168expr `notIn` exprs = UnsafeExpression $ renderSQL expr <+> "NOT IN"
1168expr `notIn` exprs = UnsafeExpression $ renderSQL expr <+> "NOT IN"
1169 <+> parenthesized (commaSeparated (renderSQL <$> exprs))
1169 <+> parenthesized (commaSeparated (renderSQL <$> exprs))
1170
1170