on dev help sign in
rename kinds
aa75914Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+2−2
@@ -514,11 +514,11 @@ instance FromValue pg y
514 Decoding.valueParser (fromValue @pg) bytestring
514 Decoding.valueParser (fromValue @pg) bytestring
515
515
516-- | A `FromRow` constraint generically sequences the parsings of the columns
516-- | 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
518-- the same field names. You should not define instances of `FromRow`.
518-- the same field names. You should not define instances of `FromRow`.
519-- Instead define `Generic` and `HasDatatypeInfo` instances which in turn
519-- Instead define `Generic` and `HasDatatypeInfo` instances which in turn
520-- provide `FromRow` instances.
520-- provide `FromRow` instances.
521−class SListI result => FromRow (result :: RelationType) y where
521+class SListI result => FromRow (result :: RowType) y where
522 -- | >>> :set -XOverloadedStrings
522 -- | >>> :set -XOverloadedStrings
523 -- >>> import Data.Text
523 -- >>> import Data.Text
524 -- >>> newtype UserId = UserId { getUserId :: Int16 } deriving Show
524 -- >>> 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
807createView
807createView
808 :: KnownSymbol view
808 :: KnownSymbol view
809 => Alias view -- ^ the name of the view to add
809 => Alias view -- ^ the name of the view to add
810− -> Query schema '[] relation
810+ -> Query schema '[] row
811 -- ^ query
811 -- ^ query
812− -> Definition schema (Create view ('View relation) schema)
812+ -> Definition schema (Create view ('View row) schema)
813createView alias query = UnsafeDefinition $
813createView alias query = UnsafeDefinition $
814 "CREATE" <+> "VIEW" <+> renderAlias alias <+> "AS"
814 "CREATE" <+> "VIEW" <+> renderAlias alias <+> "AS"
815 <+> renderQuery query <> ";"
815 <+> renderQuery query <> ";"
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+292−292
@@ -217,14 +217,14 @@ and other operations.
217-}
217-}
218newtype Expression
218newtype Expression
219 (schema :: SchemaType)
219 (schema :: SchemaType)
220− (relations :: RelationsType)
220+ (from :: FromType)
221 (grouping :: Grouping)
221 (grouping :: Grouping)
222 (params :: [NullityType])
222 (params :: [NullityType])
223 (ty :: NullityType)
223 (ty :: NullityType)
224 = UnsafeExpression { renderExpression :: ByteString }
224 = UnsafeExpression { renderExpression :: ByteString }
225 deriving (GHC.Generic,Show,Eq,Ord,NFData)
225 deriving (GHC.Generic,Show,Eq,Ord,NFData)
226
226
227−instance RenderSQL (Expression schema relations grouping params ty) where
227+instance RenderSQL (Expression schema from grouping params ty) where
228 renderSQL = renderExpression
228 renderSQL = renderExpression
229
229
230{- | A `HasParameter` constraint is used to indicate a value that is
230{- | A `HasParameter` constraint is used to indicate a value that is
@@ -248,7 +248,7 @@ class KnownNat n => HasParameter
248 -- ($1 :: int4)
248 -- ($1 :: int4)
249 parameter
249 parameter
250 :: TypeExpression schema ty
250 :: TypeExpression schema ty
251− -> Expression schema relations grouping params ty
251+ -> Expression schema from grouping params ty
252 parameter ty = UnsafeExpression $ parenthesized $
252 parameter ty = UnsafeExpression $ parenthesized $
253 "$" <> renderNat @n <+> "::"
253 "$" <> renderNat @n <+> "::"
254 <+> renderTypeExpression ty
254 <+> renderTypeExpression ty
@@ -263,82 +263,82 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
263-- >>> printSQL expr
263-- >>> printSQL expr
264-- ($1 :: int4)
264-- ($1 :: int4)
265param
265param
266− :: forall n schema params relations grouping ty
266+ :: forall n schema params from grouping ty
267 . (PGTyped schema ty, HasParameter n schema params ty)
267 . (PGTyped schema ty, HasParameter n schema params ty)
268− => Expression schema relations grouping params ty -- ^ param
268+ => Expression schema from grouping params ty -- ^ param
269param = parameter @n pgtype
269param = parameter @n pgtype
270
270
271−instance (HasUnique relation relations columns, Has column columns ty)
271+instance (HasUnique relation from columns, Has column columns ty)
272− => IsLabel column (Expression schema relations 'Ungrouped params ty) where
272+ => IsLabel column (Expression schema from 'Ungrouped params ty) where
273 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
273 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)
275 => IsLabel column
275 => IsLabel column
276− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
276+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
277 fromLabel = fromLabel @column `As` Alias @column
277 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)
279 => IsLabel column
279 => IsLabel column
280− (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
280+ (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
281 fromLabel = fromLabel @column :* Nil
281 fromLabel = fromLabel @column :* Nil
282
282
283−instance (Has relation relations columns, Has column columns ty)
283+instance (Has relation from columns, Has column columns ty)
284− => IsQualified relation column (Expression schema relations 'Ungrouped params ty) where
284+ => IsQualified relation column (Expression schema from 'Ungrouped params ty) where
285 relation ! column = UnsafeExpression $
285 relation ! column = UnsafeExpression $
286 renderAlias relation <> "." <> renderAlias column
286 renderAlias relation <> "." <> renderAlias column
287−instance (Has relation relations columns, Has column columns ty)
287+instance (Has relation from columns, Has column columns ty)
288 => IsQualified relation column
288 => IsQualified relation column
289− (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
289+ (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
290 relation ! column = relation ! column `As` column
290 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)
292 => IsQualified relation column
292 => 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
294 relation ! column = relation ! column :* Nil
294 relation ! column = relation ! column :* Nil
295
295
296instance
296instance
297− ( HasUnique relation relations columns
297+ ( HasUnique relation from columns
298 , Has column columns ty
298 , Has column columns ty
299 , GroupedBy relation column bys
299 , GroupedBy relation column bys
300 ) => IsLabel column
300 ) => IsLabel column
301− (Expression schema relations ('Grouped bys) params ty) where
301+ (Expression schema from ('Grouped bys) params ty) where
302 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
302 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
303instance
303instance
304− ( HasUnique relation relations columns
304+ ( HasUnique relation from columns
305 , Has column columns ty
305 , Has column columns ty
306 , GroupedBy relation column bys
306 , GroupedBy relation column bys
307 ) => IsLabel column
307 ) => IsLabel column
308− ( Aliased (Expression schema relations ('Grouped bys) params)
308+ ( Aliased (Expression schema from ('Grouped bys) params)
309 (column ::: ty) ) where
309 (column ::: ty) ) where
310 fromLabel = fromLabel @column `As` Alias @column
310 fromLabel = fromLabel @column `As` Alias @column
311instance
311instance
312− ( HasUnique relation relations columns
312+ ( HasUnique relation from columns
313 , Has column columns ty
313 , Has column columns ty
314 , GroupedBy relation column bys
314 , GroupedBy relation column bys
315 ) => IsLabel column
315 ) => IsLabel column
316− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
316+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
317 '[column ::: ty] ) where
317 '[column ::: ty] ) where
318 fromLabel = fromLabel @column :* Nil
318 fromLabel = fromLabel @column :* Nil
319
319
320instance
320instance
321− ( Has relation relations columns
321+ ( Has relation from columns
322 , Has column columns ty
322 , Has column columns ty
323 , GroupedBy relation column bys
323 , GroupedBy relation column bys
324 ) => IsQualified relation column
324 ) => IsQualified relation column
325− (Expression schema relations ('Grouped bys) params ty) where
325+ (Expression schema from ('Grouped bys) params ty) where
326 relation ! column = UnsafeExpression $
326 relation ! column = UnsafeExpression $
327 renderAlias relation <> "." <> renderAlias column
327 renderAlias relation <> "." <> renderAlias column
328instance
328instance
329− ( Has relation relations columns
329+ ( Has relation from columns
330 , Has column columns ty
330 , Has column columns ty
331 , GroupedBy relation column bys
331 , GroupedBy relation column bys
332 ) => IsQualified relation column
332 ) => IsQualified relation column
333− (Aliased (Expression schema relations ('Grouped bys) params)
333+ (Aliased (Expression schema from ('Grouped bys) params)
334 (column ::: ty)) where
334 (column ::: ty)) where
335 relation ! column = relation ! column `As` column
335 relation ! column = relation ! column `As` column
336instance
336instance
337− ( Has relation relations columns
337+ ( Has relation from columns
338 , Has column columns ty
338 , Has column columns ty
339 , GroupedBy relation column bys
339 , GroupedBy relation column bys
340 ) => IsQualified relation column
340 ) => IsQualified relation column
341− ( NP (Aliased (Expression schema relations ('Grouped bys) params))
341+ ( NP (Aliased (Expression schema from ('Grouped bys) params))
342 '[column ::: ty]) where
342 '[column ::: ty]) where
343 relation ! column = relation ! column :* Nil
343 relation ! column = relation ! column :* Nil
344
344
@@ -363,11 +363,11 @@ notNull = UnsafeExpression . renderExpression
363-- >>> printSQL $ coalesce [null_, true] false
363-- >>> printSQL $ coalesce [null_, true] false
364-- COALESCE(NULL, TRUE, FALSE)
364-- COALESCE(NULL, TRUE, FALSE)
365coalesce
365coalesce
366− :: [Expression schema relations grouping params ('Null ty)]
366+ :: [Expression schema from grouping params ('Null ty)]
367 -- ^ @NULL@s may be present
367 -- ^ @NULL@s may be present
368− -> Expression schema relations grouping params ('NotNull ty)
368+ -> Expression schema from grouping params ('NotNull ty)
369 -- ^ @NULL@ is absent
369 -- ^ @NULL@ is absent
370− -> Expression schema relations grouping params ('NotNull ty)
370+ -> Expression schema from grouping params ('NotNull ty)
371coalesce nullxs notNullx = UnsafeExpression $
371coalesce nullxs notNullx = UnsafeExpression $
372 "COALESCE" <> parenthesized (commaSeparated
372 "COALESCE" <> parenthesized (commaSeparated
373 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
373 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -377,26 +377,26 @@ coalesce nullxs notNullx = UnsafeExpression $
377-- >>> printSQL $ fromNull true null_
377-- >>> printSQL $ fromNull true null_
378-- COALESCE(NULL, TRUE)
378-- COALESCE(NULL, TRUE)
379fromNull
379fromNull
380− :: Expression schema relations grouping params ('NotNull ty)
380+ :: Expression schema from grouping params ('NotNull ty)
381 -- ^ what to convert @NULL@ to
381 -- ^ what to convert @NULL@ to
382− -> Expression schema relations grouping params ('Null ty)
382+ -> Expression schema from grouping params ('Null ty)
383− -> Expression schema relations grouping params ('NotNull ty)
383+ -> Expression schema from grouping params ('NotNull ty)
384fromNull notNullx nullx = coalesce [nullx] notNullx
384fromNull notNullx nullx = coalesce [nullx] notNullx
385
385
386-- | >>> printSQL $ null_ & isNull
386-- | >>> printSQL $ null_ & isNull
387-- NULL IS NULL
387-- NULL IS NULL
388isNull
388isNull
389− :: Expression schema relations grouping params ('Null ty)
389+ :: Expression schema from grouping params ('Null ty)
390 -- ^ possibly @NULL@
390 -- ^ possibly @NULL@
391− -> Condition schema relations grouping params
391+ -> Condition schema from grouping params
392isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
392isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
393
393
394-- | >>> printSQL $ null_ & isNotNull
394-- | >>> printSQL $ null_ & isNotNull
395-- NULL IS NOT NULL
395-- NULL IS NOT NULL
396isNotNull
396isNotNull
397− :: Expression schema relations grouping params ('Null ty)
397+ :: Expression schema from grouping params ('Null ty)
398 -- ^ possibly @NULL@
398 -- ^ possibly @NULL@
399− -> Condition schema relations grouping params
399+ -> Condition schema from grouping params
400isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
400isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
401
401
402-- | analagous to `maybe` using @IS NULL@
402-- | analagous to `maybe` using @IS NULL@
@@ -404,13 +404,13 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
404-- >>> printSQL $ matchNull true not_ null_
404-- >>> printSQL $ matchNull true not_ null_
405-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
405-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
406matchNull
406matchNull
407− :: Expression schema relations grouping params (nullty)
407+ :: Expression schema from grouping params (nullty)
408 -- ^ what to convert @NULL@ to
408 -- ^ what to convert @NULL@ to
409− -> ( Expression schema relations grouping params ('NotNull ty)
409+ -> ( Expression schema from grouping params ('NotNull ty)
410− -> Expression schema relations grouping params (nullty) )
410+ -> Expression schema from grouping params (nullty) )
411 -- ^ function to perform when @NULL@ is absent
411 -- ^ function to perform when @NULL@ is absent
412− -> Expression schema relations grouping params ('Null ty)
412+ -> Expression schema from grouping params ('Null ty)
413− -> Expression schema relations grouping params (nullty)
413+ -> Expression schema from grouping params (nullty)
414matchNull y f x = ifThenElse (isNull x) y
414matchNull y f x = ifThenElse (isNull x) y
415 (f (UnsafeExpression (renderExpression x)))
415 (f (UnsafeExpression (renderExpression x)))
416
416
@@ -423,25 +423,25 @@ matchNull y f x = ifThenElse (isNull x) y
423NULL IF (FALSE, ($1 :: bool))
423NULL IF (FALSE, ($1 :: bool))
424-}
424-}
425nullIf
425nullIf
426− :: Expression schema relations grouping params ('NotNull ty)
426+ :: Expression schema from grouping params ('NotNull ty)
427 -- ^ @NULL@ is absent
427 -- ^ @NULL@ is absent
428− -> Expression schema relations grouping params ('NotNull ty)
428+ -> Expression schema from grouping params ('NotNull ty)
429 -- ^ @NULL@ is absent
429 -- ^ @NULL@ is absent
430− -> Expression schema relations grouping params ('Null ty)
430+ -> Expression schema from grouping params ('Null ty)
431nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
431nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
432 (renderExpression x <> ", " <> renderExpression y)
432 (renderExpression x <> ", " <> renderExpression y)
433
433
434-- | >>> printSQL $ array [null_, false, true]
434-- | >>> printSQL $ array [null_, false, true]
435-- ARRAY[NULL, FALSE, TRUE]
435-- ARRAY[NULL, FALSE, TRUE]
436array
436array
437− :: [Expression schema relations grouping params ty]
437+ :: [Expression schema from grouping params ty]
438 -- ^ array elements
438 -- ^ array elements
439− -> Expression schema relations grouping params (nullity ('PGvararray ty))
439+ -> Expression schema from grouping params (nullity ('PGvararray ty))
440array xs = UnsafeExpression $
440array xs = UnsafeExpression $
441 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
441 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
442
442
443instance (KnownSymbol label, label `In` labels) => IsPGlabel label
443instance (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
445 label = UnsafeExpression $ renderLabel (PGlabel @label)
445 label = UnsafeExpression $ renderLabel (PGlabel @label)
446
446
447-- | A row constructor is an expression that builds a row value
447-- | A row constructor is an expression that builds a row value
@@ -458,9 +458,9 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
458-- ROW(0, 1)
458-- ROW(0, 1)
459row
459row
460 :: SListI fields
460 :: SListI fields
461− => NP (Aliased (Expression schema relations grouping params)) fields
461+ => NP (Aliased (Expression schema from grouping params)) fields
462 -- ^ zero or more expressions for the row field values
462 -- ^ 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))
464row exprs = UnsafeExpression $ "ROW" <> parenthesized
464row exprs = UnsafeExpression $ "ROW" <> parenthesized
465 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
465 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
466
466
@@ -472,11 +472,11 @@ instance Has field fields ty => IsLabel field
472 renderSymbol @field
472 renderSymbol @field
473
473
474instance Semigroup
474instance Semigroup
475− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
475+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
476 (<>) = unsafeBinaryOp "||"
476 (<>) = unsafeBinaryOp "||"
477
477
478instance Monoid
478instance Monoid
479− (Expression schema relations grouping params (nullity ('PGvararray ty))) where
479+ (Expression schema from grouping params (nullity ('PGvararray ty))) where
480 mempty = array []
480 mempty = array []
481 mappend = (<>)
481 mappend = (<>)
482
482
@@ -484,22 +484,22 @@ instance Monoid
484-- >>> printSQL expr
484-- >>> printSQL expr
485-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
485-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
486greatest
486greatest
487− :: Expression schema relations grouping params (nullty)
487+ :: Expression schema from grouping params (nullty)
488 -- ^ needs at least 1 argument
488 -- ^ needs at least 1 argument
489− -> [Expression schema relations grouping params (nullty)]
489+ -> [Expression schema from grouping params (nullty)]
490 -- ^ or more
490 -- ^ or more
491− -> Expression schema relations grouping params (nullty)
491+ -> Expression schema from grouping params (nullty)
492greatest x xs = UnsafeExpression $ "GREATEST("
492greatest x xs = UnsafeExpression $ "GREATEST("
493 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
493 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
494
494
495-- | >>> printSQL $ least currentTimestamp [null_]
495-- | >>> printSQL $ least currentTimestamp [null_]
496-- LEAST(CURRENT_TIMESTAMP, NULL)
496-- LEAST(CURRENT_TIMESTAMP, NULL)
497least
497least
498− :: Expression schema relations grouping params (nullty)
498+ :: Expression schema from grouping params (nullty)
499 -- ^ needs at least 1 argument
499 -- ^ needs at least 1 argument
500− -> [Expression schema relations grouping params (nullty)]
500+ -> [Expression schema from grouping params (nullty)]
501 -- ^ or more
501 -- ^ or more
502− -> Expression schema relations grouping params (nullty)
502+ -> Expression schema from grouping params (nullty)
503least x xs = UnsafeExpression $ "LEAST("
503least x xs = UnsafeExpression $ "LEAST("
504 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
504 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
505
505
@@ -508,9 +508,9 @@ least x xs = UnsafeExpression $ "LEAST("
508unsafeBinaryOp
508unsafeBinaryOp
509 :: ByteString
509 :: ByteString
510 -- ^ operator
510 -- ^ operator
511− -> Expression schema relations grouping params (ty0)
511+ -> Expression schema from grouping params (ty0)
512− -> Expression schema relations grouping params (ty1)
512+ -> Expression schema from grouping params (ty1)
513− -> Expression schema relations grouping params (ty2)
513+ -> Expression schema from grouping params (ty2)
514unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
514unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
515 renderExpression x <+> op <+> renderExpression y
515 renderExpression x <+> op <+> renderExpression y
516
516
@@ -519,8 +519,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
519unsafeUnaryOp
519unsafeUnaryOp
520 :: ByteString
520 :: ByteString
521 -- ^ operator
521 -- ^ operator
522− -> Expression schema relations grouping params (ty0)
522+ -> Expression schema from grouping params (ty0)
523− -> Expression schema relations grouping params (ty1)
523+ -> Expression schema from grouping params (ty1)
524unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
524unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
525 op <+> renderExpression x
525 op <+> renderExpression x
526
526
@@ -529,8 +529,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
529unsafeFunction
529unsafeFunction
530 :: ByteString
530 :: ByteString
531 -- ^ function
531 -- ^ function
532− -> Expression schema relations grouping params (xty)
532+ -> Expression schema from grouping params (xty)
533− -> Expression schema relations grouping params (yty)
533+ -> Expression schema from grouping params (yty)
534unsafeFunction fun x = UnsafeExpression $
534unsafeFunction fun x = UnsafeExpression $
535 fun <> parenthesized (renderExpression x)
535 fun <> parenthesized (renderExpression x)
536
536
@@ -539,13 +539,13 @@ unsafeVariadicFunction
539 :: SListI elems
539 :: SListI elems
540 => ByteString
540 => ByteString
541 -- ^ function
541 -- ^ function
542− -> NP (Expression schema relations grouping params) elems
542+ -> NP (Expression schema from grouping params) elems
543− -> Expression schema relations grouping params ret
543+ -> Expression schema from grouping params ret
544unsafeVariadicFunction fun x = UnsafeExpression $
544unsafeVariadicFunction fun x = UnsafeExpression $
545 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
545 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderExpression) x)))
546
546
547instance PGNum ty
547instance PGNum ty
548− => Num (Expression schema relations grouping params (nullity ty)) where
548+ => Num (Expression schema from grouping params (nullity ty)) where
549 (+) = unsafeBinaryOp "+"
549 (+) = unsafeBinaryOp "+"
550 (-) = unsafeBinaryOp "-"
550 (-) = unsafeBinaryOp "-"
551 (*) = unsafeBinaryOp "*"
551 (*) = unsafeBinaryOp "*"
@@ -557,12 +557,12 @@ instance PGNum ty
557 . show
557 . show
558
558
559instance (PGNum ty, PGFloating ty) => Fractional
559instance (PGNum ty, PGFloating ty) => Fractional
560− (Expression schema relations grouping params (nullity ty)) where
560+ (Expression schema from grouping params (nullity ty)) where
561 (/) = unsafeBinaryOp "/"
561 (/) = unsafeBinaryOp "/"
562 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
562 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
563
563
564instance (PGNum ty, PGFloating ty) => Floating
564instance (PGNum ty, PGFloating ty) => Floating
565− (Expression schema relations grouping params (nullity ty)) where
565+ (Expression schema from grouping params (nullity ty)) where
566 pi = UnsafeExpression "pi()"
566 pi = UnsafeExpression "pi()"
567 exp = unsafeFunction "exp"
567 exp = unsafeFunction "exp"
568 log = unsafeFunction "ln"
568 log = unsafeFunction "ln"
@@ -585,18 +585,18 @@ instance (PGNum ty, PGFloating ty) => Floating
585
585
586-- | >>> :{
586-- | >>> :{
587-- let
587-- let
588−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
588+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
589-- expression = atan2_ pi 2
589-- expression = atan2_ pi 2
590-- in printSQL expression
590-- in printSQL expression
591-- :}
591-- :}
592-- atan2(pi(), 2)
592-- atan2(pi(), 2)
593atan2_
593atan2_
594 :: PGFloating float
594 :: PGFloating float
595− => Expression schema relations grouping params (nullity float)
595+ => Expression schema from grouping params (nullity float)
596 -- ^ numerator
596 -- ^ numerator
597− -> Expression schema relations grouping params (nullity float)
597+ -> Expression schema from grouping params (nullity float)
598 -- ^ denominator
598 -- ^ denominator
599− -> Expression schema relations grouping params (nullity float)
599+ -> Expression schema from grouping params (nullity float)
600atan2_ y x = UnsafeExpression $
600atan2_ y x = UnsafeExpression $
601 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
601 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
602
602
@@ -609,9 +609,9 @@ atan2_ y x = UnsafeExpression $
609cast
609cast
610 :: TypeExpression schema ty1
610 :: TypeExpression schema ty1
611 -- ^ type to cast as
611 -- ^ type to cast as
612− -> Expression schema relations grouping params ty0
612+ -> Expression schema from grouping params ty0
613 -- ^ value to convert
613 -- ^ value to convert
614− -> Expression schema relations grouping params ty1
614+ -> Expression schema from grouping params ty1
615cast ty x = UnsafeExpression $ parenthesized $
615cast ty x = UnsafeExpression $ parenthesized $
616 renderExpression x <+> "::" <+> renderTypeExpression ty
616 renderExpression x <+> "::" <+> renderTypeExpression ty
617
617
@@ -619,134 +619,134 @@ cast ty x = UnsafeExpression $ parenthesized $
619--
619--
620-- >>> :{
620-- >>> :{
621-- let
621-- let
622−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
622+-- expression :: Expression schema from grouping params (nullity 'PGint2)
623-- expression = 5 `quot_` 2
623-- expression = 5 `quot_` 2
624-- in printSQL expression
624-- in printSQL expression
625-- :}
625-- :}
626-- (5 / 2)
626-- (5 / 2)
627quot_
627quot_
628 :: PGIntegral int
628 :: PGIntegral int
629− => Expression schema relations grouping params (nullity int)
629+ => Expression schema from grouping params (nullity int)
630 -- ^ numerator
630 -- ^ numerator
631− -> Expression schema relations grouping params (nullity int)
631+ -> Expression schema from grouping params (nullity int)
632 -- ^ denominator
632 -- ^ denominator
633− -> Expression schema relations grouping params (nullity int)
633+ -> Expression schema from grouping params (nullity int)
634quot_ = unsafeBinaryOp "/"
634quot_ = unsafeBinaryOp "/"
635
635
636-- | remainder upon integer division
636-- | remainder upon integer division
637--
637--
638-- >>> :{
638-- >>> :{
639-- let
639-- let
640−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
640+-- expression :: Expression schema from grouping params (nullity 'PGint2)
641-- expression = 5 `rem_` 2
641-- expression = 5 `rem_` 2
642-- in printSQL expression
642-- in printSQL expression
643-- :}
643-- :}
644-- (5 % 2)
644-- (5 % 2)
645rem_
645rem_
646 :: PGIntegral int
646 :: PGIntegral int
647− => Expression schema relations grouping params (nullity int)
647+ => Expression schema from grouping params (nullity int)
648 -- ^ numerator
648 -- ^ numerator
649− -> Expression schema relations grouping params (nullity int)
649+ -> Expression schema from grouping params (nullity int)
650 -- ^ denominator
650 -- ^ denominator
651− -> Expression schema relations grouping params (nullity int)
651+ -> Expression schema from grouping params (nullity int)
652rem_ = unsafeBinaryOp "%"
652rem_ = unsafeBinaryOp "%"
653
653
654-- | >>> :{
654-- | >>> :{
655-- let
655-- let
656−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
656+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
657-- expression = trunc pi
657-- expression = trunc pi
658-- in printSQL expression
658-- in printSQL expression
659-- :}
659-- :}
660-- trunc(pi())
660-- trunc(pi())
661trunc
661trunc
662 :: PGFloating frac
662 :: PGFloating frac
663− => Expression schema relations grouping params (nullity frac)
663+ => Expression schema from grouping params (nullity frac)
664 -- ^ fractional number
664 -- ^ fractional number
665− -> Expression schema relations grouping params (nullity frac)
665+ -> Expression schema from grouping params (nullity frac)
666trunc = unsafeFunction "trunc"
666trunc = unsafeFunction "trunc"
667
667
668-- | >>> :{
668-- | >>> :{
669-- let
669-- let
670−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
670+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
671-- expression = round_ pi
671-- expression = round_ pi
672-- in printSQL expression
672-- in printSQL expression
673-- :}
673-- :}
674-- round(pi())
674-- round(pi())
675round_
675round_
676 :: PGFloating frac
676 :: PGFloating frac
677− => Expression schema relations grouping params (nullity frac)
677+ => Expression schema from grouping params (nullity frac)
678 -- ^ fractional number
678 -- ^ fractional number
679− -> Expression schema relations grouping params (nullity frac)
679+ -> Expression schema from grouping params (nullity frac)
680round_ = unsafeFunction "round"
680round_ = unsafeFunction "round"
681
681
682-- | >>> :{
682-- | >>> :{
683-- let
683-- let
684−-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
684+-- expression :: Expression schema from grouping params (nullity 'PGfloat4)
685-- expression = ceiling_ pi
685-- expression = ceiling_ pi
686-- in printSQL expression
686-- in printSQL expression
687-- :}
687-- :}
688-- ceiling(pi())
688-- ceiling(pi())
689ceiling_
689ceiling_
690 :: PGFloating frac
690 :: PGFloating frac
691− => Expression schema relations grouping params (nullity frac)
691+ => Expression schema from grouping params (nullity frac)
692 -- ^ fractional number
692 -- ^ fractional number
693− -> Expression schema relations grouping params (nullity frac)
693+ -> Expression schema from grouping params (nullity frac)
694ceiling_ = unsafeFunction "ceiling"
694ceiling_ = unsafeFunction "ceiling"
695
695
696-- | A `Condition` is an `Expression`, which can evaluate
696-- | A `Condition` is an `Expression`, which can evaluate
697-- to `TRUE`, `FALSE` or `NULL`. This is because SQL uses
697-- to `TRUE`, `FALSE` or `NULL`. This is because SQL uses
698-- a three valued logic.
698-- a three valued logic.
699−type Condition schema relations grouping params =
699+type Condition schema from grouping params =
700− Expression schema relations grouping params ('Null 'PGbool)
700+ Expression schema from grouping params ('Null 'PGbool)
701
701
702-- | >>> printSQL true
702-- | >>> printSQL true
703-- TRUE
703-- TRUE
704−true :: Expression schema relations grouping params (nullity 'PGbool)
704+true :: Expression schema from grouping params (nullity 'PGbool)
705true = UnsafeExpression "TRUE"
705true = UnsafeExpression "TRUE"
706
706
707-- | >>> printSQL false
707-- | >>> printSQL false
708-- FALSE
708-- FALSE
709−false :: Expression schema relations grouping params (nullity 'PGbool)
709+false :: Expression schema from grouping params (nullity 'PGbool)
710false = UnsafeExpression "FALSE"
710false = UnsafeExpression "FALSE"
711
711
712-- | >>> printSQL $ not_ true
712-- | >>> printSQL $ not_ true
713-- (NOT TRUE)
713-- (NOT TRUE)
714not_
714not_
715− :: Expression schema relations grouping params (nullity 'PGbool)
715+ :: Expression schema from grouping params (nullity 'PGbool)
716− -> Expression schema relations grouping params (nullity 'PGbool)
716+ -> Expression schema from grouping params (nullity 'PGbool)
717not_ = unsafeUnaryOp "NOT"
717not_ = unsafeUnaryOp "NOT"
718
718
719-- | >>> printSQL $ true .&& false
719-- | >>> printSQL $ true .&& false
720-- (TRUE AND FALSE)
720-- (TRUE AND FALSE)
721(.&&)
721(.&&)
722− :: Condition schema relations grouping params
722+ :: Condition schema from grouping params
723− -> Condition schema relations grouping params
723+ -> Condition schema from grouping params
724− -> Condition schema relations grouping params
724+ -> Condition schema from grouping params
725(.&&) = unsafeBinaryOp "AND"
725(.&&) = unsafeBinaryOp "AND"
726
726
727-- | >>> printSQL $ true .|| false
727-- | >>> printSQL $ true .|| false
728-- (TRUE OR FALSE)
728-- (TRUE OR FALSE)
729(.||)
729(.||)
730− :: Condition schema relations grouping params
730+ :: Condition schema from grouping params
731− -> Condition schema relations grouping params
731+ -> Condition schema from grouping params
732− -> Condition schema relations grouping params
732+ -> Condition schema from grouping params
733(.||) = unsafeBinaryOp "OR"
733(.||) = unsafeBinaryOp "OR"
734
734
735-- | >>> :{
735-- | >>> :{
736-- let
736-- let
737−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
737+-- expression :: Expression schema from grouping params (nullity 'PGint2)
738-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
738-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
739-- in printSQL expression
739-- in printSQL expression
740-- :}
740-- :}
741-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
741-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
742caseWhenThenElse
742caseWhenThenElse
743− :: [ ( Condition schema relations grouping params
743+ :: [ ( Condition schema from grouping params
744− , Expression schema relations grouping params ty
744+ , Expression schema from grouping params ty
745 ) ]
745 ) ]
746 -- ^ whens and thens
746 -- ^ whens and thens
747− -> Expression schema relations grouping params ty
747+ -> Expression schema from grouping params ty
748 -- ^ else
748 -- ^ else
749− -> Expression schema relations grouping params ty
749+ -> Expression schema from grouping params ty
750caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
750caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
751 [ "CASE"
751 [ "CASE"
752 , mconcat
752 , mconcat
@@ -762,16 +762,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
762
762
763-- | >>> :{
763-- | >>> :{
764-- let
764-- let
765−-- expression :: Expression schema relations grouping params (nullity 'PGint2)
765+-- expression :: Expression schema from grouping params (nullity 'PGint2)
766-- expression = ifThenElse true 1 0
766-- expression = ifThenElse true 1 0
767-- in printSQL expression
767-- in printSQL expression
768-- :}
768-- :}
769-- CASE WHEN TRUE THEN 1 ELSE 0 END
769-- CASE WHEN TRUE THEN 1 ELSE 0 END
770ifThenElse
770ifThenElse
771− :: Condition schema relations grouping params
771+ :: Condition schema from grouping params
772− -> Expression schema relations grouping params ty -- ^ then
772+ -> Expression schema from grouping params ty -- ^ then
773− -> Expression schema relations grouping params ty -- ^ else
773+ -> Expression schema from grouping params ty -- ^ else
774− -> Expression schema relations grouping params ty
774+ -> Expression schema from grouping params ty
775ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
775ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
776
776
777-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
777-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -780,85 +780,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
780-- >>> printSQL $ true .== null_
780-- >>> printSQL $ true .== null_
781-- (TRUE = NULL)
781-- (TRUE = NULL)
782(.==)
782(.==)
783− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
783+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
784− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
784+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
785− -> Condition schema relations grouping params
785+ -> Condition schema from grouping params
786(.==) = unsafeBinaryOp "="
786(.==) = unsafeBinaryOp "="
787infix 4 .==
787infix 4 .==
788
788
789-- | >>> printSQL $ true ./= null_
789-- | >>> printSQL $ true ./= null_
790-- (TRUE <> NULL)
790-- (TRUE <> NULL)
791(./=)
791(./=)
792− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
792+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
793− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
793+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
794− -> Condition schema relations grouping params
794+ -> Condition schema from grouping params
795(./=) = unsafeBinaryOp "<>"
795(./=) = unsafeBinaryOp "<>"
796infix 4 ./=
796infix 4 ./=
797
797
798-- | >>> printSQL $ true .>= null_
798-- | >>> printSQL $ true .>= null_
799-- (TRUE >= NULL)
799-- (TRUE >= NULL)
800(.>=)
800(.>=)
801− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
801+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
802− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
802+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
803− -> Condition schema relations grouping params
803+ -> Condition schema from grouping params
804(.>=) = unsafeBinaryOp ">="
804(.>=) = unsafeBinaryOp ">="
805infix 4 .>=
805infix 4 .>=
806
806
807-- | >>> printSQL $ true .< null_
807-- | >>> printSQL $ true .< null_
808-- (TRUE < NULL)
808-- (TRUE < NULL)
809(.<)
809(.<)
810− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
810+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
811− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
811+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
812− -> Condition schema relations grouping params
812+ -> Condition schema from grouping params
813(.<) = unsafeBinaryOp "<"
813(.<) = unsafeBinaryOp "<"
814infix 4 .<
814infix 4 .<
815
815
816-- | >>> printSQL $ true .<= null_
816-- | >>> printSQL $ true .<= null_
817-- (TRUE <= NULL)
817-- (TRUE <= NULL)
818(.<=)
818(.<=)
819− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
819+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
820− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
820+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
821− -> Condition schema relations grouping params
821+ -> Condition schema from grouping params
822(.<=) = unsafeBinaryOp "<="
822(.<=) = unsafeBinaryOp "<="
823infix 4 .<=
823infix 4 .<=
824
824
825-- | >>> printSQL $ true .> null_
825-- | >>> printSQL $ true .> null_
826-- (TRUE > NULL)
826-- (TRUE > NULL)
827(.>)
827(.>)
828− :: Expression schema relations grouping params (nullity0 ty) -- ^ lhs
828+ :: Expression schema from grouping params (nullity0 ty) -- ^ lhs
829− -> Expression schema relations grouping params (nullity1 ty) -- ^ rhs
829+ -> Expression schema from grouping params (nullity1 ty) -- ^ rhs
830− -> Condition schema relations grouping params
830+ -> Condition schema from grouping params
831(.>) = unsafeBinaryOp ">"
831(.>) = unsafeBinaryOp ">"
832infix 4 .>
832infix 4 .>
833
833
834-- | >>> printSQL currentDate
834-- | >>> printSQL currentDate
835-- CURRENT_DATE
835-- CURRENT_DATE
836currentDate
836currentDate
837− :: Expression schema relations grouping params (nullity 'PGdate)
837+ :: Expression schema from grouping params (nullity 'PGdate)
838currentDate = UnsafeExpression "CURRENT_DATE"
838currentDate = UnsafeExpression "CURRENT_DATE"
839
839
840-- | >>> printSQL currentTime
840-- | >>> printSQL currentTime
841-- CURRENT_TIME
841-- CURRENT_TIME
842currentTime
842currentTime
843− :: Expression schema relations grouping params (nullity 'PGtimetz)
843+ :: Expression schema from grouping params (nullity 'PGtimetz)
844currentTime = UnsafeExpression "CURRENT_TIME"
844currentTime = UnsafeExpression "CURRENT_TIME"
845
845
846-- | >>> printSQL currentTimestamp
846-- | >>> printSQL currentTimestamp
847-- CURRENT_TIMESTAMP
847-- CURRENT_TIMESTAMP
848currentTimestamp
848currentTimestamp
849− :: Expression schema relations grouping params (nullity 'PGtimestamptz)
849+ :: Expression schema from grouping params (nullity 'PGtimestamptz)
850currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
850currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
851
851
852-- | >>> printSQL localTime
852-- | >>> printSQL localTime
853-- LOCALTIME
853-- LOCALTIME
854localTime
854localTime
855− :: Expression schema relations grouping params (nullity 'PGtime)
855+ :: Expression schema from grouping params (nullity 'PGtime)
856localTime = UnsafeExpression "LOCALTIME"
856localTime = UnsafeExpression "LOCALTIME"
857
857
858-- | >>> printSQL localTimestamp
858-- | >>> printSQL localTimestamp
859-- LOCALTIMESTAMP
859-- LOCALTIMESTAMP
860localTimestamp
860localTimestamp
861− :: Expression schema relations grouping params (nullity 'PGtimestamp)
861+ :: Expression schema from grouping params (nullity 'PGtimestamp)
862localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
862localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
863
863
864{-----------------------------------------
864{-----------------------------------------
@@ -866,7 +866,7 @@ text
866-----------------------------------------}
866-----------------------------------------}
867
867
868instance IsString
868instance IsString
869− (Expression schema relations grouping params (nullity 'PGtext)) where
869+ (Expression schema from grouping params (nullity 'PGtext)) where
870 fromString str = UnsafeExpression $
870 fromString str = UnsafeExpression $
871 "E\'" <> fromString (escape =<< str) <> "\'"
871 "E\'" <> fromString (escape =<< str) <> "\'"
872 where
872 where
@@ -882,36 +882,36 @@ instance IsString
882 c -> [c]
882 c -> [c]
883
883
884instance Semigroup
884instance Semigroup
885− (Expression schema relations grouping params (nullity 'PGtext)) where
885+ (Expression schema from grouping params (nullity 'PGtext)) where
886 (<>) = unsafeBinaryOp "||"
886 (<>) = unsafeBinaryOp "||"
887
887
888instance Monoid
888instance Monoid
889− (Expression schema relations grouping params (nullity 'PGtext)) where
889+ (Expression schema from grouping params (nullity 'PGtext)) where
890 mempty = fromString ""
890 mempty = fromString ""
891 mappend = (<>)
891 mappend = (<>)
892
892
893-- | >>> printSQL $ lower "ARRRGGG"
893-- | >>> printSQL $ lower "ARRRGGG"
894-- lower(E'ARRRGGG')
894-- lower(E'ARRRGGG')
895lower
895lower
896− :: Expression schema relations grouping params (nullity 'PGtext)
896+ :: Expression schema from grouping params (nullity 'PGtext)
897 -- ^ string to lower case
897 -- ^ string to lower case
898− -> Expression schema relations grouping params (nullity 'PGtext)
898+ -> Expression schema from grouping params (nullity 'PGtext)
899lower = unsafeFunction "lower"
899lower = unsafeFunction "lower"
900
900
901-- | >>> printSQL $ upper "eeee"
901-- | >>> printSQL $ upper "eeee"
902-- upper(E'eeee')
902-- upper(E'eeee')
903upper
903upper
904− :: Expression schema relations grouping params (nullity 'PGtext)
904+ :: Expression schema from grouping params (nullity 'PGtext)
905 -- ^ string to upper case
905 -- ^ string to upper case
906− -> Expression schema relations grouping params (nullity 'PGtext)
906+ -> Expression schema from grouping params (nullity 'PGtext)
907upper = unsafeFunction "upper"
907upper = unsafeFunction "upper"
908
908
909-- | >>> printSQL $ charLength "four"
909-- | >>> printSQL $ charLength "four"
910-- char_length(E'four')
910-- char_length(E'four')
911charLength
911charLength
912− :: Expression schema relations grouping params (nullity 'PGtext)
912+ :: Expression schema from grouping params (nullity 'PGtext)
913 -- ^ string to measure
913 -- ^ string to measure
914− -> Expression schema relations grouping params (nullity 'PGint4)
914+ -> Expression schema from grouping params (nullity 'PGint4)
915charLength = unsafeFunction "char_length"
915charLength = unsafeFunction "char_length"
916
916
917-- | The `like` expression returns true if the @string@ matches
917-- | The `like` expression returns true if the @string@ matches
@@ -924,11 +924,11 @@ charLength = unsafeFunction "char_length"
924-- >>> printSQL $ "abc" `like` "a%"
924-- >>> printSQL $ "abc" `like` "a%"
925-- (E'abc' LIKE E'a%')
925-- (E'abc' LIKE E'a%')
926like
926like
927− :: Expression schema relations grouping params (nullity 'PGtext)
927+ :: Expression schema from grouping params (nullity 'PGtext)
928 -- ^ string
928 -- ^ string
929− -> Expression schema relations grouping params (nullity 'PGtext)
929+ -> Expression schema from grouping params (nullity 'PGtext)
930 -- ^ pattern
930 -- ^ pattern
931− -> Expression schema relations grouping params (nullity 'PGbool)
931+ -> Expression schema from grouping params (nullity 'PGbool)
932like = unsafeBinaryOp "LIKE"
932like = unsafeBinaryOp "LIKE"
933
933
934{-----------------------------------------
934{-----------------------------------------
@@ -943,33 +943,33 @@ Table 9.44: json and jsonb operators
943-- | Get JSON value (object field or array element) at a key.
943-- | Get JSON value (object field or array element) at a key.
944(.->)
944(.->)
945 :: (PGjson_ json, PGjsonKey key)
945 :: (PGjson_ json, PGjsonKey key)
946− => Expression schema relations grouping params (nullity json)
946+ => Expression schema from grouping params (nullity json)
947− -> Expression schema relations grouping params (nullity key)
947+ -> Expression schema from grouping params (nullity key)
948− -> Expression schema relations grouping params ('Null json)
948+ -> Expression schema from grouping params ('Null json)
949(.->) = unsafeBinaryOp "->"
949(.->) = unsafeBinaryOp "->"
950
950
951-- | Get JSON value (object field or array element) at a key, as text.
951-- | Get JSON value (object field or array element) at a key, as text.
952(.->>)
952(.->>)
953 :: (PGjson_ json, PGjsonKey key)
953 :: (PGjson_ json, PGjsonKey key)
954− => Expression schema relations grouping params (nullity json)
954+ => Expression schema from grouping params (nullity json)
955− -> Expression schema relations grouping params (nullity key)
955+ -> Expression schema from grouping params (nullity key)
956− -> Expression schema relations grouping params ('Null 'PGtext)
956+ -> Expression schema from grouping params ('Null 'PGtext)
957(.->>) = unsafeBinaryOp "->>"
957(.->>) = unsafeBinaryOp "->>"
958
958
959-- | Get JSON value at a specified path.
959-- | Get JSON value at a specified path.
960(.#>)
960(.#>)
961 :: (PGjson_ json, PGtextArray "(.#>)" path)
961 :: (PGjson_ json, PGtextArray "(.#>)" path)
962− => Expression schema relations grouping params (nullity json)
962+ => Expression schema from grouping params (nullity json)
963− -> Expression schema relations grouping params (nullity path)
963+ -> Expression schema from grouping params (nullity path)
964− -> Expression schema relations grouping params ('Null json)
964+ -> Expression schema from grouping params ('Null json)
965(.#>) = unsafeBinaryOp "#>"
965(.#>) = unsafeBinaryOp "#>"
966
966
967-- | Get JSON value at a specified path as text.
967-- | Get JSON value at a specified path as text.
968(.#>>)
968(.#>>)
969 :: (PGjson_ json, PGtextArray "(.#>>)" path)
969 :: (PGjson_ json, PGtextArray "(.#>>)" path)
970− => Expression schema relations grouping params (nullity json)
970+ => Expression schema from grouping params (nullity json)
971− -> Expression schema relations grouping params (nullity path)
971+ -> Expression schema from grouping params (nullity path)
972− -> Expression schema relations grouping params ('Null 'PGtext)
972+ -> Expression schema from grouping params ('Null 'PGtext)
973(.#>>) = unsafeBinaryOp "#>>"
973(.#>>) = unsafeBinaryOp "#>>"
974
974
975-- Additional jsonb operators
975-- Additional jsonb operators
@@ -977,43 +977,43 @@ Table 9.44: json and jsonb operators
977-- | Does the left JSON value contain the right JSON path/value entries at the
977-- | Does the left JSON value contain the right JSON path/value entries at the
978-- top level?
978-- top level?
979(.@>)
979(.@>)
980− :: Expression schema relations grouping params (nullity 'PGjsonb)
980+ :: Expression schema from grouping params (nullity 'PGjsonb)
981− -> Expression schema relations grouping params (nullity 'PGjsonb)
981+ -> Expression schema from grouping params (nullity 'PGjsonb)
982− -> Condition schema relations grouping params
982+ -> Condition schema from grouping params
983(.@>) = unsafeBinaryOp "@>"
983(.@>) = unsafeBinaryOp "@>"
984
984
985-- | Are the left JSON path/value entries contained at the top level within the
985-- | Are the left JSON path/value entries contained at the top level within the
986-- right JSON value?
986-- right JSON value?
987(.<@)
987(.<@)
988− :: Expression schema relations grouping params (nullity 'PGjsonb)
988+ :: Expression schema from grouping params (nullity 'PGjsonb)
989− -> Expression schema relations grouping params (nullity 'PGjsonb)
989+ -> Expression schema from grouping params (nullity 'PGjsonb)
990− -> Condition schema relations grouping params
990+ -> Condition schema from grouping params
991(.<@) = unsafeBinaryOp "<@"
991(.<@) = unsafeBinaryOp "<@"
992
992
993-- | Does the string exist as a top-level key within the JSON value?
993-- | Does the string exist as a top-level key within the JSON value?
994(.?)
994(.?)
995− :: Expression schema relations grouping params (nullity 'PGjsonb)
995+ :: Expression schema from grouping params (nullity 'PGjsonb)
996− -> Expression schema relations grouping params (nullity 'PGtext)
996+ -> Expression schema from grouping params (nullity 'PGtext)
997− -> Condition schema relations grouping params
997+ -> Condition schema from grouping params
998(.?) = unsafeBinaryOp "?"
998(.?) = unsafeBinaryOp "?"
999
999
1000-- | Do any of these array strings exist as top-level keys?
1000-- | Do any of these array strings exist as top-level keys?
1001(.?|)
1001(.?|)
1002− :: Expression schema relations grouping params (nullity 'PGjsonb)
1002+ :: Expression schema from grouping params (nullity 'PGjsonb)
1003− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1003+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1004− -> Condition schema relations grouping params
1004+ -> Condition schema from grouping params
1005(.?|) = unsafeBinaryOp "?|"
1005(.?|) = unsafeBinaryOp "?|"
1006
1006
1007-- | Do all of these array strings exist as top-level keys?
1007-- | Do all of these array strings exist as top-level keys?
1008(.?&)
1008(.?&)
1009− :: Expression schema relations grouping params (nullity 'PGjsonb)
1009+ :: Expression schema from grouping params (nullity 'PGjsonb)
1010− -> Expression schema relations grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1010+ -> Expression schema from grouping params (nullity ('PGvararray ('NotNull 'PGtext)))
1011− -> Condition schema relations grouping params
1011+ -> Condition schema from grouping params
1012(.?&) = unsafeBinaryOp "?&"
1012(.?&) = unsafeBinaryOp "?&"
1013
1013
1014-- | Concatenate two jsonb values into a new jsonb value.
1014-- | Concatenate two jsonb values into a new jsonb value.
1015instance
1015instance
1016− Semigroup (Expression schema relations grouping param (nullity 'PGjsonb)) where
1016+ Semigroup (Expression schema from grouping param (nullity 'PGjsonb)) where
1017 (<>) = unsafeBinaryOp "||"
1017 (<>) = unsafeBinaryOp "||"
1018
1018
1019-- | Delete a key or keys from a JSON object, or remove an array element.
1019-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1030,18 +1030,18 @@ instance
1030-- count from the end). Throws an error if top level container is not an array.
1030-- count from the end). Throws an error if top level container is not an array.
1031(.-.)
1031(.-.)
1032 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1032 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1033− => Expression schema relations grouping params (nullity 'PGjsonb)
1033+ => Expression schema from grouping params (nullity 'PGjsonb)
1034− -> Expression schema relations grouping params (nullity key)
1034+ -> Expression schema from grouping params (nullity key)
1035− -> Expression schema relations grouping params (nullity 'PGjsonb)
1035+ -> Expression schema from grouping params (nullity 'PGjsonb)
1036(.-.) = unsafeBinaryOp "-"
1036(.-.) = unsafeBinaryOp "-"
1037
1037
1038-- | Delete the field or element with specified path (for JSON arrays, negative
1038-- | Delete the field or element with specified path (for JSON arrays, negative
1039-- integers count from the end)
1039-- integers count from the end)
1040(#-.)
1040(#-.)
1041 :: PGtextArray "(#-.)" arrayty
1041 :: PGtextArray "(#-.)" arrayty
1042− => Expression schema relations grouping params (nullity 'PGjsonb)
1042+ => Expression schema from grouping params (nullity 'PGjsonb)
1043− -> Expression schema relations grouping params (nullity arrayty)
1043+ -> Expression schema from grouping params (nullity arrayty)
1044− -> Expression schema relations grouping params (nullity 'PGjsonb)
1044+ -> Expression schema from grouping params (nullity 'PGjsonb)
1045(#-.) = unsafeBinaryOp "#-"
1045(#-.) = unsafeBinaryOp "#-"
1046
1046
1047{-----------------------------------------
1047{-----------------------------------------
@@ -1049,11 +1049,11 @@ Table 9.45: JSON creation functions
1049-----------------------------------------}
1049-----------------------------------------}
1050
1050
1051-- | Literal binary JSON
1051-- | 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)
1053jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1053jsonbLit = cast jsonb . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1054
1054
1055-- | Literal JSON
1055-- | Literal JSON
1056−jsonLit :: JSON.Value -> Expression schema relations grouping params (nullity 'PGjson)
1056+jsonLit :: JSON.Value -> Expression schema from grouping params (nullity 'PGjson)
1057jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1057jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.encode
1058
1058
1059-- | Returns the value as json. Arrays and composites are converted
1059-- | Returns the value as json. Arrays and composites are converted
@@ -1063,8 +1063,8 @@ jsonLit = cast json . UnsafeExpression . singleQuotedUtf8 . toStrict . JSON.enco
1063-- number, a Boolean, or a null value, the text representation will be used, in
1063-- number, a Boolean, or a null value, the text representation will be used, in
1064-- such a fashion that it is a valid json value.
1064-- such a fashion that it is a valid json value.
1065toJson
1065toJson
1066− :: Expression schema relations grouping params (nullity ty)
1066+ :: Expression schema from grouping params (nullity ty)
1067− -> Expression schema relations grouping params (nullity 'PGjson)
1067+ -> Expression schema from grouping params (nullity 'PGjson)
1068toJson = unsafeFunction "to_json"
1068toJson = unsafeFunction "to_json"
1069
1069
1070-- | Returns the value as jsonb. Arrays and composites are converted
1070-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1074,43 +1074,43 @@ toJson = unsafeFunction "to_json"
1074-- number, a Boolean, or a null value, the text representation will be used, in
1074-- number, a Boolean, or a null value, the text representation will be used, in
1075-- such a fashion that it is a valid jsonb value.
1075-- such a fashion that it is a valid jsonb value.
1076toJsonb
1076toJsonb
1077− :: Expression schema relations grouping params (nullity ty)
1077+ :: Expression schema from grouping params (nullity ty)
1078− -> Expression schema relations grouping params (nullity 'PGjsonb)
1078+ -> Expression schema from grouping params (nullity 'PGjsonb)
1079toJsonb = unsafeFunction "to_jsonb"
1079toJsonb = unsafeFunction "to_jsonb"
1080
1080
1081-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1081-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1082-- becomes a JSON array of arrays.
1082-- becomes a JSON array of arrays.
1083arrayToJson
1083arrayToJson
1084 :: PGarray "arrayToJson" arr
1084 :: PGarray "arrayToJson" arr
1085− => Expression schema relations grouping params (nullity arr)
1085+ => Expression schema from grouping params (nullity arr)
1086− -> Expression schema relations grouping params (nullity 'PGjson)
1086+ -> Expression schema from grouping params (nullity 'PGjson)
1087arrayToJson = unsafeFunction "array_to_json"
1087arrayToJson = unsafeFunction "array_to_json"
1088
1088
1089-- | Returns the row as a JSON object.
1089-- | Returns the row as a JSON object.
1090rowToJson
1090rowToJson
1091− :: Expression schema relations grouping params (nullity ('PGcomposite ty))
1091+ :: Expression schema from grouping params (nullity ('PGcomposite ty))
1092− -> Expression schema relations grouping params (nullity 'PGjson)
1092+ -> Expression schema from grouping params (nullity 'PGjson)
1093rowToJson = unsafeFunction "row_to_json"
1093rowToJson = unsafeFunction "row_to_json"
1094
1094
1095-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1095-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1096-- argument list.
1096-- argument list.
1097jsonBuildArray
1097jsonBuildArray
1098 :: SListI elems
1098 :: SListI elems
1099− => NP (Expression schema relations grouping params) elems
1099+ => NP (Expression schema from grouping params) elems
1100− -> Expression schema relations grouping params (nullity 'PGjson)
1100+ -> Expression schema from grouping params (nullity 'PGjson)
1101jsonBuildArray = unsafeVariadicFunction "json_build_array"
1101jsonBuildArray = unsafeVariadicFunction "json_build_array"
1102
1102
1103-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1103-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1104-- variadic argument list.
1104-- variadic argument list.
1105jsonbBuildArray
1105jsonbBuildArray
1106 :: SListI elems
1106 :: SListI elems
1107− => NP (Expression schema relations grouping params) elems
1107+ => NP (Expression schema from grouping params) elems
1108− -> Expression schema relations grouping params (nullity 'PGjsonb)
1108+ -> Expression schema from grouping params (nullity 'PGjsonb)
1109jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1109jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1110
1110
1111unsafeRowFunction
1111unsafeRowFunction
1112 :: All Top elems
1112 :: All Top elems
1113− => NP (Aliased (Expression schema relations grouping params)) elems
1113+ => NP (Aliased (Expression schema from grouping params)) elems
1114 -> [ByteString]
1114 -> [ByteString]
1115unsafeRowFunction =
1115unsafeRowFunction =
1116 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1116 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1122,8 +1122,8 @@ unsafeRowFunction =
1122-- and values.
1122-- and values.
1123jsonBuildObject
1123jsonBuildObject
1124 :: All Top elems
1124 :: All Top elems
1125− => NP (Aliased (Expression schema relations grouping params)) elems
1125+ => NP (Aliased (Expression schema from grouping params)) elems
1126− -> Expression schema relations grouping params (nullity 'PGjson)
1126+ -> Expression schema from grouping params (nullity 'PGjson)
1127jsonBuildObject
1127jsonBuildObject
1128 = unsafeFunction "json_build_object"
1128 = unsafeFunction "json_build_object"
1129 . UnsafeExpression
1129 . UnsafeExpression
@@ -1135,8 +1135,8 @@ jsonBuildObject
1135-- between text and values.
1135-- between text and values.
1136jsonbBuildObject
1136jsonbBuildObject
1137 :: All Top elems
1137 :: All Top elems
1138− => NP (Aliased (Expression schema relations grouping params)) elems
1138+ => NP (Aliased (Expression schema from grouping params)) elems
1139− -> Expression schema relations grouping params (nullity 'PGjsonb)
1139+ -> Expression schema from grouping params (nullity 'PGjsonb)
1140jsonbBuildObject
1140jsonbBuildObject
1141 = unsafeFunction "jsonb_build_object"
1141 = unsafeFunction "jsonb_build_object"
1142 . UnsafeExpression
1142 . UnsafeExpression
@@ -1149,8 +1149,8 @@ jsonbBuildObject
1149-- array has exactly two elements, which are taken as a key/value pair.
1149-- array has exactly two elements, which are taken as a key/value pair.
1150jsonObject
1150jsonObject
1151 :: PGarrayOf "jsonObject" arr ('NotNull 'PGtext)
1151 :: PGarrayOf "jsonObject" arr ('NotNull 'PGtext)
1152− => Expression schema relations grouping params (nullity arr)
1152+ => Expression schema from grouping params (nullity arr)
1153− -> Expression schema relations grouping params (nullity 'PGjson)
1153+ -> Expression schema from grouping params (nullity 'PGjson)
1154jsonObject = unsafeFunction "json_object"
1154jsonObject = unsafeFunction "json_object"
1155
1155
1156-- | Builds a binary JSON object out of a text array. The array must have either
1156-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1159,8 +1159,8 @@ jsonObject = unsafeFunction "json_object"
1159-- array has exactly two elements, which are taken as a key/value pair.
1159-- array has exactly two elements, which are taken as a key/value pair.
1160jsonbObject
1160jsonbObject
1161 :: PGarrayOf "jsonbObject" arr ('NotNull 'PGtext)
1161 :: PGarrayOf "jsonbObject" arr ('NotNull 'PGtext)
1162− => Expression schema relations grouping params (nullity arr)
1162+ => Expression schema from grouping params (nullity arr)
1163− -> Expression schema relations grouping params (nullity 'PGjsonb)
1163+ -> Expression schema from grouping params (nullity 'PGjsonb)
1164jsonbObject = unsafeFunction "jsonb_object"
1164jsonbObject = unsafeFunction "jsonb_object"
1165
1165
1166-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1166-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1168,9 +1168,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1168jsonZipObject
1168jsonZipObject
1169 :: ( PGarrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1169 :: ( PGarrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1170 , PGarrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1170 , PGarrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1171− => Expression schema relations grouping params (nullity keysArray)
1171+ => Expression schema from grouping params (nullity keysArray)
1172− -> Expression schema relations grouping params (nullity valuesArray)
1172+ -> Expression schema from grouping params (nullity valuesArray)
1173− -> Expression schema relations grouping params (nullity 'PGjson)
1173+ -> Expression schema from grouping params (nullity 'PGjson)
1174jsonZipObject ks vs =
1174jsonZipObject ks vs =
1175 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1175 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1176
1176
@@ -1180,9 +1180,9 @@ jsonZipObject ks vs =
1180jsonbZipObject
1180jsonbZipObject
1181 :: ( PGarrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1181 :: ( PGarrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1182 , PGarrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1182 , PGarrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1183− => Expression schema relations grouping params (nullity keysArray)
1183+ => Expression schema from grouping params (nullity keysArray)
1184− -> Expression schema relations grouping params (nullity valuesArray)
1184+ -> Expression schema from grouping params (nullity valuesArray)
1185− -> Expression schema relations grouping params (nullity 'PGjsonb)
1185+ -> Expression schema from grouping params (nullity 'PGjsonb)
1186jsonbZipObject ks vs =
1186jsonbZipObject ks vs =
1187 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1187 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1188
1188
@@ -1192,23 +1192,23 @@ Table 9.46: JSON processing functions
1192
1192
1193-- | Returns the number of elements in the outermost JSON array.
1193-- | Returns the number of elements in the outermost JSON array.
1194jsonArrayLength
1194jsonArrayLength
1195− :: Expression schema relations grouping params (nullity 'PGjson)
1195+ :: Expression schema from grouping params (nullity 'PGjson)
1196− -> Expression schema relations grouping params (nullity 'PGint4)
1196+ -> Expression schema from grouping params (nullity 'PGint4)
1197jsonArrayLength = unsafeFunction "json_array_length"
1197jsonArrayLength = unsafeFunction "json_array_length"
1198
1198
1199-- | Returns the number of elements in the outermost binary JSON array.
1199-- | Returns the number of elements in the outermost binary JSON array.
1200jsonbArrayLength
1200jsonbArrayLength
1201− :: Expression schema relations grouping params (nullity 'PGjsonb)
1201+ :: Expression schema from grouping params (nullity 'PGjsonb)
1202− -> Expression schema relations grouping params (nullity 'PGint4)
1202+ -> Expression schema from grouping params (nullity 'PGint4)
1203jsonbArrayLength = unsafeFunction "jsonb_array_length"
1203jsonbArrayLength = unsafeFunction "jsonb_array_length"
1204
1204
1205-- | Returns JSON value pointed to by the given path (equivalent to #>
1205-- | Returns JSON value pointed to by the given path (equivalent to #>
1206-- operator).
1206-- operator).
1207jsonExtractPath
1207jsonExtractPath
1208 :: SListI elems
1208 :: SListI elems
1209− => Expression schema relations grouping params (nullity 'PGjson)
1209+ => Expression schema from grouping params (nullity 'PGjson)
1210− -> NP (Expression schema relations grouping params) elems
1210+ -> NP (Expression schema from grouping params) elems
1211− -> Expression schema relations grouping params (nullity 'PGjsonb)
1211+ -> Expression schema from grouping params (nullity 'PGjsonb)
1212jsonExtractPath x xs =
1212jsonExtractPath x xs =
1213 unsafeVariadicFunction "json_extract_path" (x :* xs)
1213 unsafeVariadicFunction "json_extract_path" (x :* xs)
1214
1214
@@ -1216,9 +1216,9 @@ jsonExtractPath x xs =
1216-- operator).
1216-- operator).
1217jsonbExtractPath
1217jsonbExtractPath
1218 :: SListI elems
1218 :: SListI elems
1219− => Expression schema relations grouping params (nullity 'PGjsonb)
1219+ => Expression schema from grouping params (nullity 'PGjsonb)
1220− -> NP (Expression schema relations grouping params) elems
1220+ -> NP (Expression schema from grouping params) elems
1221− -> Expression schema relations grouping params (nullity 'PGjsonb)
1221+ -> Expression schema from grouping params (nullity 'PGjsonb)
1222jsonbExtractPath x xs =
1222jsonbExtractPath x xs =
1223 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1223 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1224
1224
@@ -1226,9 +1226,9 @@ jsonbExtractPath x xs =
1226-- operator), as text.
1226-- operator), as text.
1227jsonExtractPathAsText
1227jsonExtractPathAsText
1228 :: SListI elems
1228 :: SListI elems
1229− => Expression schema relations grouping params (nullity 'PGjson)
1229+ => Expression schema from grouping params (nullity 'PGjson)
1230− -> NP (Expression schema relations grouping params) elems
1230+ -> NP (Expression schema from grouping params) elems
1231− -> Expression schema relations grouping params (nullity 'PGjson)
1231+ -> Expression schema from grouping params (nullity 'PGjson)
1232jsonExtractPathAsText x xs =
1232jsonExtractPathAsText x xs =
1233 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1233 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1234
1234
@@ -1236,50 +1236,50 @@ jsonExtractPathAsText x xs =
1236-- operator), as text.
1236-- operator), as text.
1237jsonbExtractPathAsText
1237jsonbExtractPathAsText
1238 :: SListI elems
1238 :: SListI elems
1239− => Expression schema relations grouping params (nullity 'PGjsonb)
1239+ => Expression schema from grouping params (nullity 'PGjsonb)
1240− -> NP (Expression schema relations grouping params) elems
1240+ -> NP (Expression schema from grouping params) elems
1241− -> Expression schema relations grouping params (nullity 'PGjsonb)
1241+ -> Expression schema from grouping params (nullity 'PGjsonb)
1242jsonbExtractPathAsText x xs =
1242jsonbExtractPathAsText x xs =
1243 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1243 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1244
1244
1245-- | Returns set of keys in the outermost JSON object.
1245-- | Returns set of keys in the outermost JSON object.
1246jsonObjectKeys
1246jsonObjectKeys
1247− :: Expression schema relations grouping params (nullity 'PGjson)
1247+ :: Expression schema from grouping params (nullity 'PGjson)
1248− -> Expression schema relations grouping params (nullity 'PGtext)
1248+ -> Expression schema from grouping params (nullity 'PGtext)
1249jsonObjectKeys = unsafeFunction "json_object_keys"
1249jsonObjectKeys = unsafeFunction "json_object_keys"
1250
1250
1251-- | Returns set of keys in the outermost JSON object.
1251-- | Returns set of keys in the outermost JSON object.
1252jsonbObjectKeys
1252jsonbObjectKeys
1253− :: Expression schema relations grouping params (nullity 'PGjsonb)
1253+ :: Expression schema from grouping params (nullity 'PGjsonb)
1254− -> Expression schema relations grouping params (nullity 'PGtext)
1254+ -> Expression schema from grouping params (nullity 'PGtext)
1255jsonbObjectKeys = unsafeFunction "jsonb_object_keys"
1255jsonbObjectKeys = unsafeFunction "jsonb_object_keys"
1256
1256
1257-- | Returns the type of the outermost JSON value as a text string. Possible
1257-- | Returns the type of the outermost JSON value as a text string. Possible
1258-- types are object, array, string, number, boolean, and null.
1258-- types are object, array, string, number, boolean, and null.
1259jsonTypeof
1259jsonTypeof
1260− :: Expression schema relations grouping params (nullity 'PGjson)
1260+ :: Expression schema from grouping params (nullity 'PGjson)
1261− -> Expression schema relations grouping params (nullity 'PGtext)
1261+ -> Expression schema from grouping params (nullity 'PGtext)
1262jsonTypeof = unsafeFunction "json_typeof"
1262jsonTypeof = unsafeFunction "json_typeof"
1263
1263
1264-- | Returns the type of the outermost binary JSON value as a text string.
1264-- | Returns the type of the outermost binary JSON value as a text string.
1265-- Possible types are object, array, string, number, boolean, and null.
1265-- Possible types are object, array, string, number, boolean, and null.
1266jsonbTypeof
1266jsonbTypeof
1267− :: Expression schema relations grouping params (nullity 'PGjsonb)
1267+ :: Expression schema from grouping params (nullity 'PGjsonb)
1268− -> Expression schema relations grouping params (nullity 'PGtext)
1268+ -> Expression schema from grouping params (nullity 'PGtext)
1269jsonbTypeof = unsafeFunction "jsonb_typeof"
1269jsonbTypeof = unsafeFunction "jsonb_typeof"
1270
1270
1271-- | Returns its argument with all object fields that have null values omitted.
1271-- | Returns its argument with all object fields that have null values omitted.
1272-- Other null values are untouched.
1272-- Other null values are untouched.
1273jsonStripNulls
1273jsonStripNulls
1274− :: Expression schema relations grouping params (nullity 'PGjson)
1274+ :: Expression schema from grouping params (nullity 'PGjson)
1275− -> Expression schema relations grouping params (nullity 'PGjson)
1275+ -> Expression schema from grouping params (nullity 'PGjson)
1276jsonStripNulls = unsafeFunction "json_strip_nulls"
1276jsonStripNulls = unsafeFunction "json_strip_nulls"
1277
1277
1278-- | Returns its argument with all object fields that have null values omitted.
1278-- | Returns its argument with all object fields that have null values omitted.
1279-- Other null values are untouched.
1279-- Other null values are untouched.
1280jsonbStripNulls
1280jsonbStripNulls
1281− :: Expression schema relations grouping params (nullity 'PGjsonb)
1281+ :: Expression schema from grouping params (nullity 'PGjsonb)
1282− -> Expression schema relations grouping params (nullity 'PGjsonb)
1282+ -> Expression schema from grouping params (nullity 'PGjsonb)
1283jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1283jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1284
1284
1285-- | @ jsonbSet target path new_value create_missing @
1285-- | @ jsonbSet target path new_value create_missing @
@@ -1291,11 +1291,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1291-- arrays.
1291-- arrays.
1292jsonbSet
1292jsonbSet
1293 :: PGtextArray "jsonbSet" arr
1293 :: PGtextArray "jsonbSet" arr
1294− => Expression schema relations grouping params (nullity 'PGjsonb)
1294+ => Expression schema from grouping params (nullity 'PGjsonb)
1295− -> Expression schema relations grouping params (nullity arr)
1295+ -> Expression schema from grouping params (nullity arr)
1296− -> Expression schema relations grouping params (nullity 'PGjsonb)
1296+ -> Expression schema from grouping params (nullity 'PGjsonb)
1297− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1297+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1298− -> Expression schema relations grouping params (nullity 'PGjsonb)
1298+ -> Expression schema from grouping params (nullity 'PGjsonb)
1299jsonbSet tgt path val createMissing = case createMissing of
1299jsonbSet tgt path val createMissing = case createMissing of
1300 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1300 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1301 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1301 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1310,19 +1310,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1310-- in path count from the end of JSON arrays.
1310-- in path count from the end of JSON arrays.
1311jsonbInsert
1311jsonbInsert
1312 :: PGtextArray "jsonbInsert" arr
1312 :: PGtextArray "jsonbInsert" arr
1313− => Expression schema relations grouping params (nullity 'PGjsonb)
1313+ => Expression schema from grouping params (nullity 'PGjsonb)
1314− -> Expression schema relations grouping params (nullity arr)
1314+ -> Expression schema from grouping params (nullity arr)
1315− -> Expression schema relations grouping params (nullity 'PGjsonb)
1315+ -> Expression schema from grouping params (nullity 'PGjsonb)
1316− -> Maybe (Expression schema relations grouping params (nullity 'PGbool))
1316+ -> Maybe (Expression schema from grouping params (nullity 'PGbool))
1317− -> Expression schema relations grouping params (nullity 'PGjsonb)
1317+ -> Expression schema from grouping params (nullity 'PGjsonb)
1318jsonbInsert tgt path val insertAfter = case insertAfter of
1318jsonbInsert tgt path val insertAfter = case insertAfter of
1319 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1319 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1320 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1320 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1321
1321
1322-- | Returns its argument as indented JSON text.
1322-- | Returns its argument as indented JSON text.
1323jsonbPretty
1323jsonbPretty
1324− :: Expression schema relations grouping params (nullity 'PGjsonb)
1324+ :: Expression schema from grouping params (nullity 'PGjsonb)
1325− -> Expression schema relations grouping params (nullity 'PGtext)
1325+ -> Expression schema from grouping params (nullity 'PGtext)
1326jsonbPretty = unsafeFunction "jsonb_pretty"
1326jsonbPretty = unsafeFunction "jsonb_pretty"
1327
1327
1328{-----------------------------------------
1328{-----------------------------------------
@@ -1332,16 +1332,16 @@ aggregation
1332-- | escape hatch to define aggregate functions
1332-- | escape hatch to define aggregate functions
1333unsafeAggregate
1333unsafeAggregate
1334 :: ByteString -- ^ aggregate function
1334 :: ByteString -- ^ aggregate function
1335− -> Expression schema relations 'Ungrouped params (xty)
1335+ -> Expression schema from 'Ungrouped params (xty)
1336− -> Expression schema relations ('Grouped bys) params (yty)
1336+ -> Expression schema from ('Grouped bys) params (yty)
1337unsafeAggregate fun x = UnsafeExpression $ mconcat
1337unsafeAggregate fun x = UnsafeExpression $ mconcat
1338 [fun, "(", renderExpression x, ")"]
1338 [fun, "(", renderExpression x, ")"]
1339
1339
1340-- | escape hatch to define aggregate functions over distinct values
1340-- | escape hatch to define aggregate functions over distinct values
1341unsafeAggregateDistinct
1341unsafeAggregateDistinct
1342 :: ByteString -- ^ aggregate function
1342 :: ByteString -- ^ aggregate function
1343− -> Expression schema relations 'Ungrouped params (xty)
1343+ -> Expression schema from 'Ungrouped params (xty)
1344− -> Expression schema relations ('Grouped bys) params (yty)
1344+ -> Expression schema from ('Grouped bys) params (yty)
1345unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1345unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1346 [fun, "(DISTINCT ", renderExpression x, ")"]
1346 [fun, "(DISTINCT ", renderExpression x, ")"]
1347
1347
@@ -1354,9 +1354,9 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1354-- sum("col")
1354-- sum("col")
1355sum_
1355sum_
1356 :: PGNum ty
1356 :: PGNum ty
1357− => Expression schema relations 'Ungrouped params (nullity ty)
1357+ => Expression schema from 'Ungrouped params (nullity ty)
1358 -- ^ what to sum
1358 -- ^ what to sum
1359− -> Expression schema relations ('Grouped bys) params (nullity ty)
1359+ -> Expression schema from ('Grouped bys) params (nullity ty)
1360sum_ = unsafeAggregate "sum"
1360sum_ = unsafeAggregate "sum"
1361
1361
1362-- | >>> :{
1362-- | >>> :{
@@ -1368,18 +1368,18 @@ sum_ = unsafeAggregate "sum"
1368-- sum(DISTINCT "col")
1368-- sum(DISTINCT "col")
1369sumDistinct
1369sumDistinct
1370 :: PGNum ty
1370 :: PGNum ty
1371− => Expression schema relations 'Ungrouped params (nullity ty)
1371+ => Expression schema from 'Ungrouped params (nullity ty)
1372 -- ^ what to sum
1372 -- ^ what to sum
1373− -> Expression schema relations ('Grouped bys) params (nullity ty)
1373+ -> Expression schema from ('Grouped bys) params (nullity ty)
1374sumDistinct = unsafeAggregateDistinct "sum"
1374sumDistinct = unsafeAggregateDistinct "sum"
1375
1375
1376-- | A constraint for `PGType`s that you can take averages of and the resulting
1376-- | A constraint for `PGType`s that you can take averages of and the resulting
1377-- `PGType`.
1377-- `PGType`.
1378class PGAvg ty avg | ty -> avg where
1378class PGAvg ty avg | ty -> avg where
1379 avg, avgDistinct
1379 avg, avgDistinct
1380− :: Expression schema relations 'Ungrouped params (nullity ty)
1380+ :: Expression schema from 'Ungrouped params (nullity ty)
1381 -- ^ what to average
1381 -- ^ what to average
1382− -> Expression schema relations ('Grouped bys) params (nullity avg)
1382+ -> Expression schema from ('Grouped bys) params (nullity avg)
1383 avg = unsafeAggregate "avg"
1383 avg = unsafeAggregate "avg"
1384 avgDistinct = unsafeAggregateDistinct "avg"
1384 avgDistinct = unsafeAggregateDistinct "avg"
1385instance PGAvg 'PGint2 'PGnumeric
1385instance PGAvg 'PGint2 'PGnumeric
@@ -1399,9 +1399,9 @@ instance PGAvg 'PGinterval 'PGinterval
1399-- bit_and("col")
1399-- bit_and("col")
1400bitAnd
1400bitAnd
1401 :: PGIntegral int
1401 :: PGIntegral int
1402− => Expression schema relations 'Ungrouped params (nullity int)
1402+ => Expression schema from 'Ungrouped params (nullity int)
1403 -- ^ what to aggregate
1403 -- ^ what to aggregate
1404− -> Expression schema relations ('Grouped bys) params (nullity int)
1404+ -> Expression schema from ('Grouped bys) params (nullity int)
1405bitAnd = unsafeAggregate "bit_and"
1405bitAnd = unsafeAggregate "bit_and"
1406
1406
1407-- | >>> :{
1407-- | >>> :{
@@ -1413,9 +1413,9 @@ bitAnd = unsafeAggregate "bit_and"
1413-- bit_or("col")
1413-- bit_or("col")
1414bitOr
1414bitOr
1415 :: PGIntegral int
1415 :: PGIntegral int
1416− => Expression schema relations 'Ungrouped params (nullity int)
1416+ => Expression schema from 'Ungrouped params (nullity int)
1417 -- ^ what to aggregate
1417 -- ^ what to aggregate
1418− -> Expression schema relations ('Grouped bys) params (nullity int)
1418+ -> Expression schema from ('Grouped bys) params (nullity int)
1419bitOr = unsafeAggregate "bit_or"
1419bitOr = unsafeAggregate "bit_or"
1420
1420
1421-- | >>> :{
1421-- | >>> :{
@@ -1427,9 +1427,9 @@ bitOr = unsafeAggregate "bit_or"
1427-- bit_and(DISTINCT "col")
1427-- bit_and(DISTINCT "col")
1428bitAndDistinct
1428bitAndDistinct
1429 :: PGIntegral int
1429 :: PGIntegral int
1430− => Expression schema relations 'Ungrouped params (nullity int)
1430+ => Expression schema from 'Ungrouped params (nullity int)
1431 -- ^ what to aggregate
1431 -- ^ what to aggregate
1432− -> Expression schema relations ('Grouped bys) params (nullity int)
1432+ -> Expression schema from ('Grouped bys) params (nullity int)
1433bitAndDistinct = unsafeAggregateDistinct "bit_and"
1433bitAndDistinct = unsafeAggregateDistinct "bit_and"
1434
1434
1435-- | >>> :{
1435-- | >>> :{
@@ -1441,9 +1441,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
1441-- bit_or(DISTINCT "col")
1441-- bit_or(DISTINCT "col")
1442bitOrDistinct
1442bitOrDistinct
1443 :: PGIntegral int
1443 :: PGIntegral int
1444− => Expression schema relations 'Ungrouped params (nullity int)
1444+ => Expression schema from 'Ungrouped params (nullity int)
1445 -- ^ what to aggregate
1445 -- ^ what to aggregate
1446− -> Expression schema relations ('Grouped bys) params (nullity int)
1446+ -> Expression schema from ('Grouped bys) params (nullity int)
1447bitOrDistinct = unsafeAggregateDistinct "bit_or"
1447bitOrDistinct = unsafeAggregateDistinct "bit_or"
1448
1448
1449-- | >>> :{
1449-- | >>> :{
@@ -1454,9 +1454,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
1454-- :}
1454-- :}
1455-- bool_and("col")
1455-- bool_and("col")
1456boolAnd
1456boolAnd
1457− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1457+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1458 -- ^ what to aggregate
1458 -- ^ what to aggregate
1459− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1459+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1460boolAnd = unsafeAggregate "bool_and"
1460boolAnd = unsafeAggregate "bool_and"
1461
1461
1462-- | >>> :{
1462-- | >>> :{
@@ -1467,9 +1467,9 @@ boolAnd = unsafeAggregate "bool_and"
1467-- :}
1467-- :}
1468-- bool_or("col")
1468-- bool_or("col")
1469boolOr
1469boolOr
1470− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1470+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1471 -- ^ what to aggregate
1471 -- ^ what to aggregate
1472− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1472+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1473boolOr = unsafeAggregate "bool_or"
1473boolOr = unsafeAggregate "bool_or"
1474
1474
1475-- | >>> :{
1475-- | >>> :{
@@ -1480,9 +1480,9 @@ boolOr = unsafeAggregate "bool_or"
1480-- :}
1480-- :}
1481-- bool_and(DISTINCT "col")
1481-- bool_and(DISTINCT "col")
1482boolAndDistinct
1482boolAndDistinct
1483− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1483+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1484 -- ^ what to aggregate
1484 -- ^ what to aggregate
1485− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1485+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1486boolAndDistinct = unsafeAggregateDistinct "bool_and"
1486boolAndDistinct = unsafeAggregateDistinct "bool_and"
1487
1487
1488-- | >>> :{
1488-- | >>> :{
@@ -1493,9 +1493,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
1493-- :}
1493-- :}
1494-- bool_or(DISTINCT "col")
1494-- bool_or(DISTINCT "col")
1495boolOrDistinct
1495boolOrDistinct
1496− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1496+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1497 -- ^ what to aggregate
1497 -- ^ what to aggregate
1498− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1498+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1499boolOrDistinct = unsafeAggregateDistinct "bool_or"
1499boolOrDistinct = unsafeAggregateDistinct "bool_or"
1500
1500
1501-- | A special aggregation that does not require an input
1501-- | A special aggregation that does not require an input
@@ -1503,7 +1503,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1503-- >>> printSQL countStar
1503-- >>> printSQL countStar
1504-- count(*)
1504-- count(*)
1505countStar
1505countStar
1506− :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1506+ :: Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1507countStar = UnsafeExpression $ "count(*)"
1507countStar = UnsafeExpression $ "count(*)"
1508
1508
1509-- | >>> :{
1509-- | >>> :{
@@ -1514,9 +1514,9 @@ countStar = UnsafeExpression $ "count(*)"
1514-- :}
1514-- :}
1515-- count("col")
1515-- count("col")
1516count
1516count
1517− :: Expression schema relations 'Ungrouped params ty
1517+ :: Expression schema from 'Ungrouped params ty
1518 -- ^ what to count
1518 -- ^ what to count
1519− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1519+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1520count = unsafeAggregate "count"
1520count = unsafeAggregate "count"
1521
1521
1522-- | >>> :{
1522-- | >>> :{
@@ -1527,9 +1527,9 @@ count = unsafeAggregate "count"
1527-- :}
1527-- :}
1528-- count(DISTINCT "col")
1528-- count(DISTINCT "col")
1529countDistinct
1529countDistinct
1530− :: Expression schema relations 'Ungrouped params ty
1530+ :: Expression schema from 'Ungrouped params ty
1531 -- ^ what to count
1531 -- ^ what to count
1532− -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1532+ -> Expression schema from ('Grouped bys) params ('NotNull 'PGint8)
1533countDistinct = unsafeAggregateDistinct "count"
1533countDistinct = unsafeAggregateDistinct "count"
1534
1534
1535-- | synonym for `boolAnd`
1535-- | synonym for `boolAnd`
@@ -1542,9 +1542,9 @@ countDistinct = unsafeAggregateDistinct "count"
1542-- :}
1542-- :}
1543-- every("col")
1543-- every("col")
1544every
1544every
1545− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1545+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1546 -- ^ what to aggregate
1546 -- ^ what to aggregate
1547− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1547+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1548every = unsafeAggregate "every"
1548every = unsafeAggregate "every"
1549
1549
1550-- | synonym for `boolAndDistinct`
1550-- | synonym for `boolAndDistinct`
@@ -1557,16 +1557,16 @@ every = unsafeAggregate "every"
1557-- :}
1557-- :}
1558-- every(DISTINCT "col")
1558-- every(DISTINCT "col")
1559everyDistinct
1559everyDistinct
1560− :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1560+ :: Expression schema from 'Ungrouped params (nullity 'PGbool)
1561 -- ^ what to aggregate
1561 -- ^ what to aggregate
1562− -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1562+ -> Expression schema from ('Grouped bys) params (nullity 'PGbool)
1563everyDistinct = unsafeAggregateDistinct "every"
1563everyDistinct = unsafeAggregateDistinct "every"
1564
1564
1565-- | minimum and maximum aggregation
1565-- | minimum and maximum aggregation
1566max_, min_, maxDistinct, minDistinct
1566max_, min_, maxDistinct, minDistinct
1567− :: Expression schema relations 'Ungrouped params (nullity ty)
1567+ :: Expression schema from 'Ungrouped params (nullity ty)
1568 -- ^ what to aggregate
1568 -- ^ what to aggregate
1569− -> Expression schema relations ('Grouped bys) params (nullity ty)
1569+ -> Expression schema from ('Grouped bys) params (nullity ty)
1570max_ = unsafeAggregate "max"
1570max_ = unsafeAggregate "max"
1571min_ = unsafeAggregate "min"
1571min_ = unsafeAggregate "min"
1572maxDistinct = unsafeAggregateDistinct "max"
1572maxDistinct = unsafeAggregateDistinct "max"
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+3−3
@@ -184,7 +184,7 @@ DELETE FROM "tab" WHERE ("col1" = "col2") RETURNING *
184newtype Manipulation
184newtype Manipulation
185 (schema :: SchemaType)
185 (schema :: SchemaType)
186 (params :: [NullityType])
186 (params :: [NullityType])
187− (columns :: RelationType)
187+ (columns :: RowType)
188 = UnsafeManipulation { renderManipulation :: ByteString }
188 = UnsafeManipulation { renderManipulation :: ByteString }
189 deriving (GHC.Generic,Show,Eq,Ord,NFData)
189 deriving (GHC.Generic,Show,Eq,Ord,NFData)
190
190
@@ -309,7 +309,7 @@ insertQuery_ tab query =
309-- existing value in the row for an update.
309-- existing value in the row for an update.
310data ColumnValue
310data ColumnValue
311 (schema :: SchemaType)
311 (schema :: SchemaType)
312− (columns :: RelationType)
312+ (columns :: RowType)
313 (params :: [NullityType])
313 (params :: [NullityType])
314 (ty :: ColumnType)
314 (ty :: ColumnType)
315 where
315 where
@@ -333,7 +333,7 @@ data ReturningClause
333 (schema :: SchemaType)
333 (schema :: SchemaType)
334 (columns :: ColumnsType)
334 (columns :: ColumnsType)
335 (params :: [NullityType])
335 (params :: [NullityType])
336− (results :: RelationType)
336+ (results :: RowType)
337 where
337 where
338 ReturningStar
338 ReturningStar
339 :: results ~ ColumnsToRelation columns
339 :: results ~ ColumnsToRelation columns
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+84−84
@@ -328,7 +328,7 @@ in printSQL query
328newtype Query
328newtype Query
329 (schema :: SchemaType)
329 (schema :: SchemaType)
330 (params :: [NullityType])
330 (params :: [NullityType])
331− (columns :: RelationType)
331+ (columns :: RowType)
332 = UnsafeQuery { renderQuery :: ByteString }
332 = UnsafeQuery { renderQuery :: ByteString }
333 deriving (GHC.Generic,Show,Eq,Ord,NFData)
333 deriving (GHC.Generic,Show,Eq,Ord,NFData)
334instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
334instance RenderSQL (Query schema params columns) where renderSQL = renderQuery
@@ -410,9 +410,9 @@ SELECT queries
410-- the intermediate table are actually output.
410-- the intermediate table are actually output.
411select
411select
412 :: SListI columns
412 :: SListI columns
413− => NP (Aliased (Expression schema relations grouping params)) (column ': columns)
413+ => NP (Aliased (Expression schema from grouping params)) (column ': columns)
414 -- ^ select list
414 -- ^ select list
415− -> TableExpression schema params relations grouping
415+ -> TableExpression schema params from grouping
416 -- ^ intermediate virtual table
416 -- ^ intermediate virtual table
417 -> Query schema params (column ': columns)
417 -> Query schema params (column ': columns)
418select list rels = UnsafeQuery $
418select list rels = UnsafeQuery $
@@ -424,9 +424,9 @@ select list rels = UnsafeQuery $
424-- be subject to the elimination of duplicate rows using `selectDistinct`.
424-- be subject to the elimination of duplicate rows using `selectDistinct`.
425selectDistinct
425selectDistinct
426 :: SListI columns
426 :: SListI columns
427− => NP (Aliased (Expression schema relations 'Ungrouped params)) (column ': columns)
427+ => NP (Aliased (Expression schema from 'Ungrouped params)) (column ': columns)
428 -- ^ select list
428 -- ^ select list
429− -> TableExpression schema params relations 'Ungrouped
429+ -> TableExpression schema params from 'Ungrouped
430 -- ^ intermediate virtual table
430 -- ^ intermediate virtual table
431 -> Query schema params (column ': columns)
431 -> Query schema params (column ': columns)
432selectDistinct list rels = UnsafeQuery $
432selectDistinct list rels = UnsafeQuery $
@@ -437,8 +437,8 @@ selectDistinct list rels = UnsafeQuery $
437-- | The simplest kind of query is `selectStar` which emits all columns
437-- | The simplest kind of query is `selectStar` which emits all columns
438-- that the table expression produces.
438-- that the table expression produces.
439selectStar
439selectStar
440− :: HasUnique relation relations columns
440+ :: HasUnique relation from columns
441− => TableExpression schema params relations 'Ungrouped
441+ => TableExpression schema params from 'Ungrouped
442 -- ^ intermediate virtual table
442 -- ^ intermediate virtual table
443 -> Query schema params columns
443 -> Query schema params columns
444selectStar rels = UnsafeQuery $ "SELECT" <+> "*" <+> renderTableExpression rels
444selectStar rels = UnsafeQuery $ "SELECT" <+> "*" <+> renderTableExpression rels
@@ -446,8 +446,8 @@ selectStar rels = UnsafeQuery $ "SELECT" <+> "*" <+> renderTableExpression rels
446-- | A `selectDistinctStar` emits all columns that the table expression
446-- | A `selectDistinctStar` emits all columns that the table expression
447-- produces and eliminates duplicate rows.
447-- produces and eliminates duplicate rows.
448selectDistinctStar
448selectDistinctStar
449− :: HasUnique relation relations columns
449+ :: HasUnique relation from columns
450− => TableExpression schema params relations 'Ungrouped
450+ => TableExpression schema params from 'Ungrouped
451 -- ^ intermediate virtual table
451 -- ^ intermediate virtual table
452 -> Query schema params columns
452 -> Query schema params columns
453selectDistinctStar rels = UnsafeQuery $
453selectDistinctStar rels = UnsafeQuery $
@@ -456,27 +456,27 @@ selectDistinctStar rels = UnsafeQuery $
456-- | When working with multiple tables, it can also be useful to ask
456-- | When working with multiple tables, it can also be useful to ask
457-- for all the columns of a particular table, using `selectDotStar`.
457-- for all the columns of a particular table, using `selectDotStar`.
458selectDotStar
458selectDotStar
459− :: Has relation relations columns
459+ :: Has relation from columns
460 => Alias relation
460 => Alias relation
461 -- ^ particular virtual subtable
461 -- ^ particular virtual subtable
462− -> TableExpression schema params relations 'Ungrouped
462+ -> TableExpression schema params from 'Ungrouped
463 -- ^ intermediate virtual table
463 -- ^ intermediate virtual table
464 -> Query schema params columns
464 -> Query schema params columns
465−selectDotStar rel relations = UnsafeQuery $
465+selectDotStar rel tab = UnsafeQuery $
466− "SELECT" <+> renderAlias rel <> ".*" <+> renderTableExpression relations
466+ "SELECT" <+> renderAlias rel <> ".*" <+> renderTableExpression tab
467
467
468-- | A `selectDistinctDotStar` asks for all the columns of a particular table,
468-- | A `selectDistinctDotStar` asks for all the columns of a particular table,
469-- and eliminates duplicate rows.
469-- and eliminates duplicate rows.
470selectDistinctDotStar
470selectDistinctDotStar
471− :: Has relation relations columns
471+ :: Has relation from columns
472 => Alias relation
472 => Alias relation
473 -- ^ particular virtual table
473 -- ^ particular virtual table
474− -> TableExpression schema params relations 'Ungrouped
474+ -> TableExpression schema params from 'Ungrouped
475 -- ^ intermediate virtual table
475 -- ^ intermediate virtual table
476 -> Query schema params columns
476 -> Query schema params columns
477−selectDistinctDotStar rel relations = UnsafeQuery $
477+selectDistinctDotStar rel tab = UnsafeQuery $
478 "SELECT DISTINCT" <+> renderAlias rel <> ".*"
478 "SELECT DISTINCT" <+> renderAlias rel <> ".*"
479− <+> renderTableExpression relations
479+ <+> renderTableExpression tab
480
480
481-- | `values` computes a row value or set of row values
481-- | `values` computes a row value or set of row values
482-- specified by value expressions. It is most commonly used
482-- specified by value expressions. It is most commonly used
@@ -530,13 +530,13 @@ Table Expressions
530data TableExpression
530data TableExpression
531 (schema :: SchemaType)
531 (schema :: SchemaType)
532 (params :: [NullityType])
532 (params :: [NullityType])
533− (relations :: RelationsType)
533+ (from :: FromType)
534 (grouping :: Grouping)
534 (grouping :: Grouping)
535 = TableExpression
535 = TableExpression
536− { fromClause :: FromClause schema params relations
536+ { fromClause :: FromClause schema params from
537 -- ^ A table reference that can be a table name, or a derived table such
537 -- ^ A table reference that can be a table name, or a derived table such
538 -- as a subquery, a @JOIN@ construct, or complex combinations of these.
538 -- 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]
540 -- ^ optional search coditions, combined with `.&&`. After the processing
540 -- ^ optional search coditions, combined with `.&&`. After the processing
541 -- of the `fromClause` is done, each row of the derived virtual table
541 -- of the `fromClause` is done, each row of the derived virtual table
542 -- is checked against the search condition. If the result of the
542 -- is checked against the search condition. If the result of the
@@ -545,20 +545,20 @@ data TableExpression
545 -- at least one column of the table generated in the `fromClause`;
545 -- at least one column of the table generated in the `fromClause`;
546 -- this is not required, but otherwise the WHERE clause will
546 -- this is not required, but otherwise the WHERE clause will
547 -- be fairly useless.
547 -- be fairly useless.
548− , groupByClause :: GroupByClause relations grouping
548+ , groupByClause :: GroupByClause from grouping
549 -- ^ The `groupByClause` is used to group together those rows in a table
549 -- ^ The `groupByClause` is used to group together those rows in a table
550 -- that have the same values in all the columns listed. The order in which
550 -- that have the same values in all the columns listed. The order in which
551 -- the columns are listed does not matter. The effect is to combine each
551 -- the columns are listed does not matter. The effect is to combine each
552 -- set of rows having common values into one group row that represents all
552 -- set of rows having common values into one group row that represents all
553 -- rows in the group. This is done to eliminate redundancy in the output
553 -- rows in the group. This is done to eliminate redundancy in the output
554 -- and/or compute aggregates that apply to these groups.
554 -- and/or compute aggregates that apply to these groups.
555− , havingClause :: HavingClause schema relations grouping params
555+ , havingClause :: HavingClause schema from grouping params
556 -- ^ If a table has been grouped using `groupBy`, but only certain groups
556 -- ^ If a table has been grouped using `groupBy`, but only certain groups
557 -- are of interest, the `havingClause` can be used, much like a
557 -- are of interest, the `havingClause` can be used, much like a
558 -- `whereClause`, to eliminate groups from the result. Expressions in the
558 -- `whereClause`, to eliminate groups from the result. Expressions in the
559 -- `havingClause` can refer both to grouped expressions and to ungrouped
559 -- `havingClause` can refer both to grouped expressions and to ungrouped
560 -- expressions (which necessarily involve an aggregate function).
560 -- expressions (which necessarily involve an aggregate function).
561− , orderByClause :: [SortExpression schema relations grouping params]
561+ , orderByClause :: [SortExpression schema from grouping params]
562 -- ^ The `orderByClause` is for optional sorting. When more than one
562 -- ^ The `orderByClause` is for optional sorting. When more than one
563 -- `SortExpression` is specified, the later (right) values are used to sort
563 -- `SortExpression` is specified, the later (right) values are used to sort
564 -- rows that are equal according to the earlier (left) values.
564 -- rows that are equal according to the earlier (left) values.
@@ -576,7 +576,7 @@ data TableExpression
576
576
577-- | Render a `TableExpression`
577-- | Render a `TableExpression`
578renderTableExpression
578renderTableExpression
579− :: TableExpression schema params relations grouping
579+ :: TableExpression schema params from grouping
580 -> ByteString
580 -> ByteString
581renderTableExpression
581renderTableExpression
582 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
582 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
@@ -610,16 +610,16 @@ renderTableExpression
610-- `group`, `having`, `orderBy`, `limit` and `offset`, using the `&` operator
610-- `group`, `having`, `orderBy`, `limit` and `offset`, using the `&` operator
611-- to match the left-to-right sequencing of their placement in SQL.
611-- to match the left-to-right sequencing of their placement in SQL.
612from
612from
613− :: FromClause schema params relations -- ^ table reference
613+ :: FromClause schema params from -- ^ table reference
614− -> TableExpression schema params relations 'Ungrouped
614+ -> TableExpression schema params from 'Ungrouped
615from rels = TableExpression rels [] NoGroups NoHaving [] [] []
615from rels = TableExpression rels [] NoGroups NoHaving [] [] []
616
616
617-- | A `where_` is an endomorphism of `TableExpression`s which adds a
617-- | A `where_` is an endomorphism of `TableExpression`s which adds a
618-- search condition to the `whereClause`.
618-- search condition to the `whereClause`.
619where_
619where_
620− :: Condition schema relations 'Ungrouped params -- ^ filtering condition
620+ :: Condition schema from 'Ungrouped params -- ^ filtering condition
621− -> TableExpression schema params relations grouping
621+ -> TableExpression schema params from grouping
622− -> TableExpression schema params relations grouping
622+ -> TableExpression schema params from grouping
623where_ wh rels = rels {whereClause = wh : whereClause rels}
623where_ wh rels = rels {whereClause = wh : whereClause rels}
624
624
625-- | A `groupBy` is a transformation of `TableExpression`s which switches
625-- | A `groupBy` is a transformation of `TableExpression`s which switches
@@ -627,9 +627,9 @@ where_ wh rels = rels {whereClause = wh : whereClause rels}
627-- a "grand total" aggregation query.
627-- a "grand total" aggregation query.
628groupBy
628groupBy
629 :: SListI bys
629 :: SListI bys
630− => NP (By relations) bys -- ^ grouped columns
630+ => NP (By from) bys -- ^ grouped columns
631− -> TableExpression schema params relations 'Ungrouped
631+ -> TableExpression schema params from 'Ungrouped
632− -> TableExpression schema params relations ('Grouped bys)
632+ -> TableExpression schema params from ('Grouped bys)
633groupBy bys rels = TableExpression
633groupBy bys rels = TableExpression
634 { fromClause = fromClause rels
634 { fromClause = fromClause rels
635 , whereClause = whereClause rels
635 , whereClause = whereClause rels
@@ -643,34 +643,34 @@ groupBy bys rels = TableExpression
643-- | A `having` is an endomorphism of `TableExpression`s which adds a
643-- | A `having` is an endomorphism of `TableExpression`s which adds a
644-- search condition to the `havingClause`.
644-- search condition to the `havingClause`.
645having
645having
646− :: Condition schema relations ('Grouped bys) params -- ^ having condition
646+ :: Condition schema from ('Grouped bys) params -- ^ having condition
647− -> TableExpression schema params relations ('Grouped bys)
647+ -> TableExpression schema params from ('Grouped bys)
648− -> TableExpression schema params relations ('Grouped bys)
648+ -> TableExpression schema params from ('Grouped bys)
649having hv rels = rels
649having hv rels = rels
650 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
650 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
651
651
652-- | An `orderBy` is an endomorphism of `TableExpression`s which appends an
652-- | An `orderBy` is an endomorphism of `TableExpression`s which appends an
653-- ordering to the right of the `orderByClause`.
653-- ordering to the right of the `orderByClause`.
654orderBy
654orderBy
655− :: [SortExpression schema relations grouping params] -- ^ sort expressions
655+ :: [SortExpression schema from grouping params] -- ^ sort expressions
656− -> TableExpression schema params relations grouping
656+ -> TableExpression schema params from grouping
657− -> TableExpression schema params relations grouping
657+ -> TableExpression schema params from grouping
658orderBy srts rels = rels {orderByClause = orderByClause rels ++ srts}
658orderBy srts rels = rels {orderByClause = orderByClause rels ++ srts}
659
659
660-- | A `limit` is an endomorphism of `TableExpression`s which adds to the
660-- | A `limit` is an endomorphism of `TableExpression`s which adds to the
661-- `limitClause`.
661-- `limitClause`.
662limit
662limit
663 :: Word64 -- ^ limit parameter
663 :: Word64 -- ^ limit parameter
664− -> TableExpression schema params relations grouping
664+ -> TableExpression schema params from grouping
665− -> TableExpression schema params relations grouping
665+ -> TableExpression schema params from grouping
666limit lim rels = rels {limitClause = lim : limitClause rels}
666limit lim rels = rels {limitClause = lim : limitClause rels}
667
667
668-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
668-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
669-- `offsetClause`.
669-- `offsetClause`.
670offset
670offset
671 :: Word64 -- ^ offset parameter
671 :: Word64 -- ^ offset parameter
672− -> TableExpression schema params relations grouping
672+ -> TableExpression schema params from grouping
673− -> TableExpression schema params relations grouping
673+ -> TableExpression schema params from grouping
674offset off rels = rels {offsetClause = off : offsetClause rels}
674offset off rels = rels {offsetClause = off : offsetClause rels}
675
675
676{-----------------------------------------
676{-----------------------------------------
@@ -690,8 +690,8 @@ type PGjson_each_text tab = PGjson_each_variant 'PGtext tab
690type PGjsonb_each_text tab = PGjson_each_variant 'PGtext tab
690type PGjsonb_each_text tab = PGjson_each_variant 'PGtext tab
691
691
692unsafeAliasedFromClauseExpression
692unsafeAliasedFromClauseExpression
693− :: Aliased (Expression schema' relations' grouping' params') ty'
693+ :: Aliased (Expression schema' from' grouping' params') ty'
694− -> FromClause schema params relations
694+ -> FromClause schema params from
695unsafeAliasedFromClauseExpression aliasedExpr = UnsafeFromClause
695unsafeAliasedFromClauseExpression aliasedExpr = UnsafeFromClause
696 (renderAliasedAs renderExpression aliasedExpr)
696 (renderAliasedAs renderExpression aliasedExpr)
697
697
@@ -726,7 +726,7 @@ jsonbEachAsText (As jexpr jname) = unsafeAliasedFromClauseExpression
726nullRow
726nullRow
727 :: Has tab schema ('Table table)
727 :: Has tab schema ('Table table)
728 => Alias tab
728 => Alias tab
729− -> Expression schema relations grouping params
729+ -> Expression schema from grouping params
730 (nullity ('PGcomposite (TableToRelation table)))
730 (nullity ('PGcomposite (TableToRelation table)))
731nullRow tab = UnsafeExpression ("null::"<+>renderAlias tab)
731nullRow tab = UnsafeExpression ("null::"<+>renderAlias tab)
732
732
@@ -796,7 +796,7 @@ renderTableTypeExpression (hc `As` tab)
796
796
797unsafeTableAliasedFromClauseExpression
797unsafeTableAliasedFromClauseExpression
798 :: All Top types
798 :: All Top types
799− => Expression schema' relations' grouping' params' ty'
799+ => Expression schema' from' grouping' params' ty'
800 -> Aliased (NP (Aliased (TypeExpression schema))) (tab ::: types)
800 -> Aliased (NP (Aliased (TypeExpression schema))) (tab ::: types)
801 -> FromClause schema params '[alias ::: types]
801 -> FromClause schema params '[alias ::: types]
802unsafeTableAliasedFromClauseExpression expr types = UnsafeFromClause
802unsafeTableAliasedFromClauseExpression expr types = UnsafeFromClause
@@ -864,7 +864,7 @@ FROM clauses
864A `FromClause` can be a table name, or a derived table such
864A `FromClause` can be a table name, or a derived table such
865as a subquery, a @JOIN@ construct, or complex combinations of these.
865as a subquery, a @JOIN@ construct, or complex combinations of these.
866-}
866-}
867−newtype FromClause schema params relations
867+newtype FromClause schema params from
868 = UnsafeFromClause { renderFromClause :: ByteString }
868 = UnsafeFromClause { renderFromClause :: ByteString }
869 deriving (GHC.Generic,Show,Eq,Ord,NFData)
869 deriving (GHC.Generic,Show,Eq,Ord,NFData)
870
870
@@ -985,20 +985,20 @@ Grouping
985-- column @col@; otherwise @By2 (\#tab \! \#col)@ will reference a table
985-- column @col@; otherwise @By2 (\#tab \! \#col)@ will reference a table
986-- qualified column @tab.col@.
986-- qualified column @tab.col@.
987data By
987data By
988− (relations :: RelationsType)
988+ (from :: FromType)
989 (by :: (Symbol,Symbol)) where
989 (by :: (Symbol,Symbol)) where
990 By1
990 By1
991− :: (HasUnique relation relations columns, Has column columns ty)
991+ :: (HasUnique relation from columns, Has column columns ty)
992 => Alias column
992 => Alias column
993− -> By relations '(relation, column)
993+ -> By from '(relation, column)
994 By2
994 By2
995− :: (Has relation relations columns, Has column columns ty)
995+ :: (Has relation from columns, Has column columns ty)
996 => Alias relation
996 => Alias relation
997 -> Alias column
997 -> Alias column
998− -> By relations '(relation, column)
998+ -> By from '(relation, column)
999−deriving instance Show (By relations by)
999+deriving instance Show (By from by)
1000−deriving instance Eq (By relations by)
1000+deriving instance Eq (By from by)
1001−deriving instance Ord (By relations by)
1001+deriving instance Ord (By from by)
1002
1002
1003instance (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col))
1003instance (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col))
1004 => IsLabel col (By rels by) where fromLabel = By1 fromLabel
1004 => 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)])
1011 rel ! col = By2 rel col :* Nil
1011 rel ! col = By2 rel col :* Nil
1012
1012
1013-- | Renders a `By`.
1013-- | Renders a `By`.
1014−renderBy :: By relations by -> ByteString
1014+renderBy :: By from by -> ByteString
1015renderBy = \case
1015renderBy = \case
1016 By1 column -> renderAlias column
1016 By1 column -> renderAlias column
1017 By2 rel column -> renderAlias rel <> "." <> renderAlias column
1017 By2 rel column -> renderAlias rel <> "." <> renderAlias column
@@ -1022,15 +1022,15 @@ renderBy = \case
1022-- done on @NoGroups@ while all output `Expression`s must be aggregated
1022-- done on @NoGroups@ while all output `Expression`s must be aggregated
1023-- in @Group Nil@. In general, all output `Expression`s in the
1023-- in @Group Nil@. In general, all output `Expression`s in the
1024-- complement of @bys@ must be aggregated in @Group bys@.
1024-- complement of @bys@ must be aggregated in @Group bys@.
1025−data GroupByClause relations grouping where
1025+data GroupByClause from grouping where
1026− NoGroups :: GroupByClause relations 'Ungrouped
1026+ NoGroups :: GroupByClause from 'Ungrouped
1027 Group
1027 Group
1028 :: SListI bys
1028 :: SListI bys
1029− => NP (By relations) bys
1029+ => NP (By from) bys
1030− -> GroupByClause relations ('Grouped bys)
1030+ -> GroupByClause from ('Grouped bys)
1031
1031
1032-- | Renders a `GroupByClause`.
1032-- | Renders a `GroupByClause`.
1033−renderGroupByClause :: GroupByClause relations grouping -> ByteString
1033+renderGroupByClause :: GroupByClause from grouping -> ByteString
1034renderGroupByClause = \case
1034renderGroupByClause = \case
1035 NoGroups -> ""
1035 NoGroups -> ""
1036 Group Nil -> ""
1036 Group Nil -> ""
@@ -1040,17 +1040,17 @@ renderGroupByClause = \case
1040-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1040-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1041-- `TableExpression` must use `Having` whose conditions are combined with
1041-- `TableExpression` must use `Having` whose conditions are combined with
1042-- `.&&`.
1042-- `.&&`.
1043−data HavingClause schema relations grouping params where
1043+data HavingClause schema from grouping params where
1044− NoHaving :: HavingClause schema relations 'Ungrouped params
1044+ NoHaving :: HavingClause schema from 'Ungrouped params
1045 Having
1045 Having
1046− :: [Condition schema relations ('Grouped bys) params]
1046+ :: [Condition schema from ('Grouped bys) params]
1047− -> HavingClause schema relations ('Grouped bys) params
1047+ -> HavingClause schema from ('Grouped bys) params
1048−deriving instance Show (HavingClause schema relations grouping params)
1048+deriving instance Show (HavingClause schema from grouping params)
1049−deriving instance Eq (HavingClause schema relations grouping params)
1049+deriving instance Eq (HavingClause schema from grouping params)
1050−deriving instance Ord (HavingClause schema relations grouping params)
1050+deriving instance Ord (HavingClause schema from grouping params)
1051
1051
1052-- | Render a `HavingClause`.
1052-- | Render a `HavingClause`.
1053−renderHavingClause :: HavingClause schema relations grouping params -> ByteString
1053+renderHavingClause :: HavingClause schema from grouping params -> ByteString
1054renderHavingClause = \case
1054renderHavingClause = \case
1055 NoHaving -> ""
1055 NoHaving -> ""
1056 Having [] -> ""
1056 Having [] -> ""
@@ -1069,29 +1069,29 @@ Sorting
1069-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
1069-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
1070-- determine whether nulls appear before or after non-null values in the sort
1070-- determine whether nulls appear before or after non-null values in the sort
1071-- ordering of a `Null` result column.
1071-- ordering of a `Null` result column.
1072−data SortExpression schema relations grouping params where
1072+data SortExpression schema from grouping params where
1073 Asc
1073 Asc
1074− :: Expression schema relations grouping params ('NotNull ty)
1074+ :: Expression schema from grouping params ('NotNull ty)
1075− -> SortExpression schema relations grouping params
1075+ -> SortExpression schema from grouping params
1076 Desc
1076 Desc
1077− :: Expression schema relations grouping params ('NotNull ty)
1077+ :: Expression schema from grouping params ('NotNull ty)
1078− -> SortExpression schema relations grouping params
1078+ -> SortExpression schema from grouping params
1079 AscNullsFirst
1079 AscNullsFirst
1080− :: Expression schema relations grouping params ('Null ty)
1080+ :: Expression schema from grouping params ('Null ty)
1081− -> SortExpression schema relations grouping params
1081+ -> SortExpression schema from grouping params
1082 AscNullsLast
1082 AscNullsLast
1083− :: Expression schema relations grouping params ('Null ty)
1083+ :: Expression schema from grouping params ('Null ty)
1084− -> SortExpression schema relations grouping params
1084+ -> SortExpression schema from grouping params
1085 DescNullsFirst
1085 DescNullsFirst
1086− :: Expression schema relations grouping params ('Null ty)
1086+ :: Expression schema from grouping params ('Null ty)
1087− -> SortExpression schema relations grouping params
1087+ -> SortExpression schema from grouping params
1088 DescNullsLast
1088 DescNullsLast
1089− :: Expression schema relations grouping params ('Null ty)
1089+ :: Expression schema from grouping params ('Null ty)
1090− -> SortExpression schema relations grouping params
1090+ -> SortExpression schema from grouping params
1091−deriving instance Show (SortExpression schema relations grouping params)
1091+deriving instance Show (SortExpression schema from grouping params)
1092
1092
1093-- | Render a `SortExpression`.
1093-- | Render a `SortExpression`.
1094−renderSortExpression :: SortExpression schema relations grouping params -> ByteString
1094+renderSortExpression :: SortExpression schema from grouping params -> ByteString
1095renderSortExpression = \case
1095renderSortExpression = \case
1096 Asc expression -> renderExpression expression <+> "ASC"
1096 Asc expression -> renderExpression expression <+> "ASC"
1097 Desc expression -> renderExpression expression <+> "DESC"
1097 Desc expression -> renderExpression expression <+> "DESC"
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+19−19
@@ -40,9 +40,9 @@ module Squeal.PostgreSQL.Schema
40 , ColumnType
40 , ColumnType
41 -- * Tables
41 -- * Tables
42 , ColumnsType
42 , ColumnsType
43− , RelationType
43+ , RowType
44 , NilRelation
44 , NilRelation
45− , RelationsType
45+ , FromType
46 , TableType
46 , TableType
47 -- * Schema
47 -- * Schema
48 , SchemumType (..)
48 , SchemumType (..)
@@ -302,25 +302,25 @@ type family Uniquely
302-- :}
302-- :}
303type TableType = (TableConstraints,ColumnsType)
303type TableType = (TableConstraints,ColumnsType)
304
304
305−-- | `RelationType` is a row of `NullityType`
305+-- | `RowType` is a row of `NullityType`
306--
306--
307-- >>> :{
307-- >>> :{
308−-- type family PersonRelation :: RelationType where
308+-- type family PersonRelation :: RowType where
309-- PersonRelation =
309-- PersonRelation =
310-- '[ "name" ::: 'NotNull 'PGtext
310-- '[ "name" ::: 'NotNull 'PGtext
311-- , "age" ::: 'NotNull 'PGint4
311-- , "age" ::: 'NotNull 'PGint4
312-- , "dateOfBirth" ::: 'Null 'PGdate
312-- , "dateOfBirth" ::: 'Null 'PGdate
313-- ]
313-- ]
314-- :}
314-- :}
315−type RelationType = [(Symbol,NullityType)]
315+type RowType = [(Symbol,NullityType)]
316−-- | A monokinded empty `RelationType`.
316+-- | A monokinded empty `RowType`.
317−type family NilRelation :: RelationType where NilRelation = '[]
317+type family NilRelation :: RowType where NilRelation = '[]
318
318
319−-- | `RelationsType` is a row of `RelationType`s, thought of as a product.
319+-- | `FromType` is a row of `RowType`s, thought of as a product.
320−type RelationsType = [(Symbol,RelationType)]
320+type FromType = [(Symbol,RowType)]
321
321
322-- | `ColumnsToRelation` removes column constraints.
322-- | `ColumnsToRelation` removes column constraints.
323−type family ColumnsToRelation (columns :: ColumnsType) :: RelationType where
323+type family ColumnsToRelation (columns :: ColumnsType) :: RowType where
324 ColumnsToRelation '[] = '[]
324 ColumnsToRelation '[] = '[]
325 ColumnsToRelation (column ::: constraint :=> ty ': columns) =
325 ColumnsToRelation (column ::: constraint :=> ty ': columns) =
326 column ::: ty ': ColumnsToRelation columns
326 column ::: ty ': ColumnsToRelation columns
@@ -330,7 +330,7 @@ type family TableToColumns (table :: TableType) :: ColumnsType where
330 TableToColumns (constraints :=> columns) = columns
330 TableToColumns (constraints :=> columns) = columns
331
331
332-- | Convert a table to a relation.
332-- | Convert a table to a relation.
333−type family TableToRelation (table :: TableType) :: RelationType where
333+type family TableToRelation (table :: TableType) :: RowType where
334 TableToRelation tab = ColumnsToRelation (TableToColumns tab)
334 TableToRelation tab = ColumnsToRelation (TableToColumns tab)
335
335
336-- | `Grouping` is an auxiliary namespace, created by
336-- | `Grouping` is an auxiliary namespace, created by
@@ -568,21 +568,21 @@ type family NullifyType (ty :: NullityType) :: NullityType where
568 NullifyType ('NotNull ty) = 'Null ty
568 NullifyType ('NotNull ty) = 'Null ty
569
569
570-- | `NullifyRelation` is an idempotent that nullifies a `ColumnsType`.
570-- | `NullifyRelation` is an idempotent that nullifies a `ColumnsType`.
571−type family NullifyRelation (columns :: RelationType) :: RelationType where
571+type family NullifyRelation (columns :: RowType) :: RowType where
572 NullifyRelation '[] = '[]
572 NullifyRelation '[] = '[]
573 NullifyRelation (column ::: ty ': columns) =
573 NullifyRelation (column ::: ty ': columns) =
574 column ::: NullifyType ty ': NullifyRelation columns
574 column ::: NullifyType ty ': NullifyRelation columns
575
575
576−-- | `NullifyRelations` is an idempotent that nullifies a `RelationsType`
576+-- | `NullifyRelations` is an idempotent that nullifies a `FromType`
577-- used to nullify the left or right hand side of an outer join
577-- used to nullify the left or right hand side of an outer join
578-- in a `Squeal.PostgreSQL.Query.FromClause`.
578-- in a `Squeal.PostgreSQL.Query.FromClause`.
579−type family NullifyRelations (tables :: RelationsType) :: RelationsType where
579+type family NullifyRelations (tables :: FromType) :: FromType where
580 NullifyRelations '[] = '[]
580 NullifyRelations '[] = '[]
581 NullifyRelations (table ::: columns ': tables) =
581 NullifyRelations (table ::: columns ': tables) =
582 table ::: NullifyRelation columns ': NullifyRelations tables
582 table ::: NullifyRelation columns ': NullifyRelations tables
583
583
584-- | `RelationToNullityTypes` drops the column constraints.
584-- | `RelationToNullityTypes` drops the column constraints.
585−type family RelationToNullityTypes (rel :: RelationType) :: [NullityType] where
585+type family RelationToNullityTypes (rel :: RowType) :: [NullityType] where
586 RelationToNullityTypes ('(k, x) : xs) = x : RelationToNullityTypes xs
586 RelationToNullityTypes ('(k, x) : xs) = x : RelationToNullityTypes xs
587 RelationToNullityTypes '[] = '[]
587 RelationToNullityTypes '[] = '[]
588
588
@@ -648,7 +648,7 @@ type family Length (xs :: [k]) :: Nat where
648-- `View` or `Typedef`.
648-- `View` or `Typedef`.
649data SchemumType
649data SchemumType
650 = Table TableType
650 = Table TableType
651− | View RelationType
651+ | View RowType
652 | Typedef PGType
652 | Typedef PGType
653
653
654-- | The schema of a database consists of a list of aliased,
654-- | The schema of a database consists of a list of aliased,
@@ -657,7 +657,7 @@ type SchemaType = [(Symbol,SchemumType)]
657
657
658-- | Used in `Squeal.Postgresql.Manipulation.with`.
658-- | Used in `Squeal.Postgresql.Manipulation.with`.
659type family With
659type family With
660− (relations :: RelationsType)
660+ (from :: FromType)
661 (schema :: SchemaType)
661 (schema :: SchemaType)
662 :: SchemaType where
662 :: SchemaType where
663 With '[] schema = schema
663 With '[] schema = schema
@@ -758,10 +758,10 @@ type family LabelsFrom (hask :: Type) :: [Type.ConstructorName] where
758type family CompositeFrom (hask :: Type) :: PGType where
758type family CompositeFrom (hask :: Type) :: PGType where
759 CompositeFrom hask = 'PGcomposite (PGFieldsFrom hask)
759 CompositeFrom hask = 'PGcomposite (PGFieldsFrom hask)
760
760
761−type family PGFieldsFrom (hask :: Type) :: RelationType where
761+type family PGFieldsFrom (hask :: Type) :: RowType where
762 PGFieldsFrom hask = PGFieldsOf (RecordCodeOf hask)
762 PGFieldsFrom hask = PGFieldsOf (RecordCodeOf hask)
763
763
764−type family PGFieldsOf (fields :: [(Symbol, Type)]) :: RelationType where
764+type family PGFieldsOf (fields :: [(Symbol, Type)]) :: RowType where
765 PGFieldsOf '[] = '[]
765 PGFieldsOf '[] = '[]
766 PGFieldsOf (field ': fields) = PGFieldOf field ': PGFieldsOf fields
766 PGFieldsOf (field ': fields) = PGFieldOf field ': PGFieldsOf fields
767
767