@@ -30,7 +30,8 @@ Squeal expressions are the atoms used to build statements.
30module Squeal.PostgreSQL.Expression
30module Squeal.PostgreSQL.Expression
31 ( -- * Expression
31 ( -- * Expression
32 Expression (UnsafeExpression, renderExpression)
32 Expression (UnsafeExpression, renderExpression)
33− , HasParameter (param)
33+ , HasParameter (parameter)
34 -- ** Null
35 -- ** Null
@@ -163,6 +164,7 @@ values from primitive expression using arithmetic, logical,
163and other operations.
164and other operations.
165newtype Expression
166newtype Expression
167+ (schema :: SchemaType)
166 (relations :: RelationsType)
168 (relations :: RelationsType)
167 (grouping :: Grouping)
169 (grouping :: Grouping)
168 (params :: [NullityType])
170 (params :: [NullityType])
@@ -178,43 +180,51 @@ supplied externally to a SQL statement.
178separately from the SQL command string, in which case `param`s are used to
180separately from the SQL command string, in which case `param`s are used to
179refer to the out-of-line data values.
181refer to the out-of-line data values.
181−class (PGTyped (PGTypeOf ty), KnownNat n) => HasParameter
183+class KnownNat n => HasParameter
182 (n :: Nat)
184 (n :: Nat)
185+ (schema :: SchemaType)
183 (params :: [NullityType])
186 (params :: [NullityType])
184 (ty :: NullityType)
187 (ty :: NullityType)
185 | n params -> ty where
188 | n params -> ty where
190+ :: TypeExpression schema (PGTypeOf ty)
186− param :: Expression relations grouping params ty
191+ -> Expression schema relations grouping params ty
187− param = UnsafeExpression $ parenthesized $
192+ parameter ty = UnsafeExpression $ parenthesized $
188 "$" <> renderNat (Proxy @n) <+> "::"
193 "$" <> renderNat (Proxy @n) <+> "::"
189− <+> renderTypeExpression (pgtype @(PGTypeOf ty))
194+ <+> renderTypeExpression ty
190−instance {-# OVERLAPPING #-} PGTyped (PGTypeOf ty1)
191− => HasParameter 1 (ty1:tys) ty1
195+instance {-# OVERLAPPING #-} HasParameter 1 schema (ty1:tys) ty1
192−instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
196+instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) schema params ty)
193− => HasParameter n (ty' : params) ty
197+ => HasParameter n schema (ty' : params) ty
200+ :: forall n schema params relations grouping ty
201+ . (PGTyped schema (PGTypeOf ty), HasParameter n schema params ty)
202+ => Expression schema relations grouping params ty
203+param = parameter @n pgtype
195instance (HasUnique relation relations columns, Has column columns ty)
205instance (HasUnique relation relations columns, Has column columns ty)
196− => IsLabel column (Expression relations 'Ungrouped params ty) where
206+ => IsLabel column (Expression schema relations 'Ungrouped params ty) where
197 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
207 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
198instance (HasUnique relation relations columns, Has column columns ty)
208instance (HasUnique relation relations columns, Has column columns ty)
199 => IsLabel column
209 => IsLabel column
200− (Aliased (Expression relations 'Ungrouped params) (column ::: ty)) where
210+ (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
201 fromLabel = fromLabel @column `As` Alias @column
211 fromLabel = fromLabel @column `As` Alias @column
202instance (HasUnique relation relations columns, Has column columns ty)
212instance (HasUnique relation relations columns, Has column columns ty)
203 => IsLabel column
213 => IsLabel column
204− (NP (Aliased (Expression relations 'Ungrouped params)) '[column ::: ty]) where
214+ (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
205 fromLabel = fromLabel @column :* Nil
215 fromLabel = fromLabel @column :* Nil
207instance (Has relation relations columns, Has column columns ty)
217instance (Has relation relations columns, Has column columns ty)
208− => IsQualified relation column (Expression relations 'Ungrouped params ty) where
218+ => IsQualified relation column (Expression schema relations 'Ungrouped params ty) where
209 relation ! column = UnsafeExpression $
219 relation ! column = UnsafeExpression $
210 renderAlias relation <> "." <> renderAlias column
220 renderAlias relation <> "." <> renderAlias column
211instance (Has relation relations columns, Has column columns ty)
221instance (Has relation relations columns, Has column columns ty)
212 => IsQualified relation column
222 => IsQualified relation column
213− (Aliased (Expression relations 'Ungrouped params) (column ::: ty)) where
223+ (Aliased (Expression schema relations 'Ungrouped params) (column ::: ty)) where
214 relation ! column = relation ! column `As` column
224 relation ! column = relation ! column `As` column
215instance (Has relation relations columns, Has column columns ty)
225instance (Has relation relations columns, Has column columns ty)
216 => IsQualified relation column
226 => IsQualified relation column
217− (NP (Aliased (Expression relations 'Ungrouped params)) '[column ::: ty]) where
227+ (NP (Aliased (Expression schema relations 'Ungrouped params)) '[column ::: ty]) where
218 relation ! column = relation ! column :* Nil
228 relation ! column = relation ! column :* Nil
@@ -222,14 +232,14 @@ instance
222 , Has column columns ty
232 , Has column columns ty
223 , GroupedBy relation column bys
233 , GroupedBy relation column bys
224 ) => IsLabel column
234 ) => IsLabel column
225− (Expression relations ('Grouped bys) params ty) where
235+ (Expression schema relations ('Grouped bys) params ty) where
226 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
236 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
228 ( HasUnique relation relations columns
238 ( HasUnique relation relations columns
229 , Has column columns ty
239 , Has column columns ty
230 , GroupedBy relation column bys
240 , GroupedBy relation column bys
231 ) => IsLabel column
241 ) => IsLabel column
232− ( Aliased (Expression relations ('Grouped bys) params)
242+ ( Aliased (Expression schema relations ('Grouped bys) params)
233 (column ::: ty) ) where
243 (column ::: ty) ) where
234 fromLabel = fromLabel @column `As` Alias @column
244 fromLabel = fromLabel @column `As` Alias @column
@@ -237,7 +247,7 @@ instance
237 , Has column columns ty
247 , Has column columns ty
238 , GroupedBy relation column bys
248 , GroupedBy relation column bys
239 ) => IsLabel column
249 ) => IsLabel column
240− ( NP (Aliased (Expression relations ('Grouped bys) params))
250+ ( NP (Aliased (Expression schema relations ('Grouped bys) params))
241 '[column ::: ty] ) where
251 '[column ::: ty] ) where
242 fromLabel = fromLabel @column :* Nil
252 fromLabel = fromLabel @column :* Nil
@@ -246,7 +256,7 @@ instance
246 , Has column columns ty
256 , Has column columns ty
247 , GroupedBy relation column bys
257 , GroupedBy relation column bys
248 ) => IsQualified relation column
258 ) => IsQualified relation column
249− (Expression relations ('Grouped bys) params ty) where
259+ (Expression schema relations ('Grouped bys) params ty) where
250 relation ! column = UnsafeExpression $
260 relation ! column = UnsafeExpression $
251 renderAlias relation <> "." <> renderAlias column
261 renderAlias relation <> "." <> renderAlias column
@@ -254,7 +264,7 @@ instance
254 , Has column columns ty
264 , Has column columns ty
255 , GroupedBy relation column bys
265 , GroupedBy relation column bys
256 ) => IsQualified relation column
266 ) => IsQualified relation column
257− (Aliased (Expression relations ('Grouped bys) params)
267+ (Aliased (Expression schema relations ('Grouped bys) params)
258 (column ::: ty)) where
268 (column ::: ty)) where
259 relation ! column = relation ! column `As` column
269 relation ! column = relation ! column `As` column
@@ -262,7 +272,7 @@ instance
262 , Has column columns ty
272 , Has column columns ty
263 , GroupedBy relation column bys
273 , GroupedBy relation column bys
264 ) => IsQualified relation column
274 ) => IsQualified relation column
265− ( NP (Aliased (Expression relations ('Grouped bys) params))
275+ ( NP (Aliased (Expression schema relations ('Grouped bys) params))
266 '[column ::: ty]) where
276 '[column ::: ty]) where
267 relation ! column = relation ! column :* Nil
277 relation ! column = relation ! column :* Nil
@@ -270,7 +280,7 @@ instance
271-- >>> renderExpression $ null_
281-- >>> renderExpression $ null_
273−null_ :: Expression rels grouping params ('Null ty)
283+null_ :: Expression schema rels grouping params ('Null ty)
274null_ = UnsafeExpression "NULL"
284null_ = UnsafeExpression "NULL"
276-- | analagous to `Just`
286-- | analagous to `Just`
@@ -278,8 +288,8 @@ null_ = UnsafeExpression "NULL"
278-- >>> renderExpression $ notNull true
288-- >>> renderExpression $ notNull true
281− :: Expression rels grouping params ('NotNull ty)
291+ :: Expression schema rels grouping params ('NotNull ty)
282− -> Expression rels grouping params ('Null ty)
292+ -> Expression schema rels grouping params ('Null ty)
283notNull = UnsafeExpression . renderExpression
293notNull = UnsafeExpression . renderExpression
285-- | return the leftmost value which is not NULL
295-- | return the leftmost value which is not NULL
@@ -287,11 +297,11 @@ notNull = UnsafeExpression . renderExpression
287-- >>> renderExpression $ coalesce [null_, notNull true] false
297-- >>> renderExpression $ coalesce [null_, notNull true] false
288-- "COALESCE(NULL, TRUE, FALSE)"
298-- "COALESCE(NULL, TRUE, FALSE)"
290− :: [Expression relations grouping params ('Null ty)]
300+ :: [Expression schema relations grouping params ('Null ty)]
291 -- ^ @NULL@s may be present
301 -- ^ @NULL@s may be present
292− -> Expression relations grouping params ('NotNull ty)
302+ -> Expression schema relations grouping params ('NotNull ty)
293 -- ^ @NULL@ is absent
303 -- ^ @NULL@ is absent
294− -> Expression relations grouping params ('NotNull ty)
304+ -> Expression schema relations grouping params ('NotNull ty)
295coalesce nullxs notNullx = UnsafeExpression $
305coalesce nullxs notNullx = UnsafeExpression $
296 "COALESCE" <> parenthesized (commaSeparated
306 "COALESCE" <> parenthesized (commaSeparated
297 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
307 ((renderExpression <$> nullxs) <> [renderExpression notNullx]))
@@ -301,26 +311,26 @@ coalesce nullxs notNullx = UnsafeExpression $
301-- >>> renderExpression $ fromNull true null_
311-- >>> renderExpression $ fromNull true null_
302-- "COALESCE(NULL, TRUE)"
312-- "COALESCE(NULL, TRUE)"
304− :: Expression relations grouping params ('NotNull ty)
314+ :: Expression schema relations grouping params ('NotNull ty)
305 -- ^ what to convert @NULL@ to
315 -- ^ what to convert @NULL@ to
306− -> Expression relations grouping params ('Null ty)
316+ -> Expression schema relations grouping params ('Null ty)
307− -> Expression relations grouping params ('NotNull ty)
317+ -> Expression schema relations grouping params ('NotNull ty)
308fromNull notNullx nullx = coalesce [nullx] notNullx
318fromNull notNullx nullx = coalesce [nullx] notNullx
310-- | >>> renderExpression $ null_ & isNull
320-- | >>> renderExpression $ null_ & isNull
311-- "NULL IS NULL"
321-- "NULL IS NULL"
313− :: Expression relations grouping params ('Null ty)
323+ :: Expression schema relations grouping params ('Null ty)
314 -- ^ possibly @NULL@
324 -- ^ possibly @NULL@
315− -> Condition relations grouping params
325+ -> Condition schema relations grouping params
316isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
326isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
318-- | >>> renderExpression $ null_ & isNotNull
328-- | >>> renderExpression $ null_ & isNotNull
319-- "NULL IS NOT NULL"
329-- "NULL IS NOT NULL"
321− :: Expression relations grouping params ('Null ty)
331+ :: Expression schema relations grouping params ('Null ty)
322 -- ^ possibly @NULL@
332 -- ^ possibly @NULL@
323− -> Condition relations grouping params
333+ -> Condition schema relations grouping params
324isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
334isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
326-- | analagous to `maybe` using @IS NULL@
336-- | analagous to `maybe` using @IS NULL@
@@ -328,13 +338,13 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
328-- >>> renderExpression $ matchNull true not_ null_
338-- >>> renderExpression $ matchNull true not_ null_
329-- "CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END"
339-- "CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END"
331− :: Expression relations grouping params (nullty)
341+ :: Expression schema relations grouping params (nullty)
332 -- ^ what to convert @NULL@ to
342 -- ^ what to convert @NULL@ to
333− -> ( Expression relations grouping params ('NotNull ty)
343+ -> ( Expression schema relations grouping params ('NotNull ty)
334− -> Expression relations grouping params (nullty) )
344+ -> Expression schema relations grouping params (nullty) )
335 -- ^ function to perform when @NULL@ is absent
345 -- ^ function to perform when @NULL@ is absent
336− -> Expression relations grouping params ('Null ty)
346+ -> Expression schema relations grouping params ('Null ty)
337− -> Expression relations grouping params (nullty)
347+ -> Expression schema relations grouping params (nullty)
338matchNull y f x = ifThenElse (isNull x) y
348matchNull y f x = ifThenElse (isNull x) y
339 (f (UnsafeExpression (renderExpression x)))
349 (f (UnsafeExpression (renderExpression x)))
@@ -345,25 +355,25 @@ matchNull y f x = ifThenElse (isNull x) y
345-- >>> renderExpression @_ @_ @'[_] $ fromNull false (nullIf false (param @1))
355-- >>> renderExpression @_ @_ @'[_] $ fromNull false (nullIf false (param @1))
346-- "COALESCE(NULL IF (FALSE, ($1 :: bool)), FALSE)"
356-- "COALESCE(NULL IF (FALSE, ($1 :: bool)), FALSE)"
348− :: Expression relations grouping params ('NotNull ty)
358+ :: Expression schema relations grouping params ('NotNull ty)
349 -- ^ @NULL@ is absent
359 -- ^ @NULL@ is absent
350− -> Expression relations grouping params ('NotNull ty)
360+ -> Expression schema relations grouping params ('NotNull ty)
351 -- ^ @NULL@ is absent
361 -- ^ @NULL@ is absent
352− -> Expression relations grouping params ('Null ty)
362+ -> Expression schema relations grouping params ('Null ty)
353nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
363nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
354 (renderExpression x <> ", " <> renderExpression y)
364 (renderExpression x <> ", " <> renderExpression y)
356-- | >>> renderExpression $ array [null_, notNull false, notNull true]
366-- | >>> renderExpression $ array [null_, notNull false, notNull true]
357-- "ARRAY[NULL, FALSE, TRUE]"
367-- "ARRAY[NULL, FALSE, TRUE]"
359− :: [Expression relations grouping params ('Null ty)]
369+ :: [Expression schema relations grouping params ('Null ty)]
360 -- ^ array elements
370 -- ^ array elements
361− -> Expression relations grouping params (nullity ('PGvararray ty))
371+ -> Expression schema relations grouping params (nullity ('PGvararray ty))
362array xs = UnsafeExpression $
372array xs = UnsafeExpression $
363 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
373 "ARRAY[" <> commaSeparated (renderExpression <$> xs) <> "]"
365instance (KnownSymbol label, label `In` labels) => IsPGlabel label
375instance (KnownSymbol label, label `In` labels) => IsPGlabel label
366− (Expression relations grouping params (nullity ('PGenum labels))) where
376+ (Expression schema relations grouping params (nullity ('PGenum labels))) where
367 label = UnsafeExpression $ renderLabel (PGlabel @label)
377 label = UnsafeExpression $ renderLabel (PGlabel @label)
369-- | A row constructor is an expression that builds a row value
379-- | A row constructor is an expression that builds a row value
@@ -375,47 +385,47 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
375-- "ROW(0, 1)"
385-- "ROW(0, 1)"
377 :: SListI (Nulls fields)
387 :: SListI (Nulls fields)
378− => NP (Aliased (Expression relation grouping params)) (Nulls fields)
388+ => NP (Aliased (Expression schema relations grouping params)) (Nulls fields)
379 -- ^ zero or more expressions for the row field values
389 -- ^ zero or more expressions for the row field values
380− -> Expression relation grouping params (nullity ('PGcomposite fields))
390+ -> Expression schema relations grouping params (nullity ('PGcomposite fields))
381row exprs = UnsafeExpression $ "ROW" <> parenthesized
391row exprs = UnsafeExpression $ "ROW" <> parenthesized
382 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
392 (renderCommaSeparated (\ (expr `As` _) -> renderExpression expr) exprs)
384instance Has field fields ty => IsLabel field
394instance Has field fields ty => IsLabel field
385− ( Expression relation grouping params (nullity ('PGcomposite fields))
395+ ( Expression schema relation grouping params (nullity ('PGcomposite fields))
386− -> Expression relation grouping params ('Null ty) ) where
396+ -> Expression schema relation grouping params ('Null ty) ) where
387 fromLabel expr = UnsafeExpression $
397 fromLabel expr = UnsafeExpression $
388 parenthesized (renderExpression expr) <> "." <>
398 parenthesized (renderExpression expr) <> "." <>
389 fromString (symbolVal (Proxy @field))
399 fromString (symbolVal (Proxy @field))
391instance Semigroup
401instance Semigroup
392− (Expression relations grouping params (nullity ('PGvararray ty))) where
402+ (Expression schema relations grouping params (nullity ('PGvararray ty))) where
393 (<>) = unsafeBinaryOp "||"
403 (<>) = unsafeBinaryOp "||"
395instance Monoid
405instance Monoid
396− (Expression relations grouping params (nullity ('PGvararray ty))) where
406+ (Expression schema relations grouping params (nullity ('PGvararray ty))) where
397 mempty = array []
407 mempty = array []
398 mappend = (<>)
408 mappend = (<>)
400-- | >>> renderExpression @_ @_ @'[_] $ greatest currentTimestamp [param @1]
410-- | >>> renderExpression @_ @_ @'[_] $ greatest currentTimestamp [param @1]
401-- "GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))"
411-- "GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))"
403− :: Expression relations grouping params (nullty)
413+ :: Expression schema relations grouping params (nullty)
404 -- ^ needs at least 1 argument
414 -- ^ needs at least 1 argument
405− -> [Expression relations grouping params (nullty)]
415+ -> [Expression schema relations grouping params (nullty)]
406 -- ^ or more
416 -- ^ or more
407− -> Expression relations grouping params (nullty)
417+ -> Expression schema relations grouping params (nullty)
408greatest x xs = UnsafeExpression $ "GREATEST("
418greatest x xs = UnsafeExpression $ "GREATEST("
409 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
419 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
411-- | >>> renderExpression $ least currentTimestamp [null_]
421-- | >>> renderExpression $ least currentTimestamp [null_]
412-- "LEAST(CURRENT_TIMESTAMP, NULL)"
422-- "LEAST(CURRENT_TIMESTAMP, NULL)"
414− :: Expression relations grouping params (nullty)
424+ :: Expression schema relations grouping params (nullty)
415 -- ^ needs at least 1 argument
425 -- ^ needs at least 1 argument
416− -> [Expression relations grouping params (nullty)]
426+ -> [Expression schema relations grouping params (nullty)]
417 -- ^ or more
427 -- ^ or more
418− -> Expression relations grouping params (nullty)
428+ -> Expression schema relations grouping params (nullty)
419least x xs = UnsafeExpression $ "LEAST("
429least x xs = UnsafeExpression $ "LEAST("
420 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
430 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
@@ -424,9 +434,9 @@ least x xs = UnsafeExpression $ "LEAST("
424unsafeBinaryOp
434unsafeBinaryOp
425 :: ByteString
435 :: ByteString
426 -- ^ operator
436 -- ^ operator
427− -> Expression relations grouping params (ty0)
437+ -> Expression schema relations grouping params (ty0)
428− -> Expression relations grouping params (ty1)
438+ -> Expression schema relations grouping params (ty1)
429− -> Expression relations grouping params (ty2)
439+ -> Expression schema relations grouping params (ty2)
430unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
440unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
431 renderExpression x <+> op <+> renderExpression y
441 renderExpression x <+> op <+> renderExpression y
@@ -435,8 +445,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
435unsafeUnaryOp
445unsafeUnaryOp
436 :: ByteString
446 :: ByteString
437 -- ^ operator
447 -- ^ operator
438− -> Expression relations grouping params (ty0)
448+ -> Expression schema relations grouping params (ty0)
439− -> Expression relations grouping params (ty1)
449+ -> Expression schema relations grouping params (ty1)
440unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
450unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
441 op <+> renderExpression x
451 op <+> renderExpression x
@@ -445,13 +455,13 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
445unsafeFunction
455unsafeFunction
446 :: ByteString
456 :: ByteString
447 -- ^ function
457 -- ^ function
448− -> Expression relations grouping params (xty)
458+ -> Expression schema relations grouping params (xty)
449− -> Expression relations grouping params (yty)
459+ -> Expression schema relations grouping params (yty)
450unsafeFunction fun x = UnsafeExpression $
460unsafeFunction fun x = UnsafeExpression $
451 fun <> parenthesized (renderExpression x)
461 fun <> parenthesized (renderExpression x)
453instance PGNum ty
463instance PGNum ty
454− => Num (Expression relations grouping params (nullity ty)) where
464+ => Num (Expression schema relations grouping params (nullity ty)) where
455 (+) = unsafeBinaryOp "+"
465 (+) = unsafeBinaryOp "+"
456 (-) = unsafeBinaryOp "-"
466 (-) = unsafeBinaryOp "-"
457 (*) = unsafeBinaryOp "*"
467 (*) = unsafeBinaryOp "*"
@@ -463,12 +473,12 @@ instance PGNum ty
465instance (PGNum ty, PGFloating ty) => Fractional
475instance (PGNum ty, PGFloating ty) => Fractional
466− (Expression relations grouping params (nullity ty)) where
476+ (Expression schema relations grouping params (nullity ty)) where
467 (/) = unsafeBinaryOp "/"
477 (/) = unsafeBinaryOp "/"
468 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
478 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
470instance (PGNum ty, PGFloating ty) => Floating
480instance (PGNum ty, PGFloating ty) => Floating
471− (Expression relations grouping params (nullity ty)) where
481+ (Expression schema relations grouping params (nullity ty)) where
472 pi = UnsafeExpression "pi()"
482 pi = UnsafeExpression "pi()"
473 exp = unsafeFunction "exp"
483 exp = unsafeFunction "exp"
474 log = unsafeFunction "ln"
484 log = unsafeFunction "ln"
@@ -491,18 +501,18 @@ instance (PGNum ty, PGFloating ty) => Floating
492-- | >>> :{
502-- | >>> :{
494−-- expression :: Expression relations grouping params (nullity 'PGfloat4)
504+-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
495-- expression = atan2_ pi 2
505-- expression = atan2_ pi 2
496-- in renderExpression expression
506-- in renderExpression expression
498-- "atan2(pi(), 2)"
508-- "atan2(pi(), 2)"
500 :: PGFloating float
510 :: PGFloating float
501− => Expression relations grouping params (nullity float)
511+ => Expression schema relations grouping params (nullity float)
502 -- ^ numerator
512 -- ^ numerator
503− -> Expression relations grouping params (nullity float)
513+ -> Expression schema relations grouping params (nullity float)
504 -- ^ denominator
514 -- ^ denominator
505− -> Expression relations grouping params (nullity float)
515+ -> Expression schema relations grouping params (nullity float)
506atan2_ y x = UnsafeExpression $
516atan2_ y x = UnsafeExpression $
507 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
517 "atan2(" <> renderExpression y <> ", " <> renderExpression x <> ")"
@@ -513,11 +523,11 @@ atan2_ y x = UnsafeExpression $
513-- | >>> renderExpression $ true & cast int4
523-- | >>> renderExpression $ true & cast int4
514-- "(TRUE :: int4)"
524-- "(TRUE :: int4)"
516− :: TypeExpression ty1
526+ :: TypeExpression schema ty1
517 -- ^ type to cast as
527 -- ^ type to cast as
518− -> Expression relations grouping params (nullity ty0)
528+ -> Expression schema relations grouping params (nullity ty0)
519 -- ^ value to convert
529 -- ^ value to convert
520− -> Expression relations grouping params (nullity ty1)
530+ -> Expression schema relations grouping params (nullity ty1)
521cast ty x = UnsafeExpression $ parenthesized $
531cast ty x = UnsafeExpression $ parenthesized $
522 renderExpression x <+> "::" <+> renderTypeExpression ty
532 renderExpression x <+> "::" <+> renderTypeExpression ty
@@ -525,135 +535,135 @@ cast ty x = UnsafeExpression $ parenthesized $
528−-- expression :: Expression relations grouping params (nullity 'PGint2)
538+-- expression :: Expression schema relations grouping params (nullity 'PGint2)
529-- expression = 5 `quot_` 2
539-- expression = 5 `quot_` 2
530-- in renderExpression expression
540-- in renderExpression expression
532-- "(5 / 2)"
542-- "(5 / 2)"
534 :: PGIntegral int
544 :: PGIntegral int
535− => Expression relations grouping params (nullity int)
545+ => Expression schema relations grouping params (nullity int)
536 -- ^ numerator
546 -- ^ numerator
537− -> Expression relations grouping params (nullity int)
547+ -> Expression schema relations grouping params (nullity int)
538 -- ^ denominator
548 -- ^ denominator
539− -> Expression relations grouping params (nullity int)
549+ -> Expression schema relations grouping params (nullity int)
540quot_ = unsafeBinaryOp "/"
550quot_ = unsafeBinaryOp "/"
542-- | remainder upon integer division
552-- | remainder upon integer division
546−-- expression :: Expression relations grouping params (nullity 'PGint2)
556+-- expression :: Expression schema relations grouping params (nullity 'PGint2)
547-- expression = 5 `rem_` 2
557-- expression = 5 `rem_` 2
548-- in renderExpression expression
558-- in renderExpression expression
550-- "(5 % 2)"
560-- "(5 % 2)"
552 :: PGIntegral int
562 :: PGIntegral int
553− => Expression relations grouping params (nullity int)
563+ => Expression schema relations grouping params (nullity int)
554 -- ^ numerator
564 -- ^ numerator
555− -> Expression relations grouping params (nullity int)
565+ -> Expression schema relations grouping params (nullity int)
556 -- ^ denominator
566 -- ^ denominator
557− -> Expression relations grouping params (nullity int)
567+ -> Expression schema relations grouping params (nullity int)
558rem_ = unsafeBinaryOp "%"
568rem_ = unsafeBinaryOp "%"
560-- | >>> :{
570-- | >>> :{
562−-- expression :: Expression relations grouping params (nullity 'PGfloat4)
572+-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
563-- expression = trunc pi
573-- expression = trunc pi
564-- in renderExpression expression
574-- in renderExpression expression
566-- "trunc(pi())"
576-- "trunc(pi())"
568 :: PGFloating frac
578 :: PGFloating frac
569− => Expression relations grouping params (nullity frac)
579+ => Expression schema relations grouping params (nullity frac)
570 -- ^ fractional number
580 -- ^ fractional number
571− -> Expression relations grouping params (nullity frac)
581+ -> Expression schema relations grouping params (nullity frac)
572trunc = unsafeFunction "trunc"
582trunc = unsafeFunction "trunc"
574-- | >>> :{
584-- | >>> :{
576−-- expression :: Expression relations grouping params (nullity 'PGfloat4)
586+-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
577-- expression = round_ pi
587-- expression = round_ pi
578-- in renderExpression expression
588-- in renderExpression expression
580-- "round(pi())"
590-- "round(pi())"
582 :: PGFloating frac
592 :: PGFloating frac
583− => Expression relations grouping params (nullity frac)
593+ => Expression schema relations grouping params (nullity frac)
584 -- ^ fractional number
594 -- ^ fractional number
585− -> Expression relations grouping params (nullity frac)
595+ -> Expression schema relations grouping params (nullity frac)
586round_ = unsafeFunction "round"
596round_ = unsafeFunction "round"
588-- | >>> :{
598-- | >>> :{
590−-- expression :: Expression relations grouping params (nullity 'PGfloat4)
600+-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
591-- expression = ceiling_ pi
601-- expression = ceiling_ pi
592-- in renderExpression expression
602-- in renderExpression expression
594-- "ceiling(pi())"
604-- "ceiling(pi())"
596 :: PGFloating frac
606 :: PGFloating frac
597− => Expression relations grouping params (nullity frac)
607+ => Expression schema relations grouping params (nullity frac)
598 -- ^ fractional number
608 -- ^ fractional number
599− -> Expression relations grouping params (nullity frac)
609+ -> Expression schema relations grouping params (nullity frac)
600ceiling_ = unsafeFunction "ceiling"
610ceiling_ = unsafeFunction "ceiling"
602-- | A `Condition` is a boolean valued `Expression`. While SQL allows
612-- | A `Condition` is a boolean valued `Expression`. While SQL allows
603-- conditions to have @NULL@, Squeal instead chooses to disallow @NULL@,
613-- conditions to have @NULL@, Squeal instead chooses to disallow @NULL@,
604-- forcing one to handle the case of @NULL@ explicitly to produce
614-- forcing one to handle the case of @NULL@ explicitly to produce
605-- a `Condition`.
615-- a `Condition`.
606−type Condition relations grouping params =
616+type Condition schema relations grouping params =
607− Expression relations grouping params ('NotNull 'PGbool)
617+ Expression schema relations grouping params ('NotNull 'PGbool)
609-- | >>> renderExpression true
619-- | >>> renderExpression true
611−true :: Condition relations grouping params
621+true :: Condition schema relations grouping params
612true = UnsafeExpression "TRUE"
622true = UnsafeExpression "TRUE"
614-- | >>> renderExpression false
624-- | >>> renderExpression false
615-- "FALSE"
625-- "FALSE"
616−false :: Condition relations grouping params
626+false :: Condition schema relations grouping params
617false = UnsafeExpression "FALSE"
627false = UnsafeExpression "FALSE"
619-- | >>> renderExpression $ not_ true
629-- | >>> renderExpression $ not_ true
620-- "(NOT TRUE)"
630-- "(NOT TRUE)"
622− :: Condition relations grouping params
632+ :: Condition schema relations grouping params
623− -> Condition relations grouping params
633+ -> Condition schema relations grouping params
624not_ = unsafeUnaryOp "NOT"
634not_ = unsafeUnaryOp "NOT"
626-- | >>> renderExpression $ true .&& false
636-- | >>> renderExpression $ true .&& false
627-- "(TRUE AND FALSE)"
637-- "(TRUE AND FALSE)"
629− :: Condition relations grouping params
639+ :: Condition schema relations grouping params
630− -> Condition relations grouping params
640+ -> Condition schema relations grouping params
631− -> Condition relations grouping params
641+ -> Condition schema relations grouping params
632(.&&) = unsafeBinaryOp "AND"
642(.&&) = unsafeBinaryOp "AND"
634-- | >>> renderExpression $ true .|| false
644-- | >>> renderExpression $ true .|| false
635-- "(TRUE OR FALSE)"
645-- "(TRUE OR FALSE)"
637− :: Condition relations grouping params
647+ :: Condition schema relations grouping params
638− -> Condition relations grouping params
648+ -> Condition schema relations grouping params
639− -> Condition relations grouping params
649+ -> Condition schema relations grouping params
640(.||) = unsafeBinaryOp "OR"
650(.||) = unsafeBinaryOp "OR"
642-- | >>> :{
652-- | >>> :{
644−-- expression :: Expression relations grouping params (nullity 'PGint2)
654+-- expression :: Expression schema relations grouping params (nullity 'PGint2)
645-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
655-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
646-- in renderExpression expression
656-- in renderExpression expression
648-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
658-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
649caseWhenThenElse
659caseWhenThenElse
650− :: [ ( Condition relations grouping params
660+ :: [ ( Condition schema relations grouping params
651− , Expression relations grouping params (ty)
661+ , Expression schema relations grouping params (ty)
653 -- ^ whens and thens
663 -- ^ whens and thens
654− -> Expression relations grouping params (ty)
664+ -> Expression schema relations grouping params (ty)
655 -- ^ else
665 -- ^ else
656− -> Expression relations grouping params (ty)
666+ -> Expression schema relations grouping params (ty)
657caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
667caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
659 , mconcat
669 , mconcat
@@ -669,16 +679,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
670-- | >>> :{
680-- | >>> :{
672−-- expression :: Expression relations grouping params (nullity 'PGint2)
682+-- expression :: Expression schema relations grouping params (nullity 'PGint2)
673-- expression = ifThenElse true 1 0
683-- expression = ifThenElse true 1 0
674-- in renderExpression expression
684-- in renderExpression expression
676-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
686-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
677ifThenElse
687ifThenElse
678− :: Condition relations grouping params
688+ :: Condition schema relations grouping params
679− -> Expression relations grouping params (ty) -- ^ then
689+ -> Expression schema relations grouping params (ty) -- ^ then
680− -> Expression relations grouping params (ty) -- ^ else
690+ -> Expression schema relations grouping params (ty) -- ^ else
681− -> Expression relations grouping params (ty)
691+ -> Expression schema relations grouping params (ty)
682ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
692ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
684-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
694-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -687,85 +697,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
687-- >>> renderExpression $ notNull true .== null_
697-- >>> renderExpression $ notNull true .== null_
688-- "(TRUE = NULL)"
698-- "(TRUE = NULL)"
690− :: Expression relations grouping params (nullity ty) -- ^ lhs
700+ :: Expression schema relations grouping params (nullity ty) -- ^ lhs
691− -> Expression relations grouping params (nullity ty) -- ^ rhs
701+ -> Expression schema relations grouping params (nullity ty) -- ^ rhs
692− -> Expression relations grouping params (nullity 'PGbool)
702+ -> Expression schema relations grouping params (nullity 'PGbool)
693(.==) = unsafeBinaryOp "="
703(.==) = unsafeBinaryOp "="
694infix 4 .==
704infix 4 .==
696-- | >>> renderExpression $ notNull true ./= null_
706-- | >>> renderExpression $ notNull true ./= null_
697-- "(TRUE <> NULL)"
707-- "(TRUE <> NULL)"
699− :: Expression relations grouping params (nullity ty) -- ^ lhs
709+ :: Expression schema relations grouping params (nullity ty) -- ^ lhs
700− -> Expression relations grouping params (nullity ty) -- ^ rhs
710+ -> Expression schema relations grouping params (nullity ty) -- ^ rhs
701− -> Expression relations grouping params (nullity 'PGbool)
711+ -> Expression schema relations grouping params (nullity 'PGbool)
702(./=) = unsafeBinaryOp "<>"
712(./=) = unsafeBinaryOp "<>"
703infix 4 ./=
713infix 4 ./=
705-- | >>> renderExpression $ notNull true .>= null_
715-- | >>> renderExpression $ notNull true .>= null_
706-- "(TRUE >= NULL)"
716-- "(TRUE >= NULL)"
708− :: Expression relations grouping params (nullity ty) -- ^ lhs
718+ :: Expression schema relations grouping params (nullity ty) -- ^ lhs
709− -> Expression relations grouping params (nullity ty) -- ^ rhs
719+ -> Expression schema relations grouping params (nullity ty) -- ^ rhs
710− -> Expression relations grouping params (nullity 'PGbool)
720+ -> Expression schema relations grouping params (nullity 'PGbool)
711(.>=) = unsafeBinaryOp ">="
721(.>=) = unsafeBinaryOp ">="
712infix 4 .>=
722infix 4 .>=
714-- | >>> renderExpression $ notNull true .< null_
724-- | >>> renderExpression $ notNull true .< null_
715-- "(TRUE < NULL)"
725-- "(TRUE < NULL)"
717− :: Expression relations grouping params (nullity ty) -- ^ lhs
727+ :: Expression schema relations grouping params (nullity ty) -- ^ lhs
718− -> Expression relations grouping params (nullity ty) -- ^ rhs
728+ -> Expression schema relations grouping params (nullity ty) -- ^ rhs
719− -> Expression relations grouping params (nullity 'PGbool)
729+ -> Expression schema relations grouping params (nullity 'PGbool)
720(.<) = unsafeBinaryOp "<"
730(.<) = unsafeBinaryOp "<"
721infix 4 .<
731infix 4 .<
723-- | >>> renderExpression $ notNull true .<= null_
733-- | >>> renderExpression $ notNull true .<= null_
724-- "(TRUE <= NULL)"
734-- "(TRUE <= NULL)"
726− :: Expression relations grouping params (nullity ty) -- ^ lhs
736+ :: Expression schema relations grouping params (nullity ty) -- ^ lhs
727− -> Expression relations grouping params (nullity ty) -- ^ rhs
737+ -> Expression schema relations grouping params (nullity ty) -- ^ rhs
728− -> Expression relations grouping params (nullity 'PGbool)
738+ -> Expression schema relations grouping params (nullity 'PGbool)
729(.<=) = unsafeBinaryOp "<="
739(.<=) = unsafeBinaryOp "<="
730infix 4 .<=
740infix 4 .<=
732-- | >>> renderExpression $ notNull true .> null_
742-- | >>> renderExpression $ notNull true .> null_
733-- "(TRUE > NULL)"
743-- "(TRUE > NULL)"
735− :: Expression relations grouping params (nullity ty) -- ^ lhs
745+ :: Expression schema relations grouping params (nullity ty) -- ^ lhs
736− -> Expression relations grouping params (nullity ty) -- ^ rhs
746+ -> Expression schema relations grouping params (nullity ty) -- ^ rhs
737− -> Expression relations grouping params (nullity 'PGbool)
747+ -> Expression schema relations grouping params (nullity 'PGbool)
738(.>) = unsafeBinaryOp ">"
748(.>) = unsafeBinaryOp ">"
739infix 4 .>
749infix 4 .>
741-- | >>> renderExpression currentDate
751-- | >>> renderExpression currentDate
742-- "CURRENT_DATE"
752-- "CURRENT_DATE"
743currentDate
753currentDate
744− :: Expression relations grouping params (nullity 'PGdate)
754+ :: Expression schema relations grouping params (nullity 'PGdate)
745currentDate = UnsafeExpression "CURRENT_DATE"
755currentDate = UnsafeExpression "CURRENT_DATE"
747-- | >>> renderExpression currentTime
757-- | >>> renderExpression currentTime
748-- "CURRENT_TIME"
758-- "CURRENT_TIME"
749currentTime
759currentTime
750− :: Expression relations grouping params (nullity 'PGtimetz)
760+ :: Expression schema relations grouping params (nullity 'PGtimetz)
751currentTime = UnsafeExpression "CURRENT_TIME"
761currentTime = UnsafeExpression "CURRENT_TIME"
753-- | >>> renderExpression currentTimestamp
763-- | >>> renderExpression currentTimestamp
754-- "CURRENT_TIMESTAMP"
764-- "CURRENT_TIMESTAMP"
755currentTimestamp
765currentTimestamp
756− :: Expression relations grouping params (nullity 'PGtimestamptz)
766+ :: Expression schema relations grouping params (nullity 'PGtimestamptz)
757currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
767currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
759-- | >>> renderExpression localTime
769-- | >>> renderExpression localTime
760-- "LOCALTIME"
770-- "LOCALTIME"
762− :: Expression relations grouping params (nullity 'PGtime)
772+ :: Expression schema relations grouping params (nullity 'PGtime)
763localTime = UnsafeExpression "LOCALTIME"
773localTime = UnsafeExpression "LOCALTIME"
765-- | >>> renderExpression localTimestamp
775-- | >>> renderExpression localTimestamp
766-- "LOCALTIMESTAMP"
776-- "LOCALTIMESTAMP"
767localTimestamp
777localTimestamp
768− :: Expression relations grouping params (nullity 'PGtimestamp)
778+ :: Expression schema relations grouping params (nullity 'PGtimestamp)
769localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
779localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
771{-----------------------------------------
781{-----------------------------------------
@@ -773,7 +783,7 @@ text
773-----------------------------------------}
783-----------------------------------------}
775instance IsString
785instance IsString
776− (Expression relations grouping params (nullity 'PGtext)) where
786+ (Expression schema relations grouping params (nullity 'PGtext)) where
777 fromString str = UnsafeExpression $
787 fromString str = UnsafeExpression $
778 "E\'" <> fromString (escape =<< str) <> "\'"
788 "E\'" <> fromString (escape =<< str) <> "\'"
@@ -789,36 +799,36 @@ instance IsString
791instance Semigroup
801instance Semigroup
792− (Expression relations grouping params (nullity 'PGtext)) where
802+ (Expression schema relations grouping params (nullity 'PGtext)) where
793 (<>) = unsafeBinaryOp "||"
803 (<>) = unsafeBinaryOp "||"
795instance Monoid
805instance Monoid
796− (Expression relations grouping params (nullity 'PGtext)) where
806+ (Expression schema relations grouping params (nullity 'PGtext)) where
797 mempty = fromString ""
807 mempty = fromString ""
798 mappend = (<>)
808 mappend = (<>)
800-- | >>> renderExpression $ lower "ARRRGGG"
810-- | >>> renderExpression $ lower "ARRRGGG"
801-- "lower(E'ARRRGGG')"
811-- "lower(E'ARRRGGG')"
803− :: Expression relations grouping params (nullity 'PGtext)
813+ :: Expression schema relations grouping params (nullity 'PGtext)
804 -- ^ string to lower case
814 -- ^ string to lower case
805− -> Expression relations grouping params (nullity 'PGtext)
815+ -> Expression schema relations grouping params (nullity 'PGtext)
806lower = unsafeFunction "lower"
816lower = unsafeFunction "lower"
808-- | >>> renderExpression $ upper "eeee"
818-- | >>> renderExpression $ upper "eeee"
809-- "upper(E'eeee')"
819-- "upper(E'eeee')"
811− :: Expression relations grouping params (nullity 'PGtext)
821+ :: Expression schema relations grouping params (nullity 'PGtext)
812 -- ^ string to upper case
822 -- ^ string to upper case
813− -> Expression relations grouping params (nullity 'PGtext)
823+ -> Expression schema relations grouping params (nullity 'PGtext)
814upper = unsafeFunction "upper"
824upper = unsafeFunction "upper"
816-- | >>> renderExpression $ charLength "four"
826-- | >>> renderExpression $ charLength "four"
817-- "char_length(E'four')"
827-- "char_length(E'four')"
818charLength
828charLength
819− :: Expression relations grouping params (nullity 'PGtext)
829+ :: Expression schema relations grouping params (nullity 'PGtext)
820 -- ^ string to measure
830 -- ^ string to measure
821− -> Expression relations grouping params (nullity 'PGint4)
831+ -> Expression schema relations grouping params (nullity 'PGint4)
822charLength = unsafeFunction "char_length"
832charLength = unsafeFunction "char_length"
824-- | The `like` expression returns true if the @string@ matches
834-- | The `like` expression returns true if the @string@ matches
@@ -831,11 +841,11 @@ charLength = unsafeFunction "char_length"
831-- >>> renderExpression $ "abc" `like` "a%"
841-- >>> renderExpression $ "abc" `like` "a%"
832-- "(E'abc' LIKE E'a%')"
842-- "(E'abc' LIKE E'a%')"
834− :: Expression relations grouping params (nullity 'PGtext)
844+ :: Expression schema relations grouping params (nullity 'PGtext)
835 -- ^ string
845 -- ^ string
836− -> Expression relations grouping params (nullity 'PGtext)
846+ -> Expression schema relations grouping params (nullity 'PGtext)
837 -- ^ pattern
847 -- ^ pattern
838− -> Expression relations grouping params (nullity 'PGbool)
848+ -> Expression schema relations grouping params (nullity 'PGbool)
839like = unsafeBinaryOp "LIKE"
849like = unsafeBinaryOp "LIKE"
841{-----------------------------------------
851{-----------------------------------------
@@ -845,16 +855,16 @@ aggregation
845-- | escape hatch to define aggregate functions
855-- | escape hatch to define aggregate functions
846unsafeAggregate
856unsafeAggregate
847 :: ByteString -- ^ aggregate function
857 :: ByteString -- ^ aggregate function
848− -> Expression relations 'Ungrouped params (xty)
858+ -> Expression schema relations 'Ungrouped params (xty)
849− -> Expression relations ('Grouped bys) params (yty)
859+ -> Expression schema relations ('Grouped bys) params (yty)
850unsafeAggregate fun x = UnsafeExpression $ mconcat
860unsafeAggregate fun x = UnsafeExpression $ mconcat
851 [fun, "(", renderExpression x, ")"]
861 [fun, "(", renderExpression x, ")"]
853-- | escape hatch to define aggregate functions over distinct values
863-- | escape hatch to define aggregate functions over distinct values
854unsafeAggregateDistinct
864unsafeAggregateDistinct
855 :: ByteString -- ^ aggregate function
865 :: ByteString -- ^ aggregate function
856− -> Expression relations 'Ungrouped params (xty)
866+ -> Expression schema relations 'Ungrouped params (xty)
857− -> Expression relations ('Grouped bys) params (yty)
867+ -> Expression schema relations ('Grouped bys) params (yty)
858unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
868unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
859 [fun, "(DISTINCT ", renderExpression x, ")"]
869 [fun, "(DISTINCT ", renderExpression x, ")"]
@@ -867,9 +877,9 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
867-- "sum(\"col\")"
877-- "sum(\"col\")"
869 :: PGNum ty
879 :: PGNum ty
870− => Expression relations 'Ungrouped params (nullity ty)
880+ => Expression schema relations 'Ungrouped params (nullity ty)
871 -- ^ what to sum
881 -- ^ what to sum
872− -> Expression relations ('Grouped bys) params (nullity ty)
882+ -> Expression schema relations ('Grouped bys) params (nullity ty)
873sum_ = unsafeAggregate "sum"
883sum_ = unsafeAggregate "sum"
875-- | >>> :{
885-- | >>> :{
@@ -881,18 +891,18 @@ sum_ = unsafeAggregate "sum"
881-- "sum(DISTINCT \"col\")"
891-- "sum(DISTINCT \"col\")"
882sumDistinct
892sumDistinct
883 :: PGNum ty
893 :: PGNum ty
884− => Expression relations 'Ungrouped params (nullity ty)
894+ => Expression schema relations 'Ungrouped params (nullity ty)
885 -- ^ what to sum
895 -- ^ what to sum
886− -> Expression relations ('Grouped bys) params (nullity ty)
896+ -> Expression schema relations ('Grouped bys) params (nullity ty)
887sumDistinct = unsafeAggregateDistinct "sum"
897sumDistinct = unsafeAggregateDistinct "sum"
889-- | A constraint for `PGType`s that you can take averages of and the resulting
899-- | A constraint for `PGType`s that you can take averages of and the resulting
890-- `PGType`.
900-- `PGType`.
891class PGAvg ty avg | ty -> avg where
901class PGAvg ty avg | ty -> avg where
892 avg, avgDistinct
902 avg, avgDistinct
893− :: Expression relations 'Ungrouped params (nullity ty)
903+ :: Expression schema relations 'Ungrouped params (nullity ty)
894 -- ^ what to average
904 -- ^ what to average
895− -> Expression relations ('Grouped bys) params (nullity avg)
905+ -> Expression schema relations ('Grouped bys) params (nullity avg)
896 avg = unsafeAggregate "avg"
906 avg = unsafeAggregate "avg"
897 avgDistinct = unsafeAggregateDistinct "avg"
907 avgDistinct = unsafeAggregateDistinct "avg"
898instance PGAvg 'PGint2 'PGnumeric
908instance PGAvg 'PGint2 'PGnumeric
@@ -912,9 +922,9 @@ instance PGAvg 'PGinterval 'PGinterval
912-- "bit_and(\"col\")"
922-- "bit_and(\"col\")"
914 :: PGIntegral int
924 :: PGIntegral int
915− => Expression relations 'Ungrouped params (nullity int)
925+ => Expression schema relations 'Ungrouped params (nullity int)
916 -- ^ what to aggregate
926 -- ^ what to aggregate
917− -> Expression relations ('Grouped bys) params (nullity int)
927+ -> Expression schema relations ('Grouped bys) params (nullity int)
918bitAnd = unsafeAggregate "bit_and"
928bitAnd = unsafeAggregate "bit_and"
920-- | >>> :{
930-- | >>> :{
@@ -926,9 +936,9 @@ bitAnd = unsafeAggregate "bit_and"
926-- "bit_or(\"col\")"
936-- "bit_or(\"col\")"
928 :: PGIntegral int
938 :: PGIntegral int
929− => Expression relations 'Ungrouped params (nullity int)
939+ => Expression schema relations 'Ungrouped params (nullity int)
930 -- ^ what to aggregate
940 -- ^ what to aggregate
931− -> Expression relations ('Grouped bys) params (nullity int)
941+ -> Expression schema relations ('Grouped bys) params (nullity int)
932bitOr = unsafeAggregate "bit_or"
942bitOr = unsafeAggregate "bit_or"
934-- | >>> :{
944-- | >>> :{
@@ -940,9 +950,9 @@ bitOr = unsafeAggregate "bit_or"
940-- "bit_and(DISTINCT \"col\")"
950-- "bit_and(DISTINCT \"col\")"
941bitAndDistinct
951bitAndDistinct
942 :: PGIntegral int
952 :: PGIntegral int
943− => Expression relations 'Ungrouped params (nullity int)
953+ => Expression schema relations 'Ungrouped params (nullity int)
944 -- ^ what to aggregate
954 -- ^ what to aggregate
945− -> Expression relations ('Grouped bys) params (nullity int)
955+ -> Expression schema relations ('Grouped bys) params (nullity int)
946bitAndDistinct = unsafeAggregateDistinct "bit_and"
956bitAndDistinct = unsafeAggregateDistinct "bit_and"
948-- | >>> :{
958-- | >>> :{
@@ -954,9 +964,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
954-- "bit_or(DISTINCT \"col\")"
964-- "bit_or(DISTINCT \"col\")"
955bitOrDistinct
965bitOrDistinct
956 :: PGIntegral int
966 :: PGIntegral int
957− => Expression relations 'Ungrouped params (nullity int)
967+ => Expression schema relations 'Ungrouped params (nullity int)
958 -- ^ what to aggregate
968 -- ^ what to aggregate
959− -> Expression relations ('Grouped bys) params (nullity int)
969+ -> Expression schema relations ('Grouped bys) params (nullity int)
960bitOrDistinct = unsafeAggregateDistinct "bit_or"
970bitOrDistinct = unsafeAggregateDistinct "bit_or"
962-- | >>> :{
972-- | >>> :{
@@ -967,9 +977,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
968-- "bool_and(\"col\")"
978-- "bool_and(\"col\")"
970− :: Expression relations 'Ungrouped params (nullity 'PGbool)
980+ :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
971 -- ^ what to aggregate
981 -- ^ what to aggregate
972− -> Expression relations ('Grouped bys) params (nullity 'PGbool)
982+ -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
973boolAnd = unsafeAggregate "bool_and"
983boolAnd = unsafeAggregate "bool_and"
975-- | >>> :{
985-- | >>> :{
@@ -980,9 +990,9 @@ boolAnd = unsafeAggregate "bool_and"
981-- "bool_or(\"col\")"
991-- "bool_or(\"col\")"
983− :: Expression relations 'Ungrouped params (nullity 'PGbool)
993+ :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
984 -- ^ what to aggregate
994 -- ^ what to aggregate
985− -> Expression relations ('Grouped bys) params (nullity 'PGbool)
995+ -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
986boolOr = unsafeAggregate "bool_or"
996boolOr = unsafeAggregate "bool_or"
988-- | >>> :{
998-- | >>> :{
@@ -993,9 +1003,9 @@ boolOr = unsafeAggregate "bool_or"
994-- "bool_and(DISTINCT \"col\")"
1004-- "bool_and(DISTINCT \"col\")"
995boolAndDistinct
1005boolAndDistinct
996− :: Expression relations 'Ungrouped params (nullity 'PGbool)
1006+ :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
997 -- ^ what to aggregate
1007 -- ^ what to aggregate
998− -> Expression relations ('Grouped bys) params (nullity 'PGbool)
1008+ -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
999boolAndDistinct = unsafeAggregateDistinct "bool_and"
1009boolAndDistinct = unsafeAggregateDistinct "bool_and"
1001-- | >>> :{
1011-- | >>> :{
@@ -1006,9 +1016,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
1007-- "bool_or(DISTINCT \"col\")"
1017-- "bool_or(DISTINCT \"col\")"
1008boolOrDistinct
1018boolOrDistinct
1009− :: Expression relations 'Ungrouped params (nullity 'PGbool)
1019+ :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1010 -- ^ what to aggregate
1020 -- ^ what to aggregate
1011− -> Expression relations ('Grouped bys) params (nullity 'PGbool)
1021+ -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1012boolOrDistinct = unsafeAggregateDistinct "bool_or"
1022boolOrDistinct = unsafeAggregateDistinct "bool_or"
1014-- | A special aggregation that does not require an input
1024-- | A special aggregation that does not require an input
@@ -1016,7 +1026,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1016-- >>> renderExpression countStar
1026-- >>> renderExpression countStar
1017-- "count(*)"
1027-- "count(*)"
1018countStar
1028countStar
1019− :: Expression relations ('Grouped bys) params ('NotNull 'PGint8)
1029+ :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1020countStar = UnsafeExpression $ "count(*)"
1030countStar = UnsafeExpression $ "count(*)"
1022-- | >>> :{
1032-- | >>> :{
@@ -1027,9 +1037,9 @@ countStar = UnsafeExpression $ "count(*)"
1028-- "count(\"col\")"
1038-- "count(\"col\")"
1030− :: Expression relations 'Ungrouped params ty
1040+ :: Expression schema relations 'Ungrouped params ty
1031 -- ^ what to count
1041 -- ^ what to count
1032− -> Expression relations ('Grouped bys) params ('NotNull 'PGint8)
1042+ -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1033count = unsafeAggregate "count"
1043count = unsafeAggregate "count"
1035-- | >>> :{
1045-- | >>> :{
@@ -1040,9 +1050,9 @@ count = unsafeAggregate "count"
1041-- "count(DISTINCT \"col\")"
1051-- "count(DISTINCT \"col\")"
1042countDistinct
1052countDistinct
1043− :: Expression relations 'Ungrouped params ty
1053+ :: Expression schema relations 'Ungrouped params ty
1044 -- ^ what to count
1054 -- ^ what to count
1045− -> Expression relations ('Grouped bys) params ('NotNull 'PGint8)
1055+ -> Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1046countDistinct = unsafeAggregateDistinct "count"
1056countDistinct = unsafeAggregateDistinct "count"
1048-- | synonym for `boolAnd`
1058-- | synonym for `boolAnd`
@@ -1055,9 +1065,9 @@ countDistinct = unsafeAggregateDistinct "count"
1056-- "every(\"col\")"
1066-- "every(\"col\")"
1058− :: Expression relations 'Ungrouped params (nullity 'PGbool)
1068+ :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1059 -- ^ what to aggregate
1069 -- ^ what to aggregate
1060− -> Expression relations ('Grouped bys) params (nullity 'PGbool)
1070+ -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1061every = unsafeAggregate "every"
1071every = unsafeAggregate "every"
1063-- | synonym for `boolAndDistinct`
1073-- | synonym for `boolAndDistinct`
@@ -1070,16 +1080,16 @@ every = unsafeAggregate "every"
1071-- "every(DISTINCT \"col\")"
1081-- "every(DISTINCT \"col\")"
1072everyDistinct
1082everyDistinct
1073− :: Expression relations 'Ungrouped params (nullity 'PGbool)
1083+ :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1074 -- ^ what to aggregate
1084 -- ^ what to aggregate
1075− -> Expression relations ('Grouped bys) params (nullity 'PGbool)
1085+ -> Expression schema relations ('Grouped bys) params (nullity 'PGbool)
1076everyDistinct = unsafeAggregateDistinct "every"
1086everyDistinct = unsafeAggregateDistinct "every"
1078-- | minimum and maximum aggregation
1088-- | minimum and maximum aggregation
1079max_, min_, maxDistinct, minDistinct
1089max_, min_, maxDistinct, minDistinct
1080− :: Expression relations 'Ungrouped params (nullity ty)
1090+ :: Expression schema relations 'Ungrouped params (nullity ty)
1081 -- ^ what to aggregate
1091 -- ^ what to aggregate
1082− -> Expression relations ('Grouped bys) params (nullity ty)
1092+ -> Expression schema relations ('Grouped bys) params (nullity ty)
1083max_ = unsafeAggregate "max"
1093max_ = unsafeAggregate "max"
1084min_ = unsafeAggregate "min"
1094min_ = unsafeAggregate "min"
1085maxDistinct = unsafeAggregateDistinct "max"
1095maxDistinct = unsafeAggregateDistinct "max"
@@ -1090,92 +1100,96 @@ type expressions
1090-----------------------------------------}
1100-----------------------------------------}
1092-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1102-- | `TypeExpression`s are used in `cast`s and `createTable` commands.
1093−newtype TypeExpression (ty :: PGType)
1103+newtype TypeExpression (schema :: SchemaType) (ty :: PGType)
1094 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1104 = UnsafeTypeExpression { renderTypeExpression :: ByteString }
1095 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1105 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1107+instance (Has alias schema ('Typedef ty))
1108+ => IsLabel alias (TypeExpression schema ty) where
1109+ fromLabel = UnsafeTypeExpression (renderAlias (fromLabel @alias))
1097-- | logical Boolean (true/false)
1111-- | logical Boolean (true/false)
1098−bool :: TypeExpression 'PGbool
1112+bool :: TypeExpression schema 'PGbool
1099bool = UnsafeTypeExpression "bool"
1113bool = UnsafeTypeExpression "bool"
1100-- | signed two-byte integer
1114-- | signed two-byte integer
1101−int2, smallint :: TypeExpression 'PGint2
1115+int2, smallint :: TypeExpression schema 'PGint2
1102int2 = UnsafeTypeExpression "int2"
1116int2 = UnsafeTypeExpression "int2"
1103smallint = UnsafeTypeExpression "smallint"
1117smallint = UnsafeTypeExpression "smallint"
1104-- | signed four-byte integer
1118-- | signed four-byte integer
1105−int4, int, integer :: TypeExpression 'PGint4
1119+int4, int, integer :: TypeExpression schema 'PGint4
1106int4 = UnsafeTypeExpression "int4"
1120int4 = UnsafeTypeExpression "int4"
1107int = UnsafeTypeExpression "int"
1121int = UnsafeTypeExpression "int"
1108integer = UnsafeTypeExpression "integer"
1122integer = UnsafeTypeExpression "integer"
1109-- | signed eight-byte integer
1123-- | signed eight-byte integer
1110−int8, bigint :: TypeExpression 'PGint8
1124+int8, bigint :: TypeExpression schema 'PGint8
1111int8 = UnsafeTypeExpression "int8"
1125int8 = UnsafeTypeExpression "int8"
1112bigint = UnsafeTypeExpression "bigint"
1126bigint = UnsafeTypeExpression "bigint"
1113-- | arbitrary precision numeric type
1127-- | arbitrary precision numeric type
1114−numeric :: TypeExpression 'PGnumeric
1128+numeric :: TypeExpression schema 'PGnumeric
1115numeric = UnsafeTypeExpression "numeric"
1129numeric = UnsafeTypeExpression "numeric"
1116-- | single precision floating-point number (4 bytes)
1130-- | single precision floating-point number (4 bytes)
1117−float4, real :: TypeExpression 'PGfloat4
1131+float4, real :: TypeExpression schema 'PGfloat4
1118float4 = UnsafeTypeExpression "float4"
1132float4 = UnsafeTypeExpression "float4"
1119real = UnsafeTypeExpression "real"
1133real = UnsafeTypeExpression "real"
1120-- | double precision floating-point number (8 bytes)
1134-- | double precision floating-point number (8 bytes)
1121−float8, doublePrecision :: TypeExpression 'PGfloat8
1135+float8, doublePrecision :: TypeExpression schema 'PGfloat8
1122float8 = UnsafeTypeExpression "float8"
1136float8 = UnsafeTypeExpression "float8"
1123doublePrecision = UnsafeTypeExpression "double precision"
1137doublePrecision = UnsafeTypeExpression "double precision"
1124-- | variable-length character string
1138-- | variable-length character string
1125−text :: TypeExpression 'PGtext
1139+text :: TypeExpression schema 'PGtext
1126text = UnsafeTypeExpression "text"
1140text = UnsafeTypeExpression "text"
1127-- | fixed-length character string
1141-- | fixed-length character string
1128char, character
1142char, character
1129 :: (KnownNat n, 1 <= n)
1143 :: (KnownNat n, 1 <= n)
1130 => proxy n
1144 => proxy n
1131− -> TypeExpression ('PGchar n)
1145+ -> TypeExpression schema ('PGchar n)
1132char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
1146char p = UnsafeTypeExpression $ "char(" <> renderNat p <> ")"
1133character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
1147character p = UnsafeTypeExpression $ "character(" <> renderNat p <> ")"
1134-- | variable-length character string
1148-- | variable-length character string
1135varchar, characterVarying
1149varchar, characterVarying
1136 :: (KnownNat n, 1 <= n)
1150 :: (KnownNat n, 1 <= n)
1137 => proxy n
1151 => proxy n
1138− -> TypeExpression ('PGvarchar n)
1152+ -> TypeExpression schema ('PGvarchar n)
1139varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
1153varchar p = UnsafeTypeExpression $ "varchar(" <> renderNat p <> ")"
1140characterVarying p = UnsafeTypeExpression $
1154characterVarying p = UnsafeTypeExpression $
1141 "character varying(" <> renderNat p <> ")"
1155 "character varying(" <> renderNat p <> ")"
1142-- | binary data ("byte array")
1156-- | binary data ("byte array")
1143−bytea :: TypeExpression 'PGbytea
1157+bytea :: TypeExpression schema 'PGbytea
1144bytea = UnsafeTypeExpression "bytea"
1158bytea = UnsafeTypeExpression "bytea"
1145-- | date and time (no time zone)
1159-- | date and time (no time zone)
1146−timestamp :: TypeExpression 'PGtimestamp
1160+timestamp :: TypeExpression schema 'PGtimestamp
1147timestamp = UnsafeTypeExpression "timestamp"
1161timestamp = UnsafeTypeExpression "timestamp"
1148-- | date and time, including time zone
1162-- | date and time, including time zone
1149−timestampWithTimeZone :: TypeExpression 'PGtimestamptz
1163+timestampWithTimeZone :: TypeExpression schema 'PGtimestamptz
1150timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
1164timestampWithTimeZone = UnsafeTypeExpression "timestamp with time zone"
1151-- | calendar date (year, month, day)
1165-- | calendar date (year, month, day)
1152−date :: TypeExpression 'PGdate
1166+date :: TypeExpression schema 'PGdate
1153date = UnsafeTypeExpression "date"
1167date = UnsafeTypeExpression "date"
1154-- | time of day (no time zone)
1168-- | time of day (no time zone)
1155−time :: TypeExpression 'PGtime
1169+time :: TypeExpression schema 'PGtime
1156time = UnsafeTypeExpression "time"
1170time = UnsafeTypeExpression "time"
1157-- | time of day, including time zone
1171-- | time of day, including time zone
1158−timeWithTimeZone :: TypeExpression 'PGtimetz
1172+timeWithTimeZone :: TypeExpression schema 'PGtimetz
1159timeWithTimeZone = UnsafeTypeExpression "time with time zone"
1173timeWithTimeZone = UnsafeTypeExpression "time with time zone"
1160-- | time span
1174-- | time span
1161−interval :: TypeExpression 'PGinterval
1175+interval :: TypeExpression schema 'PGinterval
1162interval = UnsafeTypeExpression "interval"
1176interval = UnsafeTypeExpression "interval"
1163-- | universally unique identifier
1177-- | universally unique identifier
1164−uuid :: TypeExpression 'PGuuid
1178+uuid :: TypeExpression schema 'PGuuid
1165uuid = UnsafeTypeExpression "uuid"
1179uuid = UnsafeTypeExpression "uuid"
1166-- | IPv4 or IPv6 host address
1180-- | IPv4 or IPv6 host address
1167−inet :: TypeExpression 'PGinet
1181+inet :: TypeExpression schema 'PGinet
1168inet = UnsafeTypeExpression "inet"
1182inet = UnsafeTypeExpression "inet"
1169-- | textual JSON data
1183-- | textual JSON data
1170−json :: TypeExpression 'PGjson
1184+json :: TypeExpression schema 'PGjson
1171json = UnsafeTypeExpression "json"
1185json = UnsafeTypeExpression "json"
1172-- | binary JSON data, decomposed
1186-- | binary JSON data, decomposed
1173−jsonb :: TypeExpression 'PGjsonb
1187+jsonb :: TypeExpression schema 'PGjsonb
1174jsonb = UnsafeTypeExpression "jsonb"
1188jsonb = UnsafeTypeExpression "jsonb"
1175-- | variable length array
1189-- | variable length array
1177− :: TypeExpression pg
1191+ :: TypeExpression schema pg
1178− -> TypeExpression ('PGvararray pg)
1192+ -> TypeExpression schema ('PGvararray pg)
1179vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1193vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1180-- | fixed length array
1194-- | fixed length array
@@ -1184,36 +1198,36 @@ vararray ty = UnsafeTypeExpression $ renderTypeExpression ty <> "[]"
1185 :: KnownNat n
1199 :: KnownNat n
1186 => proxy n
1200 => proxy n
1187− -> TypeExpression pg
1201+ -> TypeExpression schema pg
1188− -> TypeExpression ('PGfixarray n pg)
1202+ -> TypeExpression schema ('PGfixarray n pg)
1189fixarray p ty = UnsafeTypeExpression $
1203fixarray p ty = UnsafeTypeExpression $
1190 renderTypeExpression ty <> "[" <> renderNat p <> "]"
1204 renderTypeExpression ty <> "[" <> renderNat p <> "]"
1192-- | `pgtype` is a demoted version of a `PGType`
1206-- | `pgtype` is a demoted version of a `PGType`
1193−class PGTyped (ty :: PGType) where pgtype :: TypeExpression ty
1207+class PGTyped schema (ty :: PGType) where pgtype :: TypeExpression schema ty
1194−instance PGTyped 'PGbool where pgtype = bool
1208+instance PGTyped schema 'PGbool where pgtype = bool
1195−instance PGTyped 'PGint2 where pgtype = int2
1209+instance PGTyped schema 'PGint2 where pgtype = int2
1196−instance PGTyped 'PGint4 where pgtype = int4
1210+instance PGTyped schema 'PGint4 where pgtype = int4
1197−instance PGTyped 'PGint8 where pgtype = int8
1211+instance PGTyped schema 'PGint8 where pgtype = int8
1198−instance PGTyped 'PGnumeric where pgtype = numeric
1212+instance PGTyped schema 'PGnumeric where pgtype = numeric
1199−instance PGTyped 'PGfloat4 where pgtype = float4
1213+instance PGTyped schema 'PGfloat4 where pgtype = float4
1200−instance PGTyped 'PGfloat8 where pgtype = float8
1214+instance PGTyped schema 'PGfloat8 where pgtype = float8
1201−instance PGTyped 'PGtext where pgtype = text
1215+instance PGTyped schema 'PGtext where pgtype = text
1202instance (KnownNat n, 1 <= n)
1216instance (KnownNat n, 1 <= n)
1203− => PGTyped ('PGchar n) where pgtype = char (Proxy @n)
1217+ => PGTyped schema ('PGchar n) where pgtype = char (Proxy @n)
1204instance (KnownNat n, 1 <= n)
1218instance (KnownNat n, 1 <= n)
1205− => PGTyped ('PGvarchar n) where pgtype = varchar (Proxy @n)
1219+ => PGTyped schema ('PGvarchar n) where pgtype = varchar (Proxy @n)
1206−instance PGTyped 'PGbytea where pgtype = bytea
1220+instance PGTyped schema 'PGbytea where pgtype = bytea
1207−instance PGTyped 'PGtimestamp where pgtype = timestamp
1221+instance PGTyped schema 'PGtimestamp where pgtype = timestamp
1208−instance PGTyped 'PGtimestamptz where pgtype = timestampWithTimeZone
1222+instance PGTyped schema 'PGtimestamptz where pgtype = timestampWithTimeZone
1209−instance PGTyped 'PGdate where pgtype = date
1223+instance PGTyped schema 'PGdate where pgtype = date
1210−instance PGTyped 'PGtime where pgtype = time
1224+instance PGTyped schema 'PGtime where pgtype = time
1211−instance PGTyped 'PGtimetz where pgtype = timeWithTimeZone
1225+instance PGTyped schema 'PGtimetz where pgtype = timeWithTimeZone
1212−instance PGTyped 'PGinterval where pgtype = interval
1226+instance PGTyped schema 'PGinterval where pgtype = interval
1213−instance PGTyped 'PGuuid where pgtype = uuid
1227+instance PGTyped schema 'PGuuid where pgtype = uuid
1214−instance PGTyped 'PGjson where pgtype = json
1228+instance PGTyped schema 'PGjson where pgtype = json
1215−instance PGTyped 'PGjsonb where pgtype = jsonb
1229+instance PGTyped schema 'PGjsonb where pgtype = jsonb
1216−instance PGTyped ty => PGTyped ('PGvararray ty) where
1230+instance PGTyped schema ty => PGTyped schema ('PGvararray ty) where
1217− pgtype = vararray (pgtype @ty)
1231+ pgtype = vararray (pgtype @schema @ty)
1218−instance (KnownNat n, PGTyped ty) => PGTyped ('PGfixarray n ty) where
1232+instance (KnownNat n, PGTyped schema ty) => PGTyped schema ('PGfixarray n ty) where
1219− pgtype = fixarray (Proxy @n) (pgtype @ty)
1233+ pgtype = fixarray (Proxy @n) (pgtype @schema @ty)