on dev help sign in
rename kinds

RelationType ~> RowType RelationsType ~> FromType

commitaa759143e8507fb9e88a44f4c6390edf77ec3f76 authorEitan Chatav <eitan.chatav@gmail.com> dateThu 16 Aug 2018, 10:06 (8 years ago) parentf7aedef
6 files changed+402−402
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+2−2 squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+2−2 squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+292−292 squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+3−3 squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+84−84 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+19−19
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+2−2
@@ -514,11 +514,11 @@ instance FromValue pg y
514514 Decoding.valueParser (fromValue @pg) bytestring
515515
516516-- | A `FromRow` constraint generically sequences the parsings of the columns
517−-- of a `RelationType` into the fields of a record `Type` provided they have
517+-- of a `RowType` into the fields of a record `Type` provided they have
518518-- the same field names. You should not define instances of `FromRow`.
519519-- Instead define `Generic` and `HasDatatypeInfo` instances which in turn
520520-- provide `FromRow` instances.
521−class SListI result => FromRow (result :: RelationType) y where
521+class SListI result => FromRow (result :: RowType) y where
522522 -- | >>> :set -XOverloadedStrings
523523 -- >>> import Data.Text
524524 -- >>> newtype UserId = UserId { getUserId :: Int16 } deriving Show
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+2−2
@@ -807,9 +807,9 @@ alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderColumnTypeExpression ty
807807createView
808808 :: KnownSymbol view
809809 => Alias view -- ^ the name of the view to add
810− -> Query schema '[] relation
810+ -> Query schema '[] row
811811 -- ^ query
812− -> Definition schema (Create view ('View relation) schema)
812+ -> Definition schema (Create view ('View row) schema)
813813createView alias query = UnsafeDefinition $
814814 "CREATE" <+> "VIEW" <+> renderAlias alias <+> "AS"
815815 <+> renderQuery query <> ";"
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+292−292
@@ -217,14 +217,14 @@ and other operations.
217217-}
218218newtype Expression
219219 (schema :: SchemaType)
220− (relations :: RelationsType)
220+ (from :: FromType)
221221 (grouping :: Grouping)
222222 (params :: [NullityType])
223223 (ty :: NullityType)
224224 = UnsafeExpression { renderExpression :: ByteString }
225225 deriving (GHC.Generic,Show,Eq,Ord,NFData)
226226
227−instance RenderSQL (Expression schema relations grouping params ty) where
227+instance RenderSQL (Expression schema from grouping params ty) where
228228 renderSQL = renderExpression
229229
230230{- | A `HasParameter` constraint is used to indicate a value that is
@@ -248,7 +248,7 @@ class KnownNat n => HasParameter
248248 -- ($1 :: int4)
249249 parameter
250250 :: TypeExpression schema ty
251− -> Expression schema relations grouping params ty
251+ -> Expression schema from grouping params ty
252252 parameter ty = UnsafeExpression $ parenthesized $
253253 "$" <> renderNat @n <+> "::"
254254 <+> renderTypeExpression ty
@@ -263,82 +263,82 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
263263-- >>> printSQL expr
264264-- ($1 :: int4)
265265param
266− :: forall n schema params relations grouping ty
266+ :: forall n schema params from grouping ty
267267 . (PGTyped schema ty, HasParameter n schema params ty)
268− => Expression schema relations grouping params ty -- ^ param
268+ => Expression schema from grouping params ty -- ^ param
269269param = parameter @n pgtype
270270
271−instance (HasUnique relation relations columns, Has column columns ty)
272− => IsLabel column (Expression schema relations 'Ungrouped params ty) where
271+instance (HasUnique relation from columns, Has column columns ty)
272+ => IsLabel column (Expression schema from 'Ungrouped params ty) where
273273 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
274−instance (HasUnique relation relations columns, Has column columns ty)
274+instance (HasUnique relation from columns, Has column columns ty)
275275 => IsLabel column
276− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
276+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
277277 fromLabel = fromLabel @column `As` Alias @column
278−instance (HasUnique relation relations columns, Has column columns ty)
278+instance (HasUnique relation from columns, Has column columns ty)
279279 => IsLabel column
280− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
280+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
281281 fromLabel = fromLabel @column :* Nil
282282
283−instance (Has relation relations columns, Has column columns ty)
284− => IsQualified relation column (Expression schema relations 'Ungrouped params ty) where
283+instance (Has relation from columns, Has column columns ty)
284+ => IsQualified relation column (Expression schema from 'Ungrouped params ty) where
285285 relation ! column = UnsafeExpression $
286286 renderAlias relation <> "." <> renderAlias column
287−instance (Has relation relations columns, Has column columns ty)
287+instance (Has relation from columns, Has column columns ty)
288288 => IsQualified relation column
289− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
289+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
290290 relation ! column = relation ! column `As` column
291−instance (Has relation relations columns, Has column columns ty)
291+instance (Has relation from columns, Has column columns ty)
292292 => IsQualified relation column
293− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
293+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
294294 relation ! column = relation ! column :* Nil
295295
296296instance
297− ( HasUnique relation relations columns
297+ ( HasUnique relation from columns
298298 , Has column columns ty
299299 , GroupedBy relation column bys
300300 ) => IsLabel column
301− (Expression schema relations ('Grouped bys) params ty) where
301+ (Expression schema from ('Grouped bys) params ty) where
302302 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
303303instance
304− ( HasUnique relation relations columns
304+ ( HasUnique relation from columns
305305 , Has column columns ty
306306 , GroupedBy relation column bys
307307 ) => IsLabel column
308− ( Aliased (Expression schema relations ('Grouped bys) params)
308+ ( Aliased (Expression schema from ('Grouped bys) params)
309309 (column ::: ty) ) where
310310 fromLabel = fromLabel @column `As` Alias @column
311311instance
312− ( HasUnique relation relations columns
312+ ( HasUnique relation from columns
313313 , Has column columns ty
314314 , GroupedBy relation column bys
315315 ) => IsLabel column
316− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
316+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
317317 '[column ::: ty] ) where
318318 fromLabel = fromLabel @column :* Nil
319319
320320instance
321− ( Has relation relations columns
321+ ( Has relation from columns
322322 , Has column columns ty
323323 , GroupedBy relation column bys
324324 ) => IsQualified relation column
325− (Expression schema relations ('Grouped bys) params ty) where
325+ (Expression schema from ('Grouped bys) params ty) where
326326 relation ! column = UnsafeExpression $
327327 renderAlias relation <> "." <> renderAlias column
328328instance
329− ( Has relation relations columns
329+ ( Has relation from columns
330330 , Has column columns ty
331331 , GroupedBy relation column bys
332332 ) => IsQualified relation column
333− (Aliased (Expression schema relations ('Grouped bys) params)
333+ (Aliased (Expression schema from ('Grouped bys) params)
334334 (column ::: ty)) where
335335 relation ! column = relation ! column `As` column
336336instance
337− ( Has relation relations columns
337+ ( Has relation from columns
338338 , Has column columns ty
339339 , GroupedBy relation column bys
340340 ) => IsQualified relation column
341− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
341+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
342342 '[column ::: ty]) where
343343 relation ! column = relation ! column :* Nil
344344
@@ -363,11 +363,11 @@ notNull = UnsafeExpression . renderExpression
363363-- >>> printSQL $ coalesce [null_, true] false
364364-- COALESCE(NULL, TRUE, FALSE)
365365coalesce
366− :: [Expression schema relations grouping params ('Null ty)]
366+ :: [Expression schema from grouping params ('Null ty)]
367367 -- ^ @NULL@s may be present
368− -> Expression schema relations grouping params ('NotNull ty)
368+ -> Expression schema from grouping params ('NotNull ty)
369369 -- ^ @NULL@ is absent
370− -> Expression schema relations grouping params ('NotNull ty)
370+ -> Expression schema from grouping params ('NotNull ty)
371371coalesce nullxs notNullx = UnsafeExpression $
372372 "COALESCE" <> parenthesized (commaSeparated
373373 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -377,26 +377,26 @@ coalesce nullxs notNullx = UnsafeExpression $
377377-- >>> printSQL $ fromNull true null_
378378-- COALESCE(NULL, TRUE)
379379fromNull
380− :: Expression schema relations grouping params ('NotNull ty)
380+ :: Expression schema from grouping params ('NotNull ty)
381381 -- ^ what to convert @NULL@ to
382− -> Expression schema relations grouping params ('Null ty)
383− -> Expression schema relations grouping params ('NotNull ty)
382+ -> Expression schema from grouping params ('Null ty)
383+ -> Expression schema from grouping params ('NotNull ty)
384384fromNull notNullx nullx = coalesce [nullx] notNullx
385385
386386-- | >>> printSQL $ null_ & isNull
387387-- NULL IS NULL
388388isNull
389− :: Expression schema relations grouping params ('Null ty)
389+ :: Expression schema from grouping params ('Null ty)
390390 -- ^ possibly @NULL@
391− -> Condition schema relations grouping params
391+ -> Condition schema from grouping params
392392isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
393393
394394-- | >>> printSQL $ null_ & isNotNull
395395-- NULL IS NOT NULL
396396isNotNull
397− :: Expression schema relations grouping params ('Null ty)
397+ :: Expression schema from grouping params ('Null ty)
398398 -- ^ possibly @NULL@
399− -> Condition schema relations grouping params
399+ -> Condition schema from grouping params
400400isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
401401
402402-- | analagous to `maybe` using @IS NULL@
@@ -404,13 +404,13 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
404404-- >>> printSQL $ matchNull true not_ null_
405405-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
406406matchNull
407− :: Expression schema relations grouping params (nullty)
407+ :: Expression schema from grouping params (nullty)
408408 -- ^ what to convert @NULL@ to
409− -> ( Expression schema relations grouping params ('NotNull ty)
410− -> Expression schema relations grouping params (nullty) )
409+ -> ( Expression schema from grouping params ('NotNull ty)
410+ -> Expression schema from grouping params (nullty) )
411411 -- ^ function to perform when @NULL@ is absent
412− -> Expression schema relations grouping params ('Null ty)
413− -> Expression schema relations grouping params (nullty)
412+ -> Expression schema from grouping params ('Null ty)
413+ -> Expression schema from grouping params (nullty)
414414matchNull y f x = ifThenElse (isNull x) y
415415 (f (UnsafeExpression (renderExpression x)))
416416
@@ -423,25 +423,25 @@ matchNull y f x = ifThenElse (isNull x) y
423423NULL IF (FALSE, ($1 :: bool))
424424-}
425425nullIf
426− :: Expression schema relations grouping params ('NotNull ty)
426+ :: Expression schema from grouping params ('NotNull ty)
427427 -- ^ @NULL@ is absent
428− -> Expression schema relations grouping params ('NotNull ty)
428+ -> Expression schema from grouping params ('NotNull ty)
429429 -- ^ @NULL@ is absent
430− -> Expression schema relations grouping params ('Null ty)
430+ -> Expression schema from grouping params ('Null ty)
431431nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
432432 (renderExpression x <> ", " <> renderExpression y)
433433
434434-- | >>> printSQL $ array [null_, false, true]
435435-- ARRAY[NULL, FALSE, TRUE]
436436array
437− :: [Expression schema relations grouping params ty]
437+ :: [Expression schema from grouping params ty]
438438 -- ^ array elements
439− -> Expression schema relations grouping params (nullity ('PGvararray ty))
439+ -> Expression schema from grouping params (nullity ('PGvararray ty))
440440array xs = UnsafeExpression $
441441 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
442442
443443instance (KnownSymbol label, label `In` labels) => IsPGlabel label
444− (Expression schema relations grouping params (nullity ('PGenum labels))) where
444+ (Expression schema from grouping params (nullity ('PGenum labels))) where
445445 label = UnsafeExpression $ renderLabel (PGlabel @label)
446446
447447-- | A row constructor is an expression that builds a row value
@@ -458,9 +458,9 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
458458-- ROW(0, 1)
459459row
460460 :: SListI fields
461− => NP (Aliased (Expression schema relations grouping params)) fields
461+ => NP (Aliased (Expression schema from grouping params)) fields
462462 -- ^ zero or more expressions for the row field values
463− -> Expression schema relations grouping params (nullity ('PGcomposite fields))
463+ -> Expression schema from grouping params (nullity ('PGcomposite fields))
464464row exprs = UnsafeExpression $ "ROW" <> parenthesized
465465 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
466466
@@ -472,11 +472,11 @@ instance Has field fields ty => IsLabel field
472472 renderSymbol @field
473473
474474instance Semigroup
475− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
475+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
476476 (<>) = unsafeBinaryOp "||"
477477
478478instance Monoid
479− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
479+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
480480 mempty = array []
481481 mappend = (<>)
482482
@@ -484,22 +484,22 @@ instance Monoid
484484-- >>> printSQL expr
485485-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
486486greatest
487− :: Expression schema relations grouping params (nullty)
487+ :: Expression schema from grouping params (nullty)
488488 -- ^ needs at least 1 argument
489− -> [Expression schema relations grouping params (nullty)]
489+ -> [Expression schema from grouping params (nullty)]
490490 -- ^ or more
491− -> Expression schema relations grouping params (nullty)
491+ -> Expression schema from grouping params (nullty)
492492greatest x xs = UnsafeExpression $ "GREATEST("
493493 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
494494
495495-- | >>> printSQL $ least currentTimestamp [null_]
496496-- LEAST(CURRENT_TIMESTAMP, NULL)
497497least
498− :: Expression schema relations grouping params (nullty)
498+ :: Expression schema from grouping params (nullty)
499499 -- ^ needs at least 1 argument
500− -> [Expression schema relations grouping params (nullty)]
500+ -> [Expression schema from grouping params (nullty)]
501501 -- ^ or more
502− -> Expression schema relations grouping params (nullty)
502+ -> Expression schema from grouping params (nullty)
503503least x xs = UnsafeExpression $ "LEAST("
504504 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
505505
@@ -508,9 +508,9 @@ least x xs = UnsafeExpression $ "LEAST("
508508unsafeBinaryOp
509509 :: ByteString
510510 -- ^ operator
511− -> Expression schema relations grouping params (ty0)
512− -> Expression schema relations grouping params (ty1)
513− -> Expression schema relations grouping params (ty2)
511+ -> Expression schema from grouping params (ty0)
512+ -> Expression schema from grouping params (ty1)
513+ -> Expression schema from grouping params (ty2)
514514unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
515515 renderExpression x <+> op <+> renderExpression y
516516
@@ -519,8 +519,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
519519unsafeUnaryOp
520520 :: ByteString
521521 -- ^ operator
522− -> Expression schema relations grouping params (ty0)
523− -> Expression schema relations grouping params (ty1)
522+ -> Expression schema from grouping params (ty0)
523+ -> Expression schema from grouping params (ty1)
524524unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
525525 op <+> renderExpression x
526526
@@ -529,8 +529,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
529529unsafeFunction
530530 :: ByteString
531531 -- ^ function
532− -> Expression schema relations grouping params (xty)
533− -> Expression schema relations grouping params (yty)
532+ -> Expression schema from grouping params (xty)
533+ -> Expression schema from grouping params (yty)
534534unsafeFunction fun x = UnsafeExpression $
535535 fun <> parenthesized (renderExpression x)
536536
@@ -539,13 +539,13 @@ unsafeVariadicFunction
539539 :: SListI elems
540540 => ByteString
541541 -- ^ function
542− -> NP (Expression schema relations grouping params) elems
543− -> Expression schema relations grouping params ret
542+ -> NP (Expression schema from grouping params) elems
543+ -> Expression schema from grouping params ret
544544unsafeVariadicFunction fun x = UnsafeExpression $
545545 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
546546
547547instance PGNum ty
548− => Num (Expression schema relations grouping params (nullity ty)) where
548+ => Num (Expression schema from grouping params (nullity ty)) where
549549 (+) = unsafeBinaryOp "+"
550550 (-) = unsafeBinaryOp "-"
551551 (*) = unsafeBinaryOp "*"
@@ -557,12 +557,12 @@ instance PGNum ty
557557 . show
558558
559559instance (PGNum ty, PGFloating ty) => Fractional
560− (Expression schema relations grouping params (nullity ty)) where
560+ (Expression schema from grouping params (nullity ty)) where
561561 (/) = unsafeBinaryOp "/"
562562 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
563563
564564instance (PGNum ty, PGFloating ty) => Floating
565− (Expression schema relations grouping params (nullity ty)) where
565+ (Expression schema from grouping params (nullity ty)) where
566566 pi = UnsafeExpression "pi()"
567567 exp = unsafeFunction "exp"
568568 log = unsafeFunction "ln"
@@ -585,18 +585,18 @@ instance (PGNum ty, PGFloating ty) => Floating
585585
586586-- | >>> :{
587587-- let
588−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
588+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
589589-- expression = atan2_ pi 2
590590-- in printSQL expression
591591-- :}
592592-- atan2(pi(), 2)
593593atan2_
594594 :: PGFloating float
595− => Expression schema relations grouping params (nullity float)
595+ => Expression schema from grouping params (nullity float)
596596 -- ^ numerator
597− -> Expression schema relations grouping params (nullity float)
597+ -> Expression schema from grouping params (nullity float)
598598 -- ^ denominator
599− -> Expression schema relations grouping params (nullity float)
599+ -> Expression schema from grouping params (nullity float)
600600atan2_ y x = UnsafeExpression $
601601 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
602602
@@ -609,9 +609,9 @@ atan2_ y x = UnsafeExpression $
609609cast
610610 :: TypeExpression schema ty1
611611 -- ^ type to cast as
612− -> Expression schema relations grouping params ty0
612+ -> Expression schema from grouping params ty0
613613 -- ^ value to convert
614− -> Expression schema relations grouping params ty1
614+ -> Expression schema from grouping params ty1
615615cast ty x = UnsafeExpression $ parenthesized $
616616 renderExpression x <+> "::" <+> renderTypeExpression ty
617617
@@ -619,134 +619,134 @@ cast ty x = UnsafeExpression $ parenthesized $
619619--
620620-- >>> :{
621621-- let
622−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
622+-- expression :: Expression schema from grouping params (nullity 'PGint2)
623623-- expression = 5 `quot_` 2
624624-- in printSQL expression
625625-- :}
626626-- (5 / 2)
627627quot_
628628 :: PGIntegral int
629− => Expression schema relations grouping params (nullity int)
629+ => Expression schema from grouping params (nullity int)
630630 -- ^ numerator
631− -> Expression schema relations grouping params (nullity int)
631+ -> Expression schema from grouping params (nullity int)
632632 -- ^ denominator
633− -> Expression schema relations grouping params (nullity int)
633+ -> Expression schema from grouping params (nullity int)
634634quot_ = unsafeBinaryOp "/"
635635
636636-- | remainder upon integer division
637637--
638638-- >>> :{
639639-- let
640−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
640+-- expression :: Expression schema from grouping params (nullity 'PGint2)
641641-- expression = 5 `rem_` 2
642642-- in printSQL expression
643643-- :}
644644-- (5 % 2)
645645rem_
646646 :: PGIntegral int
647− => Expression schema relations grouping params (nullity int)
647+ => Expression schema from grouping params (nullity int)
648648 -- ^ numerator
649− -> Expression schema relations grouping params (nullity int)
649+ -> Expression schema from grouping params (nullity int)
650650 -- ^ denominator
651− -> Expression schema relations grouping params (nullity int)
651+ -> Expression schema from grouping params (nullity int)
652652rem_ = unsafeBinaryOp "%"
653653
654654-- | >>> :{
655655-- let
656−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
656+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
657657-- expression = trunc pi
658658-- in printSQL expression
659659-- :}
660660-- trunc(pi())
661661trunc
662662 :: PGFloating frac
663− => Expression schema relations grouping params (nullity frac)
663+ => Expression schema from grouping params (nullity frac)
664664 -- ^ fractional number
665− -> Expression schema relations grouping params (nullity frac)
665+ -> Expression schema from grouping params (nullity frac)
666666trunc = unsafeFunction "trunc"
667667
668668-- | >>> :{
669669-- let
670−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
670+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
671671-- expression = round_ pi
672672-- in printSQL expression
673673-- :}
674674-- round(pi())
675675round_
676676 :: PGFloating frac
677− => Expression schema relations grouping params (nullity frac)
677+ => Expression schema from grouping params (nullity frac)
678678 -- ^ fractional number
679− -> Expression schema relations grouping params (nullity frac)
679+ -> Expression schema from grouping params (nullity frac)
680680round_ = unsafeFunction "round"
681681
682682-- | >>> :{
683683-- let
684−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
684+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
685685-- expression = ceiling_ pi
686686-- in printSQL expression
687687-- :}
688688-- ceiling(pi())
689689ceiling_
690690 :: PGFloating frac
691− => Expression schema relations grouping params (nullity frac)
691+ => Expression schema from grouping params (nullity frac)
692692 -- ^ fractional number
693− -> Expression schema relations grouping params (nullity frac)
693+ -> Expression schema from grouping params (nullity frac)
694694ceiling_ = unsafeFunction "ceiling"
695695
696696-- | A `Condition` is an `Expression`, which can evaluate
697697-- to `TRUE`, `FALSE` or `NULL`. This is because SQL uses
698698-- a three valued logic.
699−type Condition schema relations grouping params =
700− Expression schema relations grouping params ('Null 'PGbool)
699+type Condition schema from grouping params =
700+ Expression schema from grouping params ('Null 'PGbool)
701701
702702-- | >>> printSQL true
703703-- TRUE
704−true :: Expression schema relations grouping params (nullity 'PGbool)
704+true :: Expression schema from grouping params (nullity 'PGbool)
705705true = UnsafeExpression "TRUE"
706706
707707-- | >>> printSQL false
708708-- FALSE
709−false :: Expression schema relations grouping params (nullity 'PGbool)
709+false :: Expression schema from grouping params (nullity 'PGbool)
710710false = UnsafeExpression "FALSE"
711711
712712-- | >>> printSQL $ not_ true
713713-- (NOT TRUE)
714714not_
715− :: Expression schema relations grouping params (nullity 'PGbool)
716− -> Expression schema relations grouping params (nullity 'PGbool)
715+ :: Expression schema from grouping params (nullity 'PGbool)
716+ -> Expression schema from grouping params (nullity 'PGbool)
717717not_ = unsafeUnaryOp "NOT"
718718
719719-- | >>> printSQL $ true .&& false
720720-- (TRUE AND FALSE)
721721(.&&)
722− :: Condition schema relations grouping params
723− -> Condition schema relations grouping params
724− -> Condition schema relations grouping params
722+ :: Condition schema from grouping params
723+ -> Condition schema from grouping params
724+ -> Condition schema from grouping params
725725(.&&) = unsafeBinaryOp "AND"
726726
727727-- | >>> printSQL $ true .|| false
728728-- (TRUE OR FALSE)
729729(.||)
730− :: Condition schema relations grouping params
731− -> Condition schema relations grouping params
732− -> Condition schema relations grouping params
730+ :: Condition schema from grouping params
731+ -> Condition schema from grouping params
732+ -> Condition schema from grouping params
733733(.||) = unsafeBinaryOp "OR"
734734
735735-- | >>> :{
736736-- let
737−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
737+-- expression :: Expression schema from grouping params (nullity 'PGint2)
738738-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
739739-- in printSQL expression
740740-- :}
741741-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
742742caseWhenThenElse
743− :: [ ( Condition schema relations grouping params
744− , Expression schema relations grouping params ty
743+ :: [ ( Condition schema from grouping params
744+ , Expression schema from grouping params ty
745745 ) ]
746746 -- ^ whens and thens
747− -> Expression schema relations grouping params ty
747+ -> Expression schema from grouping params ty
748748 -- ^ else
749− -> Expression schema relations grouping params ty
749+ -> Expression schema from grouping params ty
750750caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
751751 [ "CASE"
752752 , mconcat
@@ -762,16 +762,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
762762
763763-- | >>> :{
764764-- let
765−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
765+-- expression :: Expression schema from grouping params (nullity 'PGint2)
766766-- expression = ifThenElse true 1 0
767767-- in printSQL expression
768768-- :}
769769-- CASE WHEN TRUE THEN 1 ELSE 0 END
770770ifThenElse
771− :: Condition schema relations grouping params
772− -> Expression schema relations grouping params ty -- ^ then
773− -> Expression schema relations grouping params ty -- ^ else
774− -> Expression schema relations grouping params ty
771+ :: Condition schema from grouping params
772+ -> Expression schema from grouping params ty -- ^ then
773+ -> Expression schema from grouping params ty -- ^ else
774+ -> Expression schema from grouping params ty
775775ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
776776
777777-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -780,85 +780,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
780780-- >>> printSQL $ true .== null_
781781-- (TRUE = NULL)
782782(.==)
783− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
784− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
785− -> Condition schema relations grouping params
783+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
784+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
785+ -> Condition schema from grouping params
786786(.==) = unsafeBinaryOp "="
787787infix 4 .==
788788
789789-- | >>> printSQL $ true ./= null_
790790-- (TRUE <> NULL)
791791(./=)
792− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
793− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
794− -> Condition schema relations grouping params
792+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
793+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
794+ -> Condition schema from grouping params
795795(./=) = unsafeBinaryOp "<>"
796796infix 4 ./=
797797
798798-- | >>> printSQL $ true .>= null_
799799-- (TRUE >= NULL)
800800(.>=)
801− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
802− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
803− -> Condition schema relations grouping params
801+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
802+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
803+ -> Condition schema from grouping params
804804(.>=) = unsafeBinaryOp ">="
805805infix 4 .>=
806806
807807-- | >>> printSQL $ true .< null_
808808-- (TRUE < NULL)
809809(.<)
810− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
811− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
812− -> Condition schema relations grouping params
810+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
811+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
812+ -> Condition schema from grouping params
813813(.<) = unsafeBinaryOp "<"
814814infix 4 .<
815815
816816-- | >>> printSQL $ true .<= null_
817817-- (TRUE <= NULL)
818818(.<=)
819− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
820− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
821− -> Condition schema relations grouping params
819+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
820+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
821+ -> Condition schema from grouping params
822822(.<=) = unsafeBinaryOp "<="
823823infix 4 .<=
824824
825825-- | >>> printSQL $ true .> null_
826826-- (TRUE > NULL)
827827(.>)
828− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
829− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
830− -> Condition schema relations grouping params
828+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
829+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
830+ -> Condition schema from grouping params
831831(.>) = unsafeBinaryOp ">"
832832infix 4 .>
833833
834834-- | >>> printSQL currentDate
835835-- CURRENT_DATE
836836currentDate
837− :: Expression schema relations grouping params (nullity 'PGdate)
837+ :: Expression schema from grouping params (nullity 'PGdate)
838838currentDate = UnsafeExpression "CURRENT_DATE"
839839
840840-- | >>> printSQL currentTime
841841-- CURRENT_TIME
842842currentTime
843− :: Expression schema relations grouping params (nullity 'PGtimetz)
843+ :: Expression schema from grouping params (nullity 'PGtimetz)
844844currentTime = UnsafeExpression "CURRENT_TIME"
845845
846846-- | >>> printSQL currentTimestamp
847847-- CURRENT_TIMESTAMP
848848currentTimestamp
849− :: Expression schema relations grouping params (nullity 'PGtimestamptz)
849+ :: Expression schema from grouping params (nullity 'PGtimestamptz)
850850currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
851851
852852-- | >>> printSQL localTime
853853-- LOCALTIME
854854localTime
855− :: Expression schema relations grouping params (nullity 'PGtime)
855+ :: Expression schema from grouping params (nullity 'PGtime)
856856localTime = UnsafeExpression "LOCALTIME"
857857
858858-- | >>> printSQL localTimestamp
859859-- LOCALTIMESTAMP
860860localTimestamp
861− :: Expression schema relations grouping params (nullity 'PGtimestamp)
861+ :: Expression schema from grouping params (nullity 'PGtimestamp)
862862localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
863863
864864{-----------------------------------------
@@ -866,7 +866,7 @@ text
866866-----------------------------------------}
867867
868868instance IsString
869− (Expression schema relations grouping params (nullity 'PGtext)) where
869+ (Expression schema from grouping params (nullity 'PGtext)) where
870870 fromString str = UnsafeExpression $
871871 "E\'" <> fromString (escape =<< str) <> "\'"
872872 where
@@ -882,36 +882,36 @@ instance IsString
882882 c -> [c]
883883
884884instance Semigroup
885− (Expression schema relations grouping params (nullity 'PGtext)) where
885+ (Expression schema from grouping params (nullity 'PGtext)) where
886886 (<>) = unsafeBinaryOp "||"
887887
888888instance Monoid
889− (Expression schema relations grouping params (nullity 'PGtext)) where
889+ (Expression schema from grouping params (nullity 'PGtext)) where
890890 mempty = fromString ""
891891 mappend = (<>)
892892
893893-- | >>> printSQL $ lower "ARRRGGG"
894894-- lower(E'ARRRGGG')
895895lower
896− :: Expression schema relations grouping params (nullity 'PGtext)
896+ :: Expression schema from grouping params (nullity 'PGtext)
897897 -- ^ string to lower case
898− -> Expression schema relations grouping params (nullity 'PGtext)
898+ -> Expression schema from grouping params (nullity 'PGtext)
899899lower = unsafeFunction "lower"
900900
901901-- | >>> printSQL $ upper "eeee"
902902-- upper(E'eeee')
903903upper
904− :: Expression schema relations grouping params (nullity 'PGtext)
904+ :: Expression schema from grouping params (nullity 'PGtext)
905905 -- ^ string to upper case
906− -> Expression schema relations grouping params (nullity 'PGtext)
906+ -> Expression schema from grouping params (nullity 'PGtext)
907907upper = unsafeFunction "upper"
908908
909909-- | >>> printSQL $ charLength "four"
910910-- char_length(E'four')
911911charLength
912− :: Expression schema relations grouping params (nullity 'PGtext)
912+ :: Expression schema from grouping params (nullity 'PGtext)
913913 -- ^ string to measure
914− -> Expression schema relations grouping params (nullity 'PGint4)
914+ -> Expression schema from grouping params (nullity 'PGint4)
915915charLength = unsafeFunction "char_length"
916916
917917-- | The `like` expression returns true if the @string@ matches
@@ -924,11 +924,11 @@ charLength = unsafeFunction "char_length"
924924-- >>> printSQL $ "abc" `like` "a%"
925925-- (E'abc' LIKE E'a%')
926926like
927− :: Expression schema relations grouping params (nullity 'PGtext)
927+ :: Expression schema from grouping params (nullity 'PGtext)
928928 -- ^ string
929− -> Expression schema relations grouping params (nullity 'PGtext)
929+ -> Expression schema from grouping params (nullity 'PGtext)
930930 -- ^ pattern
931− -> Expression schema relations grouping params (nullity 'PGbool)
931+ -> Expression schema from grouping params (nullity 'PGbool)
932932like = unsafeBinaryOp "LIKE"
933933
934934{-----------------------------------------
@@ -943,33 +943,33 @@ Table 9.44: json and jsonb operators
943943-- | Get JSON value (object field or array element) at a key.
944944(.->)
945945 :: (PGjson_ json, PGjsonKey key)
946− => Expression schema relations grouping params (nullity json)
947− -> Expression schema relations grouping params (nullity key)
948− -> Expression schema relations grouping params ('Null json)
946+ => Expression schema from grouping params (nullity json)
947+ -> Expression schema from grouping params (nullity key)
948+ -> Expression schema from grouping params ('Null json)
949949(.->) = unsafeBinaryOp "->"
950950
951951-- | Get JSON value (object field or array element) at a key, as text.
952952(.->>)
953953 :: (PGjson_ json, PGjsonKey key)
954− => Expression schema relations grouping params (nullity json)
955− -> Expression schema relations grouping params (nullity key)
956− -> Expression schema relations grouping params ('Null 'PGtext)
954+ => Expression schema from grouping params (nullity json)
955+ -> Expression schema from grouping params (nullity key)
956+ -> Expression schema from grouping params ('Null 'PGtext)
957957(.->>) = unsafeBinaryOp "->>"
958958
959959-- | Get JSON value at a specified path.
960960(.#>)
961961 :: (PGjson_ json, PGtextArray "(.#>)" path)
962− => Expression schema relations grouping params (nullity json)
963− -> Expression schema relations grouping params (nullity path)
964− -> Expression schema relations grouping params ('Null json)
962+ => Expression schema from grouping params (nullity json)
963+ -> Expression schema from grouping params (nullity path)
964+ -> Expression schema from grouping params ('Null json)
965965(.#>) = unsafeBinaryOp "#>"
966966
967967-- | Get JSON value at a specified path as text.
968968(.#>>)
969969 :: (PGjson_ json, PGtextArray "(.#>>)" path)
970− => Expression schema relations grouping params (nullity json)
971− -> Expression schema relations grouping params (nullity path)
972− -> Expression schema relations grouping params ('Null 'PGtext)
970+ => Expression schema from grouping params (nullity json)
971+ -> Expression schema from grouping params (nullity path)
972+ -> Expression schema from grouping params ('Null 'PGtext)
973973(.#>>) = unsafeBinaryOp "#>>"
974974
975975-- Additional jsonb operators
@@ -977,43 +977,43 @@ Table 9.44: json and jsonb operators
977977-- | Does the left JSON value contain the right JSON path/value entries at the
978978-- top level?
979979(.@>)
980− :: Expression schema relations grouping params (nullity 'PGjsonb)
981− -> Expression schema relations grouping params (nullity 'PGjsonb)
982− -> Condition schema relations grouping params
980+ :: Expression schema from grouping params (nullity 'PGjsonb)
981+ -> Expression schema from grouping params (nullity 'PGjsonb)
982+ -> Condition schema from grouping params
983983(.@>) = unsafeBinaryOp "@>"
984984
985985-- | Are the left JSON path/value entries contained at the top level within the
986986-- right JSON value?
987987(.<@)
988− :: Expression schema relations grouping params (nullity 'PGjsonb)
989− -> Expression schema relations grouping params (nullity 'PGjsonb)
990− -> Condition schema relations grouping params
988+ :: Expression schema from grouping params (nullity 'PGjsonb)
989+ -> Expression schema from grouping params (nullity 'PGjsonb)
990+ -> Condition schema from grouping params
991991(.<@) = unsafeBinaryOp "<@"
992992
993993-- | Does the string exist as a top-level key within the JSON value?
994994(.?)
995− :: Expression schema relations grouping params (nullity 'PGjsonb)
996− -> Expression schema relations grouping params (nullity 'PGtext)
997− -> Condition schema relations grouping params
995+ :: Expression schema from grouping params (nullity 'PGjsonb)
996+ -> Expression schema from grouping params (nullity 'PGtext)
997+ -> Condition schema from grouping params
998998(.?) = unsafeBinaryOp "?"
999999
10001000-- | Do any of these array strings exist as top-level keys?
10011001(.?|)
1002− :: Expression schema relations grouping params (nullity 'PGjsonb)
1003− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1004− -> Condition schema relations grouping params
1002+ :: Expression schema from grouping params (nullity 'PGjsonb)
1003+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1004+ -> Condition schema from grouping params
10051005(.?|) = unsafeBinaryOp "?|"
10061006
10071007-- | Do all of these array strings exist as top-level keys?
10081008(.?&)
1009− :: Expression schema relations grouping params (nullity 'PGjsonb)
1010− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1011− -> Condition schema relations grouping params
1009+ :: Expression schema from grouping params (nullity 'PGjsonb)
1010+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1011+ -> Condition schema from grouping params
10121012(.?&) = unsafeBinaryOp "?&"
10131013
10141014-- | Concatenate two jsonb values into a new jsonb value.
10151015instance
1016− Semigroup (Expression schema relations grouping param (nullity 'PGjsonb)) where
1016+ Semigroup (Expression schema from grouping param (nullity 'PGjsonb)) where
10171017 (<>) = unsafeBinaryOp "||"
10181018
10191019-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1030,18 +1030,18 @@ instance
10301030-- count from the end). Throws an error if top level container is not an array.
10311031(.-.)
10321032 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1033− => Expression schema relations grouping params (nullity 'PGjsonb)
1034− -> Expression schema relations grouping params (nullity key)
1035− -> Expression schema relations grouping params (nullity 'PGjsonb)
1033+ => Expression schema from grouping params (nullity 'PGjsonb)
1034+ -> Expression schema from grouping params (nullity key)
1035+ -> Expression schema from grouping params (nullity 'PGjsonb)
10361036(.-.) = unsafeBinaryOp "-"
10371037
10381038-- | Delete the field or element with specified path (for JSON arrays, negative
10391039-- integers count from the end)
10401040(#-.)
10411041 :: PGtextArray "(#-.)" arrayty
1042− => Expression schema relations grouping params (nullity 'PGjsonb)
1043− -> Expression schema relations grouping params (nullity arrayty)
1044− -> Expression schema relations grouping params (nullity 'PGjsonb)
1042+ => Expression schema from grouping params (nullity 'PGjsonb)
1043+ -> Expression schema from grouping params (nullity arrayty)
1044+ -> Expression schema from grouping params (nullity 'PGjsonb)
10451045(#-.) = unsafeBinaryOp "#-"
10461046
10471047{-----------------------------------------
@@ -1049,11 +1049,11 @@ Table 9.45: JSON creation functions
10491049-----------------------------------------}
10501050
10511051-- | Literal binary JSON
1052−jsonbLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjsonb)
1052+jsonbLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjsonb)
10531053jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
10541054
10551055-- | Literal JSON
1056−jsonLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjson)
1056+jsonLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjson)
10571057jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
10581058
10591059-- | Returns the value as json. Arrays and composites are converted
@@ -1063,8 +1063,8 @@ jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.enco
10631063-- number, a Boolean, or a null value, the text representation will be used, in
10641064-- such a fashion that it is a valid json value.
10651065toJson
1066− :: Expression schema relations grouping params (nullity ty)
1067− -> Expression schema relations grouping params (nullity 'PGjson)
1066+ :: Expression schema from grouping params (nullity ty)
1067+ -> Expression schema from grouping params (nullity 'PGjson)
10681068toJson = unsafeFunction "to_json"
10691069
10701070-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1074,43 +1074,43 @@ toJson = unsafeFunction "to_json"
10741074-- number, a Boolean, or a null value, the text representation will be used, in
10751075-- such a fashion that it is a valid jsonb value.
10761076toJsonb
1077− :: Expression schema relations grouping params (nullity ty)
1078− -> Expression schema relations grouping params (nullity 'PGjsonb)
1077+ :: Expression schema from grouping params (nullity ty)
1078+ -> Expression schema from grouping params (nullity 'PGjsonb)
10791079toJsonb = unsafeFunction "to_jsonb"
10801080
10811081-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
10821082-- becomes a JSON array of arrays.
10831083arrayToJson
10841084 :: PGarray "arrayToJson" arr
1085− => Expression schema relations grouping params (nullity arr)
1086− -> Expression schema relations grouping params (nullity 'PGjson)
1085+ => Expression schema from grouping params (nullity arr)
1086+ -> Expression schema from grouping params (nullity 'PGjson)
10871087arrayToJson = unsafeFunction "array_to_json"
10881088
10891089-- | Returns the row as a JSON object.
10901090rowToJson
1091− :: Expression schema relations grouping params (nullity ('PGcomposite ty))
1092− -> Expression schema relations grouping params (nullity 'PGjson)
1091+ :: Expression schema from grouping params (nullity ('PGcomposite ty))
1092+ -> Expression schema from grouping params (nullity 'PGjson)
10931093rowToJson = unsafeFunction "row_to_json"
10941094
10951095-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
10961096-- argument list.
10971097jsonBuildArray
10981098 :: SListI elems
1099− => NP (Expression schema relations grouping params) elems
1100− -> Expression schema relations grouping params (nullity 'PGjson)
1099+ => NP (Expression schema from grouping params) elems
1100+ -> Expression schema from grouping params (nullity 'PGjson)
11011101jsonBuildArray = unsafeVariadicFunction "json_build_array"
11021102
11031103-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
11041104-- variadic argument list.
11051105jsonbBuildArray
11061106 :: SListI elems
1107− => NP (Expression schema relations grouping params) elems
1108− -> Expression schema relations grouping params (nullity 'PGjsonb)
1107+ => NP (Expression schema from grouping params) elems
1108+ -> Expression schema from grouping params (nullity 'PGjsonb)
11091109jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
11101110
11111111unsafeRowFunction
11121112 :: All Top elems
1113− => NP (Aliased (Expression schema relations grouping params)) elems
1113+ => NP (Aliased (Expression schema from grouping params)) elems
11141114 -> [ByteString]
11151115unsafeRowFunction =
11161116 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1122,8 +1122,8 @@ unsafeRowFunction =
11221122-- and values.
11231123jsonBuildObject
11241124 :: All Top elems
1125− => NP (Aliased (Expression schema relations grouping params)) elems
1126− -> Expression schema relations grouping params (nullity 'PGjson)
1125+ => NP (Aliased (Expression schema from grouping params)) elems
1126+ -> Expression schema from grouping params (nullity 'PGjson)
11271127jsonBuildObject
11281128 = unsafeFunction "json_build_object"
11291129 . UnsafeExpression
@@ -1135,8 +1135,8 @@ jsonBuildObject
11351135-- between text and values.
11361136jsonbBuildObject
11371137 :: All Top elems
1138− => NP (Aliased (Expression schema relations grouping params)) elems
1139− -> Expression schema relations grouping params (nullity 'PGjsonb)
1138+ => NP (Aliased (Expression schema from grouping params)) elems
1139+ -> Expression schema from grouping params (nullity 'PGjsonb)
11401140jsonbBuildObject
11411141 = unsafeFunction "jsonb_build_object"
11421142 . UnsafeExpression
@@ -1149,8 +1149,8 @@ jsonbBuildObject
11491149-- array has exactly two elements, which are taken as a key/value pair.
11501150jsonObject
11511151 :: PGarrayOf "jsonObject" arr ('NotNull 'PGtext)
1152− => Expression schema relations grouping params (nullity arr)
1153− -> Expression schema relations grouping params (nullity 'PGjson)
1152+ => Expression schema from grouping params (nullity arr)
1153+ -> Expression schema from grouping params (nullity 'PGjson)
11541154jsonObject = unsafeFunction "json_object"
11551155
11561156-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1159,8 +1159,8 @@ jsonObject = unsafeFunction "json_object"
11591159-- array has exactly two elements, which are taken as a key/value pair.
11601160jsonbObject
11611161 :: PGarrayOf "jsonbObject" arr ('NotNull 'PGtext)
1162− => Expression schema relations grouping params (nullity arr)
1163− -> Expression schema relations grouping params (nullity 'PGjsonb)
1162+ => Expression schema from grouping params (nullity arr)
1163+ -> Expression schema from grouping params (nullity 'PGjsonb)
11641164jsonbObject = unsafeFunction "jsonb_object"
11651165
11661166-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1168,9 +1168,9 @@ jsonbObject = unsafeFunction "jsonb_object"
11681168jsonZipObject
11691169 :: ( PGarrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
11701170 , PGarrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1171− => Expression schema relations grouping params (nullity keysArray)
1172− -> Expression schema relations grouping params (nullity valuesArray)
1173− -> Expression schema relations grouping params (nullity 'PGjson)
1171+ => Expression schema from grouping params (nullity keysArray)
1172+ -> Expression schema from grouping params (nullity valuesArray)
1173+ -> Expression schema from grouping params (nullity 'PGjson)
11741174jsonZipObject ks vs =
11751175 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
11761176
@@ -1180,9 +1180,9 @@ jsonZipObject ks vs =
11801180jsonbZipObject
11811181 :: ( PGarrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
11821182 , PGarrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1183− => Expression schema relations grouping params (nullity keysArray)
1184− -> Expression schema relations grouping params (nullity valuesArray)
1185− -> Expression schema relations grouping params (nullity 'PGjsonb)
1183+ => Expression schema from grouping params (nullity keysArray)
1184+ -> Expression schema from grouping params (nullity valuesArray)
1185+ -> Expression schema from grouping params (nullity 'PGjsonb)
11861186jsonbZipObject ks vs =
11871187 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
11881188
@@ -1192,23 +1192,23 @@ Table 9.46: JSON processing functions
11921192
11931193-- | Returns the number of elements in the outermost JSON array.
11941194jsonArrayLength
1195− :: Expression schema relations grouping params (nullity 'PGjson)
1196− -> Expression schema relations grouping params (nullity 'PGint4)
1195+ :: Expression schema from grouping params (nullity 'PGjson)
1196+ -> Expression schema from grouping params (nullity 'PGint4)
11971197jsonArrayLength = unsafeFunction "json_array_length"
11981198
11991199-- | Returns the number of elements in the outermost binary JSON array.
12001200jsonbArrayLength
1201− :: Expression schema relations grouping params (nullity 'PGjsonb)
1202− -> Expression schema relations grouping params (nullity 'PGint4)
1201+ :: Expression schema from grouping params (nullity 'PGjsonb)
1202+ -> Expression schema from grouping params (nullity 'PGint4)
12031203jsonbArrayLength = unsafeFunction "jsonb_array_length"
12041204
12051205-- | Returns JSON value pointed to by the given path (equivalent to #>
12061206-- operator).
12071207jsonExtractPath
12081208 :: SListI elems
1209− => Expression schema relations grouping params (nullity 'PGjson)
1210− -> NP (Expression schema relations grouping params) elems
1211− -> Expression schema relations grouping params (nullity 'PGjsonb)
1209+ => Expression schema from grouping params (nullity 'PGjson)
1210+ -> NP (Expression schema from grouping params) elems
1211+ -> Expression schema from grouping params (nullity 'PGjsonb)
12121212jsonExtractPath x xs =
12131213 unsafeVariadicFunction "json_extract_path" (x :* xs)
12141214
@@ -1216,9 +1216,9 @@ jsonExtractPath x xs =
12161216-- operator).
12171217jsonbExtractPath
12181218 :: SListI elems
1219− => Expression schema relations grouping params (nullity 'PGjsonb)
1220− -> NP (Expression schema relations grouping params) elems
1221− -> Expression schema relations grouping params (nullity 'PGjsonb)
1219+ => Expression schema from grouping params (nullity 'PGjsonb)
1220+ -> NP (Expression schema from grouping params) elems
1221+ -> Expression schema from grouping params (nullity 'PGjsonb)
12221222jsonbExtractPath x xs =
12231223 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
12241224
@@ -1226,9 +1226,9 @@ jsonbExtractPath x xs =
12261226-- operator), as text.
12271227jsonExtractPathAsText
12281228 :: SListI elems
1229− => Expression schema relations grouping params (nullity 'PGjson)
1230− -> NP (Expression schema relations grouping params) elems
1231− -> Expression schema relations grouping params (nullity 'PGjson)
1229+ => Expression schema from grouping params (nullity 'PGjson)
1230+ -> NP (Expression schema from grouping params) elems
1231+ -> Expression schema from grouping params (nullity 'PGjson)
12321232jsonExtractPathAsText x xs =
12331233 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
12341234
@@ -1236,50 +1236,50 @@ jsonExtractPathAsText x xs =
12361236-- operator), as text.
12371237jsonbExtractPathAsText
12381238 :: SListI elems
1239− => Expression schema relations grouping params (nullity 'PGjsonb)
1240− -> NP (Expression schema relations grouping params) elems
1241− -> Expression schema relations grouping params (nullity 'PGjsonb)
1239+ => Expression schema from grouping params (nullity 'PGjsonb)
1240+ -> NP (Expression schema from grouping params) elems
1241+ -> Expression schema from grouping params (nullity 'PGjsonb)
12421242jsonbExtractPathAsText x xs =
12431243 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
12441244
12451245-- | Returns set of keys in the outermost JSON object.
12461246jsonObjectKeys
1247− :: Expression schema relations grouping params (nullity 'PGjson)
1248− -> Expression schema relations grouping params (nullity 'PGtext)
1247+ :: Expression schema from grouping params (nullity 'PGjson)
1248+ -> Expression schema from grouping params (nullity 'PGtext)
12491249jsonObjectKeys = unsafeFunction "json_object_keys"
12501250
12511251-- | Returns set of keys in the outermost JSON object.
12521252jsonbObjectKeys
1253− :: Expression schema relations grouping params (nullity 'PGjsonb)
1254− -> Expression schema relations grouping params (nullity 'PGtext)
1253+ :: Expression schema from grouping params (nullity 'PGjsonb)
1254+ -> Expression schema from grouping params (nullity 'PGtext)
12551255jsonbObjectKeys = unsafeFunction "jsonb_object_keys"
12561256
12571257-- | Returns the type of the outermost JSON value as a text string. Possible
12581258-- types are object, array, string, number, boolean, and null.
12591259jsonTypeof
1260− :: Expression schema relations grouping params (nullity 'PGjson)
1261− -> Expression schema relations grouping params (nullity 'PGtext)
1260+ :: Expression schema from grouping params (nullity 'PGjson)
1261+ -> Expression schema from grouping params (nullity 'PGtext)
12621262jsonTypeof = unsafeFunction "json_typeof"
12631263
12641264-- | Returns the type of the outermost binary JSON value as a text string.
12651265-- Possible types are object, array, string, number, boolean, and null.
12661266jsonbTypeof
1267− :: Expression schema relations grouping params (nullity 'PGjsonb)
1268− -> Expression schema relations grouping params (nullity 'PGtext)
1267+ :: Expression schema from grouping params (nullity 'PGjsonb)
1268+ -> Expression schema from grouping params (nullity 'PGtext)
12691269jsonbTypeof = unsafeFunction "jsonb_typeof"
12701270
12711271-- | Returns its argument with all object fields that have null values omitted.
12721272-- Other null values are untouched.
12731273jsonStripNulls
1274− :: Expression schema relations grouping params (nullity 'PGjson)
1275− -> Expression schema relations grouping params (nullity 'PGjson)
1274+ :: Expression schema from grouping params (nullity 'PGjson)
1275+ -> Expression schema from grouping params (nullity 'PGjson)
12761276jsonStripNulls = unsafeFunction "json_strip_nulls"
12771277
12781278-- | Returns its argument with all object fields that have null values omitted.
12791279-- Other null values are untouched.
12801280jsonbStripNulls
1281− :: Expression schema relations grouping params (nullity 'PGjsonb)
1282− -> Expression schema relations grouping params (nullity 'PGjsonb)
1281+ :: Expression schema from grouping params (nullity 'PGjsonb)
1282+ -> Expression schema from grouping params (nullity 'PGjsonb)
12831283jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
12841284
12851285-- | @ jsonbSet target path new_value create_missing @
@@ -1291,11 +1291,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
12911291-- arrays.
12921292jsonbSet
12931293 :: PGtextArray "jsonbSet" arr
1294− => Expression schema relations grouping params (nullity 'PGjsonb)
1295− -> Expression schema relations grouping params (nullity arr)
1296− -> Expression schema relations grouping params (nullity 'PGjsonb)
1297− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1298− -> Expression schema relations grouping params (nullity 'PGjsonb)
1294+ => Expression schema from grouping params (nullity 'PGjsonb)
1295+ -> Expression schema from grouping params (nullity arr)
1296+ -> Expression schema from grouping params (nullity 'PGjsonb)
1297+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1298+ -> Expression schema from grouping params (nullity 'PGjsonb)
12991299jsonbSet tgt path val createMissing = case createMissing of
13001300 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
13011301 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1310,19 +1310,19 @@ jsonbSet tgt path val createMissing = case createMissing of
13101310-- in path count from the end of JSON arrays.
13111311jsonbInsert
13121312 :: PGtextArray "jsonbInsert" arr
1313− => Expression schema relations grouping params (nullity 'PGjsonb)
1314− -> Expression schema relations grouping params (nullity arr)
1315− -> Expression schema relations grouping params (nullity 'PGjsonb)
1316− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1317− -> Expression schema relations grouping params (nullity 'PGjsonb)
1313+ => Expression schema from grouping params (nullity 'PGjsonb)
1314+ -> Expression schema from grouping params (nullity arr)
1315+ -> Expression schema from grouping params (nullity 'PGjsonb)
1316+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1317+ -> Expression schema from grouping params (nullity 'PGjsonb)
13181318jsonbInsert tgt path val insertAfter = case insertAfter of
13191319 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
13201320 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
13211321
13221322-- | Returns its argument as indented JSON text.
13231323jsonbPretty
1324− :: Expression schema relations grouping params (nullity 'PGjsonb)
1325− -> Expression schema relations grouping params (nullity 'PGtext)
1324+ :: Expression schema from grouping params (nullity 'PGjsonb)
1325+ -> Expression schema from grouping params (nullity 'PGtext)
13261326jsonbPretty = unsafeFunction "jsonb_pretty"
13271327
13281328{-----------------------------------------
@@ -1332,16 +1332,16 @@ aggregation
13321332-- | escape hatch to define aggregate functions
13331333unsafeAggregate
13341334 :: ByteString -- ^ aggregate function
1335− -> Expression schema relations 'Ungrouped params (xty)
1336− -> Expression schema relations ('Grouped bys) params (yty)
1335+ -> Expression schema from 'Ungrouped params (xty)
1336+ -> Expression schema from ('Grouped bys) params (yty)
13371337unsafeAggregate fun x = UnsafeExpression $ mconcat
13381338 [fun, "(", renderExpression x, ")"]
13391339
13401340-- | escape hatch to define aggregate functions over distinct values
13411341unsafeAggregateDistinct
13421342 :: ByteString -- ^ aggregate function
1343− -> Expression schema relations 'Ungrouped params (xty)
1344− -> Expression schema relations ('Grouped bys) params (yty)
1343+ -> Expression schema from 'Ungrouped params (xty)
1344+ -> Expression schema from ('Grouped bys) params (yty)
13451345unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
13461346 [fun, "(DISTINCT ", renderExpression x, ")"]
13471347
@@ -1354,9 +1354,9 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
13541354-- sum("col")
13551355sum_
13561356 :: PGNum ty
1357− => Expression schema relations 'Ungrouped params (nullity ty)
1357+ => Expression schema from 'Ungrouped params (nullity ty)
13581358 -- ^ what to sum
1359− -> Expression schema relations ('Grouped bys) params (nullity ty)
1359+ -> Expression schema from ('Grouped bys) params (nullity ty)
13601360sum_ = unsafeAggregate "sum"
13611361
13621362-- | >>> :{
@@ -1368,18 +1368,18 @@ sum_ = unsafeAggregate "sum"
13681368-- sum(DISTINCT "col")
13691369sumDistinct
13701370 :: PGNum ty
1371− => Expression schema relations 'Ungrouped params (nullity ty)
1371+ => Expression schema from 'Ungrouped params (nullity ty)
13721372 -- ^ what to sum
1373− -> Expression schema relations ('Grouped bys) params (nullity ty)
1373+ -> Expression schema from ('Grouped bys) params (nullity ty)
13741374sumDistinct = unsafeAggregateDistinct "sum"
13751375
13761376-- | A constraint for `PGType`s that you can take averages of and the resulting
13771377-- `PGType`.
13781378class PGAvg ty avg | ty -> avg where
13791379 avg, avgDistinct
1380− :: Expression schema relations 'Ungrouped params (nullity ty)
1380+ :: Expression schema from 'Ungrouped params (nullity ty)
13811381 -- ^ what to average
1382− -> Expression schema relations ('Grouped bys) params (nullity avg)
1382+ -> Expression schema from ('Grouped bys) params (nullity avg)
13831383 avg = unsafeAggregate "avg"
13841384 avgDistinct = unsafeAggregateDistinct "avg"
13851385instance PGAvg 'PGint2 'PGnumeric
@@ -1399,9 +1399,9 @@ instance PGAvg 'PGinterval 'PGinterval
13991399-- bit_and("col")
14001400bitAnd
14011401 :: PGIntegral int
1402− => Expression schema relations 'Ungrouped params (nullity int)
1402+ => Expression schema from 'Ungrouped params (nullity int)
14031403 -- ^ what to aggregate
1404− -> Expression schema relations ('Grouped bys) params (nullity int)
1404+ -> Expression schema from ('Grouped bys) params (nullity int)
14051405bitAnd = unsafeAggregate "bit_and"
14061406
14071407-- | >>> :{
@@ -1413,9 +1413,9 @@ bitAnd = unsafeAggregate "bit_and"
14131413-- bit_or("col")
14141414bitOr
14151415 :: PGIntegral int
1416− => Expression schema relations 'Ungrouped params (nullity int)
1416+ => Expression schema from 'Ungrouped params (nullity int)
14171417 -- ^ what to aggregate
1418− -> Expression schema relations ('Grouped bys) params (nullity int)
1418+ -> Expression schema from ('Grouped bys) params (nullity int)
14191419bitOr = unsafeAggregate "bit_or"
14201420
14211421-- | >>> :{
@@ -1427,9 +1427,9 @@ bitOr = unsafeAggregate "bit_or"
14271427-- bit_and(DISTINCT "col")
14281428bitAndDistinct
14291429 :: PGIntegral int
1430− => Expression schema relations 'Ungrouped params (nullity int)
1430+ => Expression schema from 'Ungrouped params (nullity int)
14311431 -- ^ what to aggregate
1432− -> Expression schema relations ('Grouped bys) params (nullity int)
1432+ -> Expression schema from ('Grouped bys) params (nullity int)
14331433bitAndDistinct = unsafeAggregateDistinct "bit_and"
14341434
14351435-- | >>> :{
@@ -1441,9 +1441,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
14411441-- bit_or(DISTINCT "col")
14421442bitOrDistinct
14431443 :: PGIntegral int
1444− => Expression schema relations 'Ungrouped params (nullity int)
1444+ => Expression schema from 'Ungrouped params (nullity int)
14451445 -- ^ what to aggregate
1446− -> Expression schema relations ('Grouped bys) params (nullity int)
1446+ -> Expression schema from ('Grouped bys) params (nullity int)
14471447bitOrDistinct = unsafeAggregateDistinct "bit_or"
14481448
14491449-- | >>> :{
@@ -1454,9 +1454,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
14541454-- :}
14551455-- bool_and("col")
14561456boolAnd
1457− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1457+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14581458 -- ^ what to aggregate
1459− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1459+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14601460boolAnd = unsafeAggregate "bool_and"
14611461
14621462-- | >>> :{
@@ -1467,9 +1467,9 @@ boolAnd = unsafeAggregate "bool_and"
14671467-- :}
14681468-- bool_or("col")
14691469boolOr
1470− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1470+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14711471 -- ^ what to aggregate
1472− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1472+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14731473boolOr = unsafeAggregate "bool_or"
14741474
14751475-- | >>> :{
@@ -1480,9 +1480,9 @@ boolOr = unsafeAggregate "bool_or"
14801480-- :}
14811481-- bool_and(DISTINCT "col")
14821482boolAndDistinct
1483− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1483+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14841484 -- ^ what to aggregate
1485− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1485+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14861486boolAndDistinct = unsafeAggregateDistinct "bool_and"
14871487
14881488-- | >>> :{
@@ -1493,9 +1493,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
14931493-- :}
14941494-- bool_or(DISTINCT "col")
14951495boolOrDistinct
1496− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1496+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
14971497 -- ^ what to aggregate
1498− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1498+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
14991499boolOrDistinct = unsafeAggregateDistinct "bool_or"
15001500
15011501-- | A special aggregation that does not require an input
@@ -1503,7 +1503,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
15031503-- >>> printSQL countStar
15041504-- count(*)
15051505countStar
1506− :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1506+ :: Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
15071507countStar = UnsafeExpression $ "count(*)"
15081508
15091509-- | >>> :{
@@ -1514,9 +1514,9 @@ countStar = UnsafeExpression $ "count(*)"
15141514-- :}
15151515-- count("col")
15161516count
1517− :: Expression schema relations 'Ungrouped params ty
1517+ :: Expression schema from 'Ungrouped params ty
15181518 -- ^ what to count
1519− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1519+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
15201520count = unsafeAggregate "count"
15211521
15221522-- | >>> :{
@@ -1527,9 +1527,9 @@ count = unsafeAggregate "count"
15271527-- :}
15281528-- count(DISTINCT "col")
15291529countDistinct
1530− :: Expression schema relations 'Ungrouped params ty
1530+ :: Expression schema from 'Ungrouped params ty
15311531 -- ^ what to count
1532− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1532+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
15331533countDistinct = unsafeAggregateDistinct "count"
15341534
15351535-- | synonym for `boolAnd`
@@ -1542,9 +1542,9 @@ countDistinct = unsafeAggregateDistinct "count"
15421542-- :}
15431543-- every("col")
15441544every
1545− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1545+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
15461546 -- ^ what to aggregate
1547− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1547+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
15481548every = unsafeAggregate "every"
15491549
15501550-- | synonym for `boolAndDistinct`
@@ -1557,16 +1557,16 @@ every = unsafeAggregate "every"
15571557-- :}
15581558-- every(DISTINCT "col")
15591559everyDistinct
1560− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1560+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
15611561 -- ^ what to aggregate
1562− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1562+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
15631563everyDistinct = unsafeAggregateDistinct "every"
15641564
15651565-- | minimum and maximum aggregation
15661566max_, min_, maxDistinct, minDistinct
1567− :: Expression schema relations 'Ungrouped params (nullity ty)
1567+ :: Expression schema from 'Ungrouped params (nullity ty)
15681568 -- ^ what to aggregate
1569− -> Expression schema relations ('Grouped bys) params (nullity ty)
1569+ -> Expression schema from ('Grouped bys) params (nullity ty)
15701570max_ = unsafeAggregate "max"
15711571min_ = unsafeAggregate "min"
15721572maxDistinct = unsafeAggregateDistinct "max"
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+3−3
@@ -184,7 +184,7 @@ DELETE FROM "tab" WHERE ("col1" = "col2") RETURNING *
184184newtype Manipulation
185185 (schema :: SchemaType)
186186 (params :: [NullityType])
187− (columns :: RelationType)
187+ (columns :: RowType)
188188 = UnsafeManipulation { renderManipulation :: ByteString }
189189 deriving (GHC.Generic,Show,Eq,Ord,NFData)
190190
@@ -309,7 +309,7 @@ insertQuery_ tab query =
309309-- existing value in the row for an update.
310310data ColumnValue
311311 (schema :: SchemaType)
312− (columns :: RelationType)
312+ (columns :: RowType)
313313 (params :: [NullityType])
314314 (ty :: ColumnType)
315315 where
@@ -333,7 +333,7 @@ data ReturningClause
333333 (schema :: SchemaType)
334334 (columns :: ColumnsType)
335335 (params :: [NullityType])
336− (results :: RelationType)
336+ (results :: RowType)
337337 where
338338 ReturningStar
339339 :: results ~ ColumnsToRelation columns
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+84−84
@@ -328,7 +328,7 @@ in printSQL query
328328newtype Query
329329 (schema :: SchemaType)
330330 (params :: [NullityType])
331− (columns :: RelationType)
331+ (columns :: RowType)
332332 = UnsafeQuery { renderQuery :: ByteString }
333333 deriving (GHC.Generic,Show,Eq,Ord,NFData)
334334instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
@@ -410,9 +410,9 @@ SELECT queries
410410-- the intermediate table are actually output.
411411select
412412 :: SListI columns
413− => NP (Aliased (Expression schema relations grouping params)) (column ': columns)
413+ => NP (Aliased (Expression schema from grouping params)) (column ': columns)
414414 -- ^ select list
415− -> TableExpression schema params relations grouping
415+ -> TableExpression schema params from grouping
416416 -- ^ intermediate virtual table
417417 -> Query schema params (column ': columns)
418418select list rels = UnsafeQuery $
@@ -424,9 +424,9 @@ select list rels = UnsafeQuery $
424424-- be subject to the elimination of duplicate rows using `selectDistinct`.
425425selectDistinct
426426 :: SListI columns
427− => NP (Aliased (Expression schema relations 'Ungrouped params)) (column ': columns)
427+ => NP (Aliased (Expression schema from 'Ungrouped params)) (column ': columns)
428428 -- ^ select list
429− -> TableExpression schema params relations 'Ungrouped
429+ -> TableExpression schema params from 'Ungrouped
430430 -- ^ intermediate virtual table
431431 -> Query schema params (column ': columns)
432432selectDistinct list rels = UnsafeQuery $
@@ -437,8 +437,8 @@ selectDistinct list rels = UnsafeQuery $
437437-- | The simplest kind of query is `selectStar` which emits all columns
438438-- that the table expression produces.
439439selectStar
440− :: HasUnique relation relations columns
441− => TableExpression schema params relations 'Ungrouped
440+ :: HasUnique relation from columns
441+ => TableExpression schema params from 'Ungrouped
442442 -- ^ intermediate virtual table
443443 -> Query schema params columns
444444selectStar rels = UnsafeQuery $ "SELECT" <+> "*" <+> renderTableExpression rels
@@ -446,8 +446,8 @@ selectStar rels = UnsafeQuery $ "SELECT" <+> "*" <+> renderTableExpression rels
446446-- | A `selectDistinctStar` emits all columns that the table expression
447447-- produces and eliminates duplicate rows.
448448selectDistinctStar
449− :: HasUnique relation relations columns
450− => TableExpression schema params relations 'Ungrouped
449+ :: HasUnique relation from columns
450+ => TableExpression schema params from 'Ungrouped
451451 -- ^ intermediate virtual table
452452 -> Query schema params columns
453453selectDistinctStar rels = UnsafeQuery $
@@ -456,27 +456,27 @@ selectDistinctStar rels = UnsafeQuery $
456456-- | When working with multiple tables, it can also be useful to ask
457457-- for all the columns of a particular table, using `selectDotStar`.
458458selectDotStar
459− :: Has relation relations columns
459+ :: Has relation from columns
460460 => Alias relation
461461 -- ^ particular virtual subtable
462− -> TableExpression schema params relations 'Ungrouped
462+ -> TableExpression schema params from 'Ungrouped
463463 -- ^ intermediate virtual table
464464 -> Query schema params columns
465−selectDotStar rel relations = UnsafeQuery $
466− "SELECT" <+> renderAlias rel <> ".*" <+> renderTableExpression relations
465+selectDotStar rel tab = UnsafeQuery $
466+ "SELECT" <+> renderAlias rel <> ".*" <+> renderTableExpression tab
467467
468468-- | A `selectDistinctDotStar` asks for all the columns of a particular table,
469469-- and eliminates duplicate rows.
470470selectDistinctDotStar
471− :: Has relation relations columns
471+ :: Has relation from columns
472472 => Alias relation
473473 -- ^ particular virtual table
474− -> TableExpression schema params relations 'Ungrouped
474+ -> TableExpression schema params from 'Ungrouped
475475 -- ^ intermediate virtual table
476476 -> Query schema params columns
477−selectDistinctDotStar rel relations = UnsafeQuery $
477+selectDistinctDotStar rel tab = UnsafeQuery $
478478 "SELECT DISTINCT" <+> renderAlias rel <> ".*"
479− <+> renderTableExpression relations
479+ <+> renderTableExpression tab
480480
481481-- | `values` computes a row value or set of row values
482482-- specified by value expressions. It is most commonly used
@@ -530,13 +530,13 @@ Table Expressions
530530data TableExpression
531531 (schema :: SchemaType)
532532 (params :: [NullityType])
533− (relations :: RelationsType)
533+ (from :: FromType)
534534 (grouping :: Grouping)
535535 = TableExpression
536− { fromClause :: FromClause schema params relations
536+ { fromClause :: FromClause schema params from
537537 -- ^ A table reference that can be a table name, or a derived table such
538538 -- as a subquery, a @JOIN@ construct, or complex combinations of these.
539− , whereClause :: [Condition schema relations 'Ungrouped params]
539+ , whereClause :: [Condition schema from 'Ungrouped params]
540540 -- ^ optional search coditions, combined with `.&&`. After the processing
541541 -- of the `fromClause` is done, each row of the derived virtual table
542542 -- is checked against the search condition. If the result of the
@@ -545,20 +545,20 @@ data TableExpression
545545 -- at least one column of the table generated in the `fromClause`;
546546 -- this is not required, but otherwise the WHERE clause will
547547 -- be fairly useless.
548− , groupByClause :: GroupByClause relations grouping
548+ , groupByClause :: GroupByClause from grouping
549549 -- ^ The `groupByClause` is used to group together those rows in a table
550550 -- that have the same values in all the columns listed. The order in which
551551 -- the columns are listed does not matter. The effect is to combine each
552552 -- set of rows having common values into one group row that represents all
553553 -- rows in the group. This is done to eliminate redundancy in the output
554554 -- and/or compute aggregates that apply to these groups.
555− , havingClause :: HavingClause schema relations grouping params
555+ , havingClause :: HavingClause schema from grouping params
556556 -- ^ If a table has been grouped using `groupBy`, but only certain groups
557557 -- are of interest, the `havingClause` can be used, much like a
558558 -- `whereClause`, to eliminate groups from the result. Expressions in the
559559 -- `havingClause` can refer both to grouped expressions and to ungrouped
560560 -- expressions (which necessarily involve an aggregate function).
561− , orderByClause :: [SortExpression schema relations grouping params]
561+ , orderByClause :: [SortExpression schema from grouping params]
562562 -- ^ The `orderByClause` is for optional sorting. When more than one
563563 -- `SortExpression` is specified, the later (right) values are used to sort
564564 -- rows that are equal according to the earlier (left) values.
@@ -576,7 +576,7 @@ data TableExpression
576576
577577-- | Render a `TableExpression`
578578renderTableExpression
579− :: TableExpression schema params relations grouping
579+ :: TableExpression schema params from grouping
580580 -> ByteString
581581renderTableExpression
582582 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
@@ -610,16 +610,16 @@ renderTableExpression
610610-- `group`, `having`, `orderBy`, `limit` and `offset`, using the `&` operator
611611-- to match the left-to-right sequencing of their placement in SQL.
612612from
613− :: FromClause schema params relations -- ^ table reference
614− -> TableExpression schema params relations 'Ungrouped
613+ :: FromClause schema params from -- ^ table reference
614+ -> TableExpression schema params from 'Ungrouped
615615from rels = TableExpression rels [] NoGroups NoHaving [] [] []
616616
617617-- | A `where_` is an endomorphism of `TableExpression`s which adds a
618618-- search condition to the `whereClause`.
619619where_
620− :: Condition schema relations 'Ungrouped params -- ^ filtering condition
621− -> TableExpression schema params relations grouping
622− -> TableExpression schema params relations grouping
620+ :: Condition schema from 'Ungrouped params -- ^ filtering condition
621+ -> TableExpression schema params from grouping
622+ -> TableExpression schema params from grouping
623623where_ wh rels = rels {whereClause = wh : whereClause rels}
624624
625625-- | A `groupBy` is a transformation of `TableExpression`s which switches
@@ -627,9 +627,9 @@ where_ wh rels = rels {whereClause = wh : whereClause rels}
627627-- a "grand total" aggregation query.
628628groupBy
629629 :: SListI bys
630− => NP (By relations) bys -- ^ grouped columns
631− -> TableExpression schema params relations 'Ungrouped
632− -> TableExpression schema params relations ('Grouped bys)
630+ => NP (By from) bys -- ^ grouped columns
631+ -> TableExpression schema params from 'Ungrouped
632+ -> TableExpression schema params from ('Grouped bys)
633633groupBy bys rels = TableExpression
634634 { fromClause = fromClause rels
635635 , whereClause = whereClause rels
@@ -643,34 +643,34 @@ groupBy bys rels = TableExpression
643643-- | A `having` is an endomorphism of `TableExpression`s which adds a
644644-- search condition to the `havingClause`.
645645having
646− :: Condition schema relations ('Grouped bys) params -- ^ having condition
647− -> TableExpression schema params relations ('Grouped bys)
648− -> TableExpression schema params relations ('Grouped bys)
646+ :: Condition schema from ('Grouped bys) params -- ^ having condition
647+ -> TableExpression schema params from ('Grouped bys)
648+ -> TableExpression schema params from ('Grouped bys)
649649having hv rels = rels
650650 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
651651
652652-- | An `orderBy` is an endomorphism of `TableExpression`s which appends an
653653-- ordering to the right of the `orderByClause`.
654654orderBy
655− :: [SortExpression schema relations grouping params] -- ^ sort expressions
656− -> TableExpression schema params relations grouping
657− -> TableExpression schema params relations grouping
655+ :: [SortExpression schema from grouping params] -- ^ sort expressions
656+ -> TableExpression schema params from grouping
657+ -> TableExpression schema params from grouping
658658orderBy srts rels = rels {orderByClause = orderByClause rels ++ srts}
659659
660660-- | A `limit` is an endomorphism of `TableExpression`s which adds to the
661661-- `limitClause`.
662662limit
663663 :: Word64 -- ^ limit parameter
664− -> TableExpression schema params relations grouping
665− -> TableExpression schema params relations grouping
664+ -> TableExpression schema params from grouping
665+ -> TableExpression schema params from grouping
666666limit lim rels = rels {limitClause = lim : limitClause rels}
667667
668668-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
669669-- `offsetClause`.
670670offset
671671 :: Word64 -- ^ offset parameter
672− -> TableExpression schema params relations grouping
673− -> TableExpression schema params relations grouping
672+ -> TableExpression schema params from grouping
673+ -> TableExpression schema params from grouping
674674offset off rels = rels {offsetClause = off : offsetClause rels}
675675
676676{-----------------------------------------
@@ -690,8 +690,8 @@ type PGjson_each_text tab = PGjson_each_variant 'PGtext tab
690690type PGjsonb_each_text tab = PGjson_each_variant 'PGtext tab
691691
692692unsafeAliasedFromClauseExpression
693− :: Aliased (Expression schema' relations' grouping' params') ty'
694− -> FromClause schema params relations
693+ :: Aliased (Expression schema' from' grouping' params') ty'
694+ -> FromClause schema params from
695695unsafeAliasedFromClauseExpression aliasedExpr = UnsafeFromClause
696696 (renderAliasedAs renderExpression aliasedExpr)
697697
@@ -726,7 +726,7 @@ jsonbEachAsText (As jexpr jname) = unsafeAliasedFromClauseExpression
726726nullRow
727727 :: Has tab schema ('Table table)
728728 => Alias tab
729− -> Expression schema relations grouping params
729+ -> Expression schema from grouping params
730730 (nullity ('PGcomposite (TableToRelation table)))
731731nullRow tab = UnsafeExpression ("null::"<+>renderAlias tab)
732732
@@ -796,7 +796,7 @@ renderTableTypeExpression (hc `As` tab)
796796
797797unsafeTableAliasedFromClauseExpression
798798 :: All Top types
799− => Expression schema' relations' grouping' params' ty'
799+ => Expression schema' from' grouping' params' ty'
800800 -> Aliased (NP (Aliased (TypeExpression schema))) (tab ::: types)
801801 -> FromClause schema params '[alias ::: types]
802802unsafeTableAliasedFromClauseExpression expr types = UnsafeFromClause
@@ -864,7 +864,7 @@ FROM clauses
864864A `FromClause` can be a table name, or a derived table such
865865as a subquery, a @JOIN@ construct, or complex combinations of these.
866866-}
867−newtype FromClause schema params relations
867+newtype FromClause schema params from
868868 = UnsafeFromClause { renderFromClause :: ByteString }
869869 deriving (GHC.Generic,Show,Eq,Ord,NFData)
870870
@@ -985,20 +985,20 @@ Grouping
985985-- column @col@; otherwise @By2 (\#tab \! \#col)@ will reference a table
986986-- qualified column @tab.col@.
987987data By
988− (relations :: RelationsType)
988+ (from :: FromType)
989989 (by :: (Symbol,Symbol)) where
990990 By1
991− :: (HasUnique relation relations columns, Has column columns ty)
991+ :: (HasUnique relation from columns, Has column columns ty)
992992 => Alias column
993− -> By relations '(relation, column)
993+ -> By from '(relation, column)
994994 By2
995− :: (Has relation relations columns, Has column columns ty)
995+ :: (Has relation from columns, Has column columns ty)
996996 => Alias relation
997997 -> Alias column
998− -> By relations '(relation, column)
999−deriving instance Show (By relations by)
1000−deriving instance Eq (By relations by)
1001−deriving instance Ord (By relations by)
998+ -> By from '(relation, column)
999+deriving instance Show (By from by)
1000+deriving instance Eq (By from by)
1001+deriving instance Ord (By from by)
10021002
10031003instance (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col))
10041004 => IsLabel col (By rels by) where fromLabel = By1 fromLabel
@@ -1011,7 +1011,7 @@ instance (Has rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
10111011 rel ! col = By2 rel col :* Nil
10121012
10131013-- | Renders a `By`.
1014−renderBy :: By relations by -> ByteString
1014+renderBy :: By from by -> ByteString
10151015renderBy = \case
10161016 By1 column -> renderAlias column
10171017 By2 rel column -> renderAlias rel <> "." <> renderAlias column
@@ -1022,15 +1022,15 @@ renderBy = \case
10221022-- done on @NoGroups@ while all output `Expression`s must be aggregated
10231023-- in @Group Nil@. In general, all output `Expression`s in the
10241024-- complement of @bys@ must be aggregated in @Group bys@.
1025−data GroupByClause relations grouping where
1026− NoGroups :: GroupByClause relations 'Ungrouped
1025+data GroupByClause from grouping where
1026+ NoGroups :: GroupByClause from 'Ungrouped
10271027 Group
10281028 :: SListI bys
1029− => NP (By relations) bys
1030− -> GroupByClause relations ('Grouped bys)
1029+ => NP (By from) bys
1030+ -> GroupByClause from ('Grouped bys)
10311031
10321032-- | Renders a `GroupByClause`.
1033−renderGroupByClause :: GroupByClause relations grouping -> ByteString
1033+renderGroupByClause :: GroupByClause from grouping -> ByteString
10341034renderGroupByClause = \case
10351035 NoGroups -> ""
10361036 Group Nil -> ""
@@ -1040,17 +1040,17 @@ renderGroupByClause = \case
10401040-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
10411041-- `TableExpression` must use `Having` whose conditions are combined with
10421042-- `.&&`.
1043−data HavingClause schema relations grouping params where
1044− NoHaving :: HavingClause schema relations 'Ungrouped params
1043+data HavingClause schema from grouping params where
1044+ NoHaving :: HavingClause schema from 'Ungrouped params
10451045 Having
1046− :: [Condition schema relations ('Grouped bys) params]
1047− -> HavingClause schema relations ('Grouped bys) params
1048−deriving instance Show (HavingClause schema relations grouping params)
1049−deriving instance Eq (HavingClause schema relations grouping params)
1050−deriving instance Ord (HavingClause schema relations grouping params)
1046+ :: [Condition schema from ('Grouped bys) params]
1047+ -> HavingClause schema from ('Grouped bys) params
1048+deriving instance Show (HavingClause schema from grouping params)
1049+deriving instance Eq (HavingClause schema from grouping params)
1050+deriving instance Ord (HavingClause schema from grouping params)
10511051
10521052-- | Render a `HavingClause`.
1053−renderHavingClause :: HavingClause schema relations grouping params -> ByteString
1053+renderHavingClause :: HavingClause schema from grouping params -> ByteString
10541054renderHavingClause = \case
10551055 NoHaving -> ""
10561056 Having [] -> ""
@@ -1069,29 +1069,29 @@ Sorting
10691069-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
10701070-- determine whether nulls appear before or after non-null values in the sort
10711071-- ordering of a `Null` result column.
1072−data SortExpression schema relations grouping params where
1072+data SortExpression schema from grouping params where
10731073 Asc
1074− :: Expression schema relations grouping params ('NotNull ty)
1075− -> SortExpression schema relations grouping params
1074+ :: Expression schema from grouping params ('NotNull ty)
1075+ -> SortExpression schema from grouping params
10761076 Desc
1077− :: Expression schema relations grouping params ('NotNull ty)
1078− -> SortExpression schema relations grouping params
1077+ :: Expression schema from grouping params ('NotNull ty)
1078+ -> SortExpression schema from grouping params
10791079 AscNullsFirst
1080− :: Expression schema relations grouping params ('Null ty)
1081− -> SortExpression schema relations grouping params
1080+ :: Expression schema from grouping params ('Null ty)
1081+ -> SortExpression schema from grouping params
10821082 AscNullsLast
1083− :: Expression schema relations grouping params ('Null ty)
1084− -> SortExpression schema relations grouping params
1083+ :: Expression schema from grouping params ('Null ty)
1084+ -> SortExpression schema from grouping params
10851085 DescNullsFirst
1086− :: Expression schema relations grouping params ('Null ty)
1087− -> SortExpression schema relations grouping params
1086+ :: Expression schema from grouping params ('Null ty)
1087+ -> SortExpression schema from grouping params
10881088 DescNullsLast
1089− :: Expression schema relations grouping params ('Null ty)
1090− -> SortExpression schema relations grouping params
1091−deriving instance Show (SortExpression schema relations grouping params)
1089+ :: Expression schema from grouping params ('Null ty)
1090+ -> SortExpression schema from grouping params
1091+deriving instance Show (SortExpression schema from grouping params)
10921092
10931093-- | Render a `SortExpression`.
1094−renderSortExpression :: SortExpression schema relations grouping params -> ByteString
1094+renderSortExpression :: SortExpression schema from grouping params -> ByteString
10951095renderSortExpression = \case
10961096 Asc expression -> renderExpression expression <+> "ASC"
10971097 Desc expression -> renderExpression expression <+> "DESC"
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+19−19
@@ -40,9 +40,9 @@ module Squeal.PostgreSQL.Schema
4040 , ColumnType
4141 -- * Tables
4242 , ColumnsType
43− , RelationType
43+ , RowType
4444 , NilRelation
45− , RelationsType
45+ , FromType
4646 , TableType
4747 -- * Schema
4848 , SchemumType (..)
@@ -302,25 +302,25 @@ type family Uniquely
302302-- :}
303303type TableType = (TableConstraints,ColumnsType)
304304
305−-- | `RelationType` is a row of `NullityType`
305+-- | `RowType` is a row of `NullityType`
306306--
307307-- >>> :{
308−-- type family PersonRelation :: RelationType where
308+-- type family PersonRelation :: RowType where
309309-- PersonRelation =
310310-- '[ "name" ::: 'NotNull 'PGtext
311311-- , "age" ::: 'NotNull 'PGint4
312312-- , "dateOfBirth" ::: 'Null 'PGdate
313313-- ]
314314-- :}
315−type RelationType = [(Symbol,NullityType)]
316−-- | A monokinded empty `RelationType`.
317−type family NilRelation :: RelationType where NilRelation = '[]
315+type RowType = [(Symbol,NullityType)]
316+-- | A monokinded empty `RowType`.
317+type family NilRelation :: RowType where NilRelation = '[]
318318
319−-- | `RelationsType` is a row of `RelationType`s, thought of as a product.
320−type RelationsType = [(Symbol,RelationType)]
319+-- | `FromType` is a row of `RowType`s, thought of as a product.
320+type FromType = [(Symbol,RowType)]
321321
322322-- | `ColumnsToRelation` removes column constraints.
323−type family ColumnsToRelation (columns :: ColumnsType) :: RelationType where
323+type family ColumnsToRelation (columns :: ColumnsType) :: RowType where
324324 ColumnsToRelation '[] = '[]
325325 ColumnsToRelation (column ::: constraint :=> ty ': columns) =
326326 column ::: ty ': ColumnsToRelation columns
@@ -330,7 +330,7 @@ type family TableToColumns (table :: TableType) :: ColumnsType where
330330 TableToColumns (constraints :=> columns) = columns
331331
332332-- | Convert a table to a relation.
333−type family TableToRelation (table :: TableType) :: RelationType where
333+type family TableToRelation (table :: TableType) :: RowType where
334334 TableToRelation tab = ColumnsToRelation (TableToColumns tab)
335335
336336-- | `Grouping` is an auxiliary namespace, created by
@@ -568,21 +568,21 @@ type family NullifyType (ty :: NullityType) :: NullityType where
568568 NullifyType ('NotNull ty) = 'Null ty
569569
570570-- | `NullifyRelation` is an idempotent that nullifies a `ColumnsType`.
571−type family NullifyRelation (columns :: RelationType) :: RelationType where
571+type family NullifyRelation (columns :: RowType) :: RowType where
572572 NullifyRelation '[] = '[]
573573 NullifyRelation (column ::: ty ': columns) =
574574 column ::: NullifyType ty ': NullifyRelation columns
575575
576−-- | `NullifyRelations` is an idempotent that nullifies a `RelationsType`
576+-- | `NullifyRelations` is an idempotent that nullifies a `FromType`
577577-- used to nullify the left or right hand side of an outer join
578578-- in a `Squeal.PostgreSQL.Query.FromClause`.
579−type family NullifyRelations (tables :: RelationsType) :: RelationsType where
579+type family NullifyRelations (tables :: FromType) :: FromType where
580580 NullifyRelations '[] = '[]
581581 NullifyRelations (table ::: columns ': tables) =
582582 table ::: NullifyRelation columns ': NullifyRelations tables
583583
584584-- | `RelationToNullityTypes` drops the column constraints.
585−type family RelationToNullityTypes (rel :: RelationType) :: [NullityType] where
585+type family RelationToNullityTypes (rel :: RowType) :: [NullityType] where
586586 RelationToNullityTypes ('(k, x) : xs) = x : RelationToNullityTypes xs
587587 RelationToNullityTypes '[] = '[]
588588
@@ -648,7 +648,7 @@ type family Length (xs :: [k]) :: Nat where
648648-- `View` or `Typedef`.
649649data SchemumType
650650 = Table TableType
651− | View RelationType
651+ | View RowType
652652 | Typedef PGType
653653
654654-- | The schema of a database consists of a list of aliased,
@@ -657,7 +657,7 @@ type SchemaType = [(Symbol,SchemumType)]
657657
658658-- | Used in `Squeal.Postgresql.Manipulation.with`.
659659type family With
660− (relations :: RelationsType)
660+ (from :: FromType)
661661 (schema :: SchemaType)
662662 :: SchemaType where
663663 With '[] schema = schema
@@ -758,10 +758,10 @@ type family LabelsFrom (hask :: Type) :: [Type.ConstructorName] where
758758type family CompositeFrom (hask :: Type) :: PGType where
759759 CompositeFrom hask = 'PGcomposite (PGFieldsFrom hask)
760760
761−type family PGFieldsFrom (hask :: Type) :: RelationType where
761+type family PGFieldsFrom (hask :: Type) :: RowType where
762762 PGFieldsFrom hask = PGFieldsOf (RecordCodeOf hask)
763763
764−type family PGFieldsOf (fields :: [(Symbol, Type)]) :: RelationType where
764+type family PGFieldsOf (fields :: [(Symbol, Type)]) :: RowType where
765765 PGFieldsOf '[] = '[]
766766 PGFieldsOf (field ': fields) = PGFieldOf field ': PGFieldsOf fields
767767