@@ -218,7 +218,8 @@ values from primitive expression using arithmetic, logical,
218and other operations.
218and other operations.
220newtype Expression
220newtype Expression
221− (db :: DBType)
221+ (commons :: FromType)
222+ (schemas :: SchemasType)
222 (params :: [NullityType])
223 (params :: [NullityType])
223 (grp :: Grouping)
224 (grp :: Grouping)
224 (from :: FromType)
225 (from :: FromType)
@@ -226,7 +227,7 @@ newtype Expression
226 = UnsafeExpression { renderExpression :: ByteString }
227 = UnsafeExpression { renderExpression :: ByteString }
227 deriving (GHC.Generic,Show,Eq,Ord,NFData)
228 deriving (GHC.Generic,Show,Eq,Ord,NFData)
229−instance RenderSQL (Expression db params grp from ty) where
230+instance RenderSQL (Expression commons schemas params grp from ty) where
230 renderSQL = renderExpression
231 renderSQL = renderExpression
232{- | A `HasParameter` constraint is used to indicate a value that is
233{- | A `HasParameter` constraint is used to indicate a value that is
@@ -249,7 +250,7 @@ class KnownNat n => HasParameter
249 -- ($1 :: int4)
250 -- ($1 :: int4)
250 parameter
251 parameter
251 :: TypeExpression schemas ty
252 :: TypeExpression schemas ty
252− -> Expression (commons :=> schemas) params grp from ty
253+ -> Expression commons schemas params grp from ty
253 parameter ty = UnsafeExpression $ parenthesized $
254 parameter ty = UnsafeExpression $ parenthesized $
254 "$" <> renderNat @n <+> "::"
255 "$" <> renderNat @n <+> "::"
255 <+> renderSQL ty
256 <+> renderSQL ty
@@ -260,38 +261,38 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
260-- | `param` takes a `Nat` using type application and for basic types,
261-- | `param` takes a `Nat` using type application and for basic types,
261-- infers a `TypeExpression`.
262-- infers a `TypeExpression`.
263−-- >>> let expr = param @1 :: Expression (commons :=> schemas) '[ 'Null 'PGint4] grp from ('Null 'PGint4)
264+-- >>> let expr = param @1 :: Expression commons schemas '[ 'Null 'PGint4] grp from ('Null 'PGint4)
264-- >>> printSQL expr
265-- >>> printSQL expr
265-- ($1 :: int4)
266-- ($1 :: int4)
267− :: forall n db commons schemas params from grp ty
268+ :: forall n commons schemas params from grp ty
268− . (db ~ (commons :=> schemas), PGTyped schemas ty, HasParameter n params ty)
269+ . (PGTyped schemas ty, HasParameter n params ty)
269− => Expression db params grp from ty -- ^ param
270+ => Expression commons schemas params grp from ty -- ^ param
270param = parameter @n (pgtype @schemas)
271param = parameter @n (pgtype @schemas)
272instance (HasUnique tab from row, Has col row ty)
273instance (HasUnique tab from row, Has col row ty)
273− => IsLabel col (Expression db params 'Ungrouped from ty) where
274+ => IsLabel col (Expression commons schemas params 'Ungrouped from ty) where
274 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
275 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
275instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
276instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
276 => IsLabel col
277 => IsLabel col
277− (Aliased (Expression db params 'Ungrouped from) column) where
278+ (Aliased (Expression commons schemas params 'Ungrouped from) column) where
278 fromLabel = fromLabel @col `As` Alias
279 fromLabel = fromLabel @col `As` Alias
279instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
280instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
280 => IsLabel col
281 => IsLabel col
281− (NP (Aliased (Expression db params 'Ungrouped from)) columns) where
282+ (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
282 fromLabel = fromLabel @col :* Nil
283 fromLabel = fromLabel @col :* Nil
284instance (Has tab from row, Has col row ty)
285instance (Has tab from row, Has col row ty)
285− => IsQualified tab col (Expression db params 'Ungrouped from ty) where
286+ => IsQualified tab col (Expression commons schemas params 'Ungrouped from ty) where
286 tab ! col = UnsafeExpression $
287 tab ! col = UnsafeExpression $
287 renderSQL tab <> "." <> renderSQL col
288 renderSQL tab <> "." <> renderSQL col
288instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
289instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
289 => IsQualified tab col
290 => IsQualified tab col
290− (Aliased (Expression db params 'Ungrouped from) column) where
291+ (Aliased (Expression commons schemas params 'Ungrouped from) column) where
291 tab ! col = tab ! col `As` col
292 tab ! col = tab ! col `As` col
292instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
293instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
293 => IsQualified tab col
294 => IsQualified tab col
294− (NP (Aliased (Expression db params 'Ungrouped from)) columns) where
295+ (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
295 tab ! col = tab ! col :* Nil
296 tab ! col = tab ! col :* Nil
@@ -299,7 +300,7 @@ instance
299 , Has col row ty
300 , Has col row ty
300 , GroupedBy tab col bys
301 , GroupedBy tab col bys
301 ) => IsLabel col
302 ) => IsLabel col
302− (Expression db params ('Grouped bys) from ty) where
303+ (Expression commons schemas params ('Grouped bys) from ty) where
303 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
304 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
305 ( HasUnique tab from row
306 ( HasUnique tab from row
@@ -307,7 +308,7 @@ instance
307 , GroupedBy tab col bys
308 , GroupedBy tab col bys
308 , column ~ (col ::: ty)
309 , column ~ (col ::: ty)
309 ) => IsLabel col
310 ) => IsLabel col
310− (Aliased (Expression db params ('Grouped bys) from) column) where
311+ (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
311 fromLabel = fromLabel @col `As` Alias
312 fromLabel = fromLabel @col `As` Alias
313 ( HasUnique tab from row
314 ( HasUnique tab from row
@@ -315,7 +316,7 @@ instance
315 , GroupedBy tab col bys
316 , GroupedBy tab col bys
316 , columns ~ '[col ::: ty]
317 , columns ~ '[col ::: ty]
317 ) => IsLabel col
318 ) => IsLabel col
318− (NP (Aliased (Expression db params ('Grouped bys) from)) columns) where
319+ (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
319 fromLabel = fromLabel @col :* Nil
320 fromLabel = fromLabel @col :* Nil
@@ -323,7 +324,7 @@ instance
323 , Has col row ty
324 , Has col row ty
324 , GroupedBy tab col bys
325 , GroupedBy tab col bys
325 ) => IsQualified tab col
326 ) => IsQualified tab col
326− (Expression db params ('Grouped bys) from ty) where
327+ (Expression commons schemas params ('Grouped bys) from ty) where
327 tab ! col = UnsafeExpression $
328 tab ! col = UnsafeExpression $
328 renderSQL tab <> "." <> renderSQL col
329 renderSQL tab <> "." <> renderSQL col
@@ -332,7 +333,7 @@ instance
332 , GroupedBy tab col bys
333 , GroupedBy tab col bys
333 , column ~ (col ::: ty)
334 , column ~ (col ::: ty)
334 ) => IsQualified tab col
335 ) => IsQualified tab col
335− (Aliased (Expression db params ('Grouped bys) from) column) where
336+ (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
336 tab ! col = tab ! col `As` col
337 tab ! col = tab ! col `As` col
338 ( Has tab from row
339 ( Has tab from row
@@ -340,14 +341,14 @@ instance
340 , GroupedBy tab col bys
341 , GroupedBy tab col bys
341 , columns ~ '[col ::: ty]
342 , columns ~ '[col ::: ty]
342 ) => IsQualified tab col
343 ) => IsQualified tab col
343− (NP (Aliased (Expression db params ('Grouped bys) from)) columns) where
344+ (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
344 tab ! col = tab ! col :* Nil
345 tab ! col = tab ! col :* Nil
346-- | analagous to `Nothing`
347-- | analagous to `Nothing`
348-- >>> printSQL null_
349-- >>> printSQL null_
350−null_ :: Expression db rels grouping params ('Null ty)
351+null_ :: Expression commons schemas rels grouping params ('Null ty)
351null_ = UnsafeExpression "NULL"
352null_ = UnsafeExpression "NULL"
353-- | analagous to `Just`
354-- | analagous to `Just`
@@ -355,8 +356,8 @@ null_ = UnsafeExpression "NULL"
355-- >>> printSQL $ notNull true
356-- >>> printSQL $ notNull true
358− :: Expression db rels grouping params ('NotNull ty)
359+ :: Expression commons schemas rels grouping params ('NotNull ty)
359− -> Expression db rels grouping params ('Null ty)
360+ -> Expression commons schemas rels grouping params ('Null ty)
360notNull = UnsafeExpression . renderSQL
361notNull = UnsafeExpression . renderSQL
362-- | return the leftmost value which is not NULL
363-- | return the leftmost value which is not NULL
@@ -364,11 +365,11 @@ notNull = UnsafeExpression . renderSQL
364-- >>> printSQL $ coalesce [null_, true] false
365-- >>> printSQL $ coalesce [null_, true] false
365-- COALESCE(NULL, TRUE, FALSE)
366-- COALESCE(NULL, TRUE, FALSE)
367− :: [Expression db params grp from ('Null ty)]
368+ :: [Expression commons schemas params grp from ('Null ty)]
368 -- ^ @NULL@s may be present
369 -- ^ @NULL@s may be present
369− -> Expression db params grp from ('NotNull ty)
370+ -> Expression commons schemas params grp from ('NotNull ty)
370 -- ^ @NULL@ is absent
371 -- ^ @NULL@ is absent
371− -> Expression db params grp from ('NotNull ty)
372+ -> Expression commons schemas params grp from ('NotNull ty)
372coalesce nullxs notNullx = UnsafeExpression $
373coalesce nullxs notNullx = UnsafeExpression $
373 "COALESCE" <> parenthesized (commaSeparated
374 "COALESCE" <> parenthesized (commaSeparated
374 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
375 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
@@ -378,26 +379,26 @@ coalesce nullxs notNullx = UnsafeExpression $
378-- >>> printSQL $ fromNull true null_
379-- >>> printSQL $ fromNull true null_
379-- COALESCE(NULL, TRUE)
380-- COALESCE(NULL, TRUE)
381− :: Expression db params grp from ('NotNull ty)
382+ :: Expression commons schemas params grp from ('NotNull ty)
382 -- ^ what to convert @NULL@ to
383 -- ^ what to convert @NULL@ to
383− -> Expression db params grp from ('Null ty)
384+ -> Expression commons schemas params grp from ('Null ty)
384− -> Expression db params grp from ('NotNull ty)
385+ -> Expression commons schemas params grp from ('NotNull ty)
385fromNull notNullx nullx = coalesce [nullx] notNullx
386fromNull notNullx nullx = coalesce [nullx] notNullx
387-- | >>> printSQL $ null_ & isNull
388-- | >>> printSQL $ null_ & isNull
388-- NULL IS NULL
389-- NULL IS NULL
390− :: Expression db params grp from ('Null ty)
391+ :: Expression commons schemas params grp from ('Null ty)
391 -- ^ possibly @NULL@
392 -- ^ possibly @NULL@
392− -> Condition db params grp from
393+ -> Condition commons schemas params grp from
393isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
394isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
395-- | >>> printSQL $ null_ & isNotNull
396-- | >>> printSQL $ null_ & isNotNull
396-- NULL IS NOT NULL
397-- NULL IS NOT NULL
398− :: Expression db params grp from ('Null ty)
399+ :: Expression commons schemas params grp from ('Null ty)
399 -- ^ possibly @NULL@
400 -- ^ possibly @NULL@
400− -> Condition db params grp from
401+ -> Condition commons schemas params grp from
401isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
402isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
403-- | analagous to `maybe` using @IS NULL@
404-- | analagous to `maybe` using @IS NULL@
@@ -405,13 +406,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
405-- >>> printSQL $ matchNull true not_ null_
406-- >>> printSQL $ matchNull true not_ null_
406-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
407-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
408− :: Expression db params grp from (nullty)
409+ :: Expression commons schemas params grp from (nullty)
409 -- ^ what to convert @NULL@ to
410 -- ^ what to convert @NULL@ to
410− -> ( Expression db params grp from ('NotNull ty)
411+ -> ( Expression commons schemas params grp from ('NotNull ty)
411− -> Expression db params grp from (nullty) )
412+ -> Expression commons schemas params grp from (nullty) )
412 -- ^ function to perform when @NULL@ is absent
413 -- ^ function to perform when @NULL@ is absent
413− -> Expression db params grp from ('Null ty)
414+ -> Expression commons schemas params grp from ('Null ty)
414− -> Expression db params grp from (nullty)
415+ -> Expression commons schemas params grp from (nullty)
415matchNull y f x = ifThenElse (isNull x) y
416matchNull y f x = ifThenElse (isNull x) y
416 (f (UnsafeExpression (renderSQL x)))
417 (f (UnsafeExpression (renderSQL x)))
@@ -424,20 +425,20 @@ matchNull y f x = ifThenElse (isNull x) y
424NULL IF (FALSE, ($1 :: bool))
425NULL IF (FALSE, ($1 :: bool))
427− :: Expression db params grp from ('NotNull ty)
428+ :: Expression commons schemas params grp from ('NotNull ty)
428 -- ^ @NULL@ is absent
429 -- ^ @NULL@ is absent
429− -> Expression db params grp from ('NotNull ty)
430+ -> Expression commons schemas params grp from ('NotNull ty)
430 -- ^ @NULL@ is absent
431 -- ^ @NULL@ is absent
431− -> Expression db params grp from ('Null ty)
432+ -> Expression commons schemas params grp from ('Null ty)
432nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
433 (renderSQL x <> ", " <> renderSQL y)
434 (renderSQL x <> ", " <> renderSQL y)
435-- | >>> printSQL $ array [null_, false, true]
436-- | >>> printSQL $ array [null_, false, true]
436-- ARRAY[NULL, FALSE, TRUE]
437-- ARRAY[NULL, FALSE, TRUE]
438− :: [Expression db params grp from ty]
439+ :: [Expression commons schemas params grp from ty]
439 -- ^ array elements
440 -- ^ array elements
440− -> Expression db params grp from (nullity ('PGvararray ty))
441+ -> Expression commons schemas params grp from (nullity ('PGvararray ty))
441array xs = UnsafeExpression $
442array xs = UnsafeExpression $
442 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
443 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
@@ -445,13 +446,13 @@ array xs = UnsafeExpression $
445-- (ARRAY[NULL, FALSE, TRUE])[2]
446-- (ARRAY[NULL, FALSE, TRUE])[2]
447 :: Word64 -- ^ index
448 :: Word64 -- ^ index
448− -> Expression db params grp from (nullity ('PGvararray ty)) -- ^ array
449+ -> Expression commons schemas params grp from (nullity ('PGvararray ty)) -- ^ array
449− -> Expression db params grp from (NullifyType ty)
450+ -> Expression commons schemas params grp from (NullifyType ty)
450index n expr = UnsafeExpression $
451index n expr = UnsafeExpression $
451 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
452 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
453instance (KnownSymbol label, label `In` labels) => IsPGlabel label
454instance (KnownSymbol label, label `In` labels) => IsPGlabel label
454− (Expression db params grp from (nullity ('PGenum labels))) where
455+ (Expression commons schemas params grp from (nullity ('PGenum labels))) where
455 label = UnsafeExpression $ renderSQL (PGlabel @label)
456 label = UnsafeExpression $ renderSQL (PGlabel @label)
457-- | A row constructor is an expression that builds a row value
458-- | A row constructor is an expression that builds a row value
@@ -463,14 +464,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
463-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
464-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
466−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression db from grp params ('NotNull Complex)
467+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression commons schemas from grp params ('NotNull Complex)
467-- >>> printSQL i
468-- >>> printSQL i
468-- ROW(0, 1)
469-- ROW(0, 1)
470 :: SListI row
471 :: SListI row
471− => NP (Aliased (Expression db params grp from)) row
472+ => NP (Aliased (Expression commons schemas params grp from)) row
472 -- ^ zero or more expressions for the row field values
473 -- ^ zero or more expressions for the row field values
473− -> Expression db params grp from (nullity ('PGcomposite row))
474+ -> Expression commons schemas params grp from (nullity ('PGcomposite row))
474row exprs = UnsafeExpression $ "ROW" <> parenthesized
475row exprs = UnsafeExpression $ "ROW" <> parenthesized
475 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
476 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
@@ -491,41 +492,41 @@ field
491 , Has field row ty)
492 , Has field row ty)
492 => QualifiedAlias sch tydef -- ^ row type
493 => QualifiedAlias sch tydef -- ^ row type
493 -> Alias field -- ^ field name
494 -> Alias field -- ^ field name
494− -> Expression (commons :=> schemas) params grp from ('NotNull ('PGcomposite row))
495+ -> Expression commons schemas params grp from ('NotNull ('PGcomposite row))
495− -> Expression (commons :=> schemas) params grp from ty
496+ -> Expression commons schemas params grp from ty
496field td fld expr = UnsafeExpression $
497field td fld expr = UnsafeExpression $
497 parenthesized (renderSQL expr <> "::" <> renderSQL td)
498 parenthesized (renderSQL expr <> "::" <> renderSQL td)
498 <> "." <> renderSQL fld
499 <> "." <> renderSQL fld
500instance Semigroup
501instance Semigroup
501− (Expression db params grp from (nullity ('PGvararray ty))) where
502+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
502 (<>) = unsafeBinaryOp "||"
503 (<>) = unsafeBinaryOp "||"
504instance Monoid
505instance Monoid
505− (Expression db params grp from (nullity ('PGvararray ty))) where
506+ (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
506 mempty = array []
507 mempty = array []
507 mappend = (<>)
508 mappend = (<>)
509−-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression (commons :=> schemas) '[ 'NotNull 'PGtimestamptz] grp from ('NotNull 'PGtimestamptz)
510+-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression commons schemas '[ 'NotNull 'PGtimestamptz] grp from ('NotNull 'PGtimestamptz)
510-- >>> printSQL expr
511-- >>> printSQL expr
511-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
512-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
513− :: Expression db params grp from (nullty)
514+ :: Expression commons schemas params grp from (nullty)
514 -- ^ needs at least 1 argument
515 -- ^ needs at least 1 argument
515− -> [Expression db params grp from (nullty)]
516+ -> [Expression commons schemas params grp from (nullty)]
516 -- ^ or more
517 -- ^ or more
517− -> Expression db params grp from (nullty)
518+ -> Expression commons schemas params grp from (nullty)
518greatest x xs = UnsafeExpression $ "GREATEST("
519greatest x xs = UnsafeExpression $ "GREATEST("
519 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
520 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
521-- | >>> printSQL $ least currentTimestamp [null_]
522-- | >>> printSQL $ least currentTimestamp [null_]
522-- LEAST(CURRENT_TIMESTAMP, NULL)
523-- LEAST(CURRENT_TIMESTAMP, NULL)
524− :: Expression db params grp from (nullty)
525+ :: Expression commons schemas params grp from (nullty)
525 -- ^ needs at least 1 argument
526 -- ^ needs at least 1 argument
526− -> [Expression db params grp from (nullty)]
527+ -> [Expression commons schemas params grp from (nullty)]
527 -- ^ or more
528 -- ^ or more
528− -> Expression db params grp from (nullty)
529+ -> Expression commons schemas params grp from (nullty)
529least x xs = UnsafeExpression $ "LEAST("
530least x xs = UnsafeExpression $ "LEAST("
530 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
531 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
@@ -534,9 +535,9 @@ least x xs = UnsafeExpression $ "LEAST("
534unsafeBinaryOp
535unsafeBinaryOp
535 :: ByteString
536 :: ByteString
536 -- ^ operator
537 -- ^ operator
537− -> Expression db params grp from (ty0)
538+ -> Expression commons schemas params grp from (ty0)
538− -> Expression db params grp from (ty1)
539+ -> Expression commons schemas params grp from (ty1)
539− -> Expression db params grp from (ty2)
540+ -> Expression commons schemas params grp from (ty2)
540unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
541 renderSQL x <+> op <+> renderSQL y
542 renderSQL x <+> op <+> renderSQL y
@@ -545,8 +546,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
545unsafeUnaryOp
546unsafeUnaryOp
546 :: ByteString
547 :: ByteString
547 -- ^ operator
548 -- ^ operator
548− -> Expression db params grp from (ty0)
549+ -> Expression commons schemas params grp from (ty0)
549− -> Expression db params grp from (ty1)
550+ -> Expression commons schemas params grp from (ty1)
550unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
551 op <+> renderSQL x
552 op <+> renderSQL x
@@ -555,8 +556,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
555unsafeFunction
556unsafeFunction
556 :: ByteString
557 :: ByteString
557 -- ^ function
558 -- ^ function
558− -> Expression db params grp from (xty)
559+ -> Expression commons schemas params grp from (xty)
559− -> Expression db params grp from (yty)
560+ -> Expression commons schemas params grp from (yty)
560unsafeFunction fun x = UnsafeExpression $
561unsafeFunction fun x = UnsafeExpression $
561 fun <> parenthesized (renderSQL x)
562 fun <> parenthesized (renderSQL x)
@@ -565,13 +566,13 @@ unsafeVariadicFunction
565 :: SListI elems
566 :: SListI elems
566 => ByteString
567 => ByteString
567 -- ^ function
568 -- ^ function
568− -> NP (Expression db params grp from) elems
569+ -> NP (Expression commons schemas params grp from) elems
569− -> Expression db params grp from ret
570+ -> Expression commons schemas params grp from ret
570unsafeVariadicFunction fun x = UnsafeExpression $
571unsafeVariadicFunction fun x = UnsafeExpression $
571 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
572 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
573instance ty `In` PGNum
574instance ty `In` PGNum
574− => Num (Expression db params grp from (nullity ty)) where
575+ => Num (Expression commons schemas params grp from (nullity ty)) where
575 (+) = unsafeBinaryOp "+"
576 (+) = unsafeBinaryOp "+"
576 (-) = unsafeBinaryOp "-"
577 (-) = unsafeBinaryOp "-"
577 (*) = unsafeBinaryOp "*"
578 (*) = unsafeBinaryOp "*"
@@ -583,12 +584,12 @@ instance ty `In` PGNum
585instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
586instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
586− (Expression db params grp from (nullity ty)) where
587+ (Expression commons schemas params grp from (nullity ty)) where
587 (/) = unsafeBinaryOp "/"
588 (/) = unsafeBinaryOp "/"
588 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
589 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
590instance (ty `In` PGNum, ty `In` PGFloating) => Floating
591instance (ty `In` PGNum, ty `In` PGFloating) => Floating
591− (Expression db params grp from (nullity ty)) where
592+ (Expression commons schemas params grp from (nullity ty)) where
592 pi = UnsafeExpression "pi()"
593 pi = UnsafeExpression "pi()"
593 exp = unsafeFunction "exp"
594 exp = unsafeFunction "exp"
594 log = unsafeFunction "ln"
595 log = unsafeFunction "ln"
@@ -611,18 +612,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
612-- | >>> :{
613-- | >>> :{
614−-- expression :: Expression db params grp from (nullity 'PGfloat4)
615+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
615-- expression = atan2_ pi 2
616-- expression = atan2_ pi 2
616-- in printSQL expression
617-- in printSQL expression
618-- atan2(pi(), 2)
619-- atan2(pi(), 2)
620 :: float `In` PGFloating
621 :: float `In` PGFloating
621− => Expression db params grp from (nullity float)
622+ => Expression commons schemas params grp from (nullity float)
622 -- ^ numerator
623 -- ^ numerator
623− -> Expression db params grp from (nullity float)
624+ -> Expression commons schemas params grp from (nullity float)
624 -- ^ denominator
625 -- ^ denominator
625− -> Expression db params grp from (nullity float)
626+ -> Expression commons schemas params grp from (nullity float)
626atan2_ y x = UnsafeExpression $
627atan2_ y x = UnsafeExpression $
627 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
628 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
@@ -635,9 +636,9 @@ atan2_ y x = UnsafeExpression $
636 :: TypeExpression schemas ty1
637 :: TypeExpression schemas ty1
637 -- ^ type to cast as
638 -- ^ type to cast as
638− -> Expression (commons :=> schemas) params grp from ty0
639+ -> Expression commons schemas params grp from ty0
639 -- ^ value to convert
640 -- ^ value to convert
640− -> Expression (commons :=> schemas) params grp from ty1
641+ -> Expression commons schemas params grp from ty1
641cast ty x = UnsafeExpression $ parenthesized $
642cast ty x = UnsafeExpression $ parenthesized $
642 renderSQL x <+> "::" <+> renderSQL ty
643 renderSQL x <+> "::" <+> renderSQL ty
@@ -645,136 +646,136 @@ cast ty x = UnsafeExpression $ parenthesized $
648−-- expression :: Expression db params grp from (nullity 'PGint2)
649+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
649-- expression = 5 `quot_` 2
650-- expression = 5 `quot_` 2
650-- in printSQL expression
651-- in printSQL expression
652-- (5 / 2)
653-- (5 / 2)
654 :: int `In` PGIntegral
655 :: int `In` PGIntegral
655− => Expression db params grp from (nullity int)
656+ => Expression commons schemas params grp from (nullity int)
656 -- ^ numerator
657 -- ^ numerator
657− -> Expression db params grp from (nullity int)
658+ -> Expression commons schemas params grp from (nullity int)
658 -- ^ denominator
659 -- ^ denominator
659− -> Expression db params grp from (nullity int)
660+ -> Expression commons schemas params grp from (nullity int)
660quot_ = unsafeBinaryOp "/"
661quot_ = unsafeBinaryOp "/"
662-- | remainder upon integer division
663-- | remainder upon integer division
666−-- expression :: Expression db params grp from (nullity 'PGint2)
667+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
667-- expression = 5 `rem_` 2
668-- expression = 5 `rem_` 2
668-- in printSQL expression
669-- in printSQL expression
670-- (5 % 2)
671-- (5 % 2)
672 :: int `In` PGIntegral
673 :: int `In` PGIntegral
673− => Expression db params grp from (nullity int)
674+ => Expression commons schemas params grp from (nullity int)
674 -- ^ numerator
675 -- ^ numerator
675− -> Expression db params grp from (nullity int)
676+ -> Expression commons schemas params grp from (nullity int)
676 -- ^ denominator
677 -- ^ denominator
677− -> Expression db params grp from (nullity int)
678+ -> Expression commons schemas params grp from (nullity int)
678rem_ = unsafeBinaryOp "%"
679rem_ = unsafeBinaryOp "%"
680-- | >>> :{
681-- | >>> :{
682−-- expression :: Expression db params grp from (nullity 'PGfloat4)
683+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
683-- expression = trunc pi
684-- expression = trunc pi
684-- in printSQL expression
685-- in printSQL expression
686-- trunc(pi())
687-- trunc(pi())
688 :: frac `In` PGFloating
689 :: frac `In` PGFloating
689− => Expression db params grp from (nullity frac)
690+ => Expression commons schemas params grp from (nullity frac)
690 -- ^ fractional number
691 -- ^ fractional number
691− -> Expression db params grp from (nullity frac)
692+ -> Expression commons schemas params grp from (nullity frac)
692trunc = unsafeFunction "trunc"
693trunc = unsafeFunction "trunc"
694-- | >>> :{
695-- | >>> :{
696−-- expression :: Expression db params grp from (nullity 'PGfloat4)
697+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
697-- expression = round_ pi
698-- expression = round_ pi
698-- in printSQL expression
699-- in printSQL expression
700-- round(pi())
701-- round(pi())
702 :: frac `In` PGFloating
703 :: frac `In` PGFloating
703− => Expression db params grp from (nullity frac)
704+ => Expression commons schemas params grp from (nullity frac)
704 -- ^ fractional number
705 -- ^ fractional number
705− -> Expression db params grp from (nullity frac)
706+ -> Expression commons schemas params grp from (nullity frac)
706round_ = unsafeFunction "round"
707round_ = unsafeFunction "round"
708-- | >>> :{
709-- | >>> :{
710−-- expression :: Expression db params grp from (nullity 'PGfloat4)
711+-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
711-- expression = ceiling_ pi
712-- expression = ceiling_ pi
712-- in printSQL expression
713-- in printSQL expression
714-- ceiling(pi())
715-- ceiling(pi())
716 :: frac `In` PGFloating
717 :: frac `In` PGFloating
717− => Expression db params grp from (nullity frac)
718+ => Expression commons schemas params grp from (nullity frac)
718 -- ^ fractional number
719 -- ^ fractional number
719− -> Expression db params grp from (nullity frac)
720+ -> Expression commons schemas params grp from (nullity frac)
720ceiling_ = unsafeFunction "ceiling"
721ceiling_ = unsafeFunction "ceiling"
722-- | A `Condition` is an `Expression`, which can evaluate
723-- | A `Condition` is an `Expression`, which can evaluate
723-- to `true`, `false` or `null_`. This is because SQL uses
724-- to `true`, `false` or `null_`. This is because SQL uses
724-- a three valued logic.
725-- a three valued logic.
725−type Condition db params grp from =
726+type Condition commons schemas params grp from =
726− Expression db params grp from ('Null 'PGbool)
727+ Expression commons schemas params grp from ('Null 'PGbool)
728-- | >>> printSQL true
729-- | >>> printSQL true
730−true :: Expression db params grp from (nullity 'PGbool)
731+true :: Expression commons schemas params grp from (nullity 'PGbool)
731true = UnsafeExpression "TRUE"
732true = UnsafeExpression "TRUE"
733-- | >>> printSQL false
734-- | >>> printSQL false
735−false :: Expression db params grp from (nullity 'PGbool)
736+false :: Expression commons schemas params grp from (nullity 'PGbool)
736false = UnsafeExpression "FALSE"
737false = UnsafeExpression "FALSE"
738-- | >>> printSQL $ not_ true
739-- | >>> printSQL $ not_ true
739-- (NOT TRUE)
740-- (NOT TRUE)
741− :: Expression db params grp from (nullity 'PGbool)
742+ :: Expression commons schemas params grp from (nullity 'PGbool)
742− -> Expression db params grp from (nullity 'PGbool)
743+ -> Expression commons schemas params grp from (nullity 'PGbool)
743not_ = unsafeUnaryOp "NOT"
744not_ = unsafeUnaryOp "NOT"
745-- | >>> printSQL $ true .&& false
746-- | >>> printSQL $ true .&& false
746-- (TRUE AND FALSE)
747-- (TRUE AND FALSE)
748− :: Expression db params grp from (nullity 'PGbool)
749+ :: Expression commons schemas params grp from (nullity 'PGbool)
749− -> Expression db params grp from (nullity 'PGbool)
750+ -> Expression commons schemas params grp from (nullity 'PGbool)
750− -> Expression db params grp from (nullity 'PGbool)
751+ -> Expression commons schemas params grp from (nullity 'PGbool)
751infixr 3 .&&
752infixr 3 .&&
752(.&&) = unsafeBinaryOp "AND"
753(.&&) = unsafeBinaryOp "AND"
754-- | >>> printSQL $ true .|| false
755-- | >>> printSQL $ true .|| false
755-- (TRUE OR FALSE)
756-- (TRUE OR FALSE)
757− :: Expression db params grp from (nullity 'PGbool)
758+ :: Expression commons schemas params grp from (nullity 'PGbool)
758− -> Expression db params grp from (nullity 'PGbool)
759+ -> Expression commons schemas params grp from (nullity 'PGbool)
759− -> Expression db params grp from (nullity 'PGbool)
760+ -> Expression commons schemas params grp from (nullity 'PGbool)
760infixr 2 .||
761infixr 2 .||
761(.||) = unsafeBinaryOp "OR"
762(.||) = unsafeBinaryOp "OR"
763-- | >>> :{
764-- | >>> :{
765−-- expression :: Expression db params grp from (nullity 'PGint2)
766+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
766-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
767-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
767-- in printSQL expression
768-- in printSQL expression
769-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
770-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
770caseWhenThenElse
771caseWhenThenElse
771− :: [ ( Condition db params grp from
772+ :: [ ( Condition commons schemas params grp from
772− , Expression db params grp from ty
773+ , Expression commons schemas params grp from ty
774 -- ^ whens and thens
775 -- ^ whens and thens
775− -> Expression db params grp from ty
776+ -> Expression commons schemas params grp from ty
776 -- ^ else
777 -- ^ else
777− -> Expression db params grp from ty
778+ -> Expression commons schemas params grp from ty
778caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
779caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
780 , mconcat
781 , mconcat
@@ -790,16 +791,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
791-- | >>> :{
792-- | >>> :{
793−-- expression :: Expression db params grp from (nullity 'PGint2)
794+-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
794-- expression = ifThenElse true 1 0
795-- expression = ifThenElse true 1 0
795-- in printSQL expression
796-- in printSQL expression
797-- CASE WHEN TRUE THEN 1 ELSE 0 END
798-- CASE WHEN TRUE THEN 1 ELSE 0 END
798ifThenElse
799ifThenElse
799− :: Condition db params grp from
800+ :: Condition commons schemas params grp from
800− -> Expression db params grp from ty -- ^ then
801+ -> Expression commons schemas params grp from ty -- ^ then
801− -> Expression db params grp from ty -- ^ else
802+ -> Expression commons schemas params grp from ty -- ^ else
802− -> Expression db params grp from ty
803+ -> Expression commons schemas params grp from ty
803ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
804ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
805-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
806-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -808,85 +809,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
808-- >>> printSQL $ true .== null_
809-- >>> printSQL $ true .== null_
809-- (TRUE = NULL)
810-- (TRUE = NULL)
811− :: Expression db params grp from (nullity0 ty) -- ^ lhs
812+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
812− -> Expression db params grp from (nullity1 ty) -- ^ rhs
813+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
813− -> Condition db params grp from
814+ -> Condition commons schemas params grp from
814(.==) = unsafeBinaryOp "="
815(.==) = unsafeBinaryOp "="
815infix 4 .==
816infix 4 .==
817-- | >>> printSQL $ true ./= null_
818-- | >>> printSQL $ true ./= null_
818-- (TRUE <> NULL)
819-- (TRUE <> NULL)
820− :: Expression db params grp from (nullity0 ty) -- ^ lhs
821+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
821− -> Expression db params grp from (nullity1 ty) -- ^ rhs
822+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
822− -> Condition db params grp from
823+ -> Condition commons schemas params grp from
823(./=) = unsafeBinaryOp "<>"
824(./=) = unsafeBinaryOp "<>"
824infix 4 ./=
825infix 4 ./=
826-- | >>> printSQL $ true .>= null_
827-- | >>> printSQL $ true .>= null_
827-- (TRUE >= NULL)
828-- (TRUE >= NULL)
829− :: Expression db params grp from (nullity0 ty) -- ^ lhs
830+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
830− -> Expression db params grp from (nullity1 ty) -- ^ rhs
831+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
831− -> Condition db params grp from
832+ -> Condition commons schemas params grp from
832(.>=) = unsafeBinaryOp ">="
833(.>=) = unsafeBinaryOp ">="
833infix 4 .>=
834infix 4 .>=
835-- | >>> printSQL $ true .< null_
836-- | >>> printSQL $ true .< null_
836-- (TRUE < NULL)
837-- (TRUE < NULL)
838− :: Expression db params grp from (nullity0 ty) -- ^ lhs
839+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
839− -> Expression db params grp from (nullity1 ty) -- ^ rhs
840+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
840− -> Condition db params grp from
841+ -> Condition commons schemas params grp from
841(.<) = unsafeBinaryOp "<"
842(.<) = unsafeBinaryOp "<"
842infix 4 .<
843infix 4 .<
844-- | >>> printSQL $ true .<= null_
845-- | >>> printSQL $ true .<= null_
845-- (TRUE <= NULL)
846-- (TRUE <= NULL)
847− :: Expression db params grp from (nullity0 ty) -- ^ lhs
848+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
848− -> Expression db params grp from (nullity1 ty) -- ^ rhs
849+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
849− -> Condition db params grp from
850+ -> Condition commons schemas params grp from
850(.<=) = unsafeBinaryOp "<="
851(.<=) = unsafeBinaryOp "<="
851infix 4 .<=
852infix 4 .<=
853-- | >>> printSQL $ true .> null_
854-- | >>> printSQL $ true .> null_
854-- (TRUE > NULL)
855-- (TRUE > NULL)
856− :: Expression db params grp from (nullity0 ty) -- ^ lhs
857+ :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
857− -> Expression db params grp from (nullity1 ty) -- ^ rhs
858+ -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
858− -> Condition db params grp from
859+ -> Condition commons schemas params grp from
859(.>) = unsafeBinaryOp ">"
860(.>) = unsafeBinaryOp ">"
860infix 4 .>
861infix 4 .>
862-- | >>> printSQL currentDate
863-- | >>> printSQL currentDate
863-- CURRENT_DATE
864-- CURRENT_DATE
864currentDate
865currentDate
865− :: Expression db params grp from (nullity 'PGdate)
866+ :: Expression commons schemas params grp from (nullity 'PGdate)
866currentDate = UnsafeExpression "CURRENT_DATE"
867currentDate = UnsafeExpression "CURRENT_DATE"
868-- | >>> printSQL currentTime
869-- | >>> printSQL currentTime
869-- CURRENT_TIME
870-- CURRENT_TIME
870currentTime
871currentTime
871− :: Expression db params grp from (nullity 'PGtimetz)
872+ :: Expression commons schemas params grp from (nullity 'PGtimetz)
872currentTime = UnsafeExpression "CURRENT_TIME"
873currentTime = UnsafeExpression "CURRENT_TIME"
874-- | >>> printSQL currentTimestamp
875-- | >>> printSQL currentTimestamp
875-- CURRENT_TIMESTAMP
876-- CURRENT_TIMESTAMP
876currentTimestamp
877currentTimestamp
877− :: Expression db params grp from (nullity 'PGtimestamptz)
878+ :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
878currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
879currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
880-- | >>> printSQL localTime
881-- | >>> printSQL localTime
881-- LOCALTIME
882-- LOCALTIME
883− :: Expression db params grp from (nullity 'PGtime)
884+ :: Expression commons schemas params grp from (nullity 'PGtime)
884localTime = UnsafeExpression "LOCALTIME"
885localTime = UnsafeExpression "LOCALTIME"
886-- | >>> printSQL localTimestamp
887-- | >>> printSQL localTimestamp
887-- LOCALTIMESTAMP
888-- LOCALTIMESTAMP
888localTimestamp
889localTimestamp
889− :: Expression db params grp from (nullity 'PGtimestamp)
890+ :: Expression commons schemas params grp from (nullity 'PGtimestamp)
890localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
891localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
892{-----------------------------------------
893{-----------------------------------------
@@ -894,7 +895,7 @@ text
894-----------------------------------------}
895-----------------------------------------}
896instance IsString
897instance IsString
897− (Expression db params grp from (nullity 'PGtext)) where
898+ (Expression commons schemas params grp from (nullity 'PGtext)) where
898 fromString str = UnsafeExpression $
899 fromString str = UnsafeExpression $
899 "E\'" <> fromString (escape =<< str) <> "\'"
900 "E\'" <> fromString (escape =<< str) <> "\'"
@@ -910,36 +911,36 @@ instance IsString
912instance Semigroup
913instance Semigroup
913− (Expression db params grp from (nullity 'PGtext)) where
914+ (Expression commons schemas params grp from (nullity 'PGtext)) where
914 (<>) = unsafeBinaryOp "||"
915 (<>) = unsafeBinaryOp "||"
916instance Monoid
917instance Monoid
917− (Expression db params grp from (nullity 'PGtext)) where
918+ (Expression commons schemas params grp from (nullity 'PGtext)) where
918 mempty = fromString ""
919 mempty = fromString ""
919 mappend = (<>)
920 mappend = (<>)
921-- | >>> printSQL $ lower "ARRRGGG"
922-- | >>> printSQL $ lower "ARRRGGG"
922-- lower(E'ARRRGGG')
923-- lower(E'ARRRGGG')
924− :: Expression db params grp from (nullity 'PGtext)
925+ :: Expression commons schemas params grp from (nullity 'PGtext)
925 -- ^ string to lower case
926 -- ^ string to lower case
926− -> Expression db params grp from (nullity 'PGtext)
927+ -> Expression commons schemas params grp from (nullity 'PGtext)
927lower = unsafeFunction "lower"
928lower = unsafeFunction "lower"
929-- | >>> printSQL $ upper "eeee"
930-- | >>> printSQL $ upper "eeee"
930-- upper(E'eeee')
931-- upper(E'eeee')
932− :: Expression db params grp from (nullity 'PGtext)
933+ :: Expression commons schemas params grp from (nullity 'PGtext)
933 -- ^ string to upper case
934 -- ^ string to upper case
934− -> Expression db params grp from (nullity 'PGtext)
935+ -> Expression commons schemas params grp from (nullity 'PGtext)
935upper = unsafeFunction "upper"
936upper = unsafeFunction "upper"
937-- | >>> printSQL $ charLength "four"
938-- | >>> printSQL $ charLength "four"
938-- char_length(E'four')
939-- char_length(E'four')
939charLength
940charLength
940− :: Expression db params grp from (nullity 'PGtext)
941+ :: Expression commons schemas params grp from (nullity 'PGtext)
941 -- ^ string to measure
942 -- ^ string to measure
942− -> Expression db params grp from (nullity 'PGint4)
943+ -> Expression commons schemas params grp from (nullity 'PGint4)
943charLength = unsafeFunction "char_length"
944charLength = unsafeFunction "char_length"
945-- | The `like` expression returns true if the @string@ matches
946-- | The `like` expression returns true if the @string@ matches
@@ -952,11 +953,11 @@ charLength = unsafeFunction "char_length"
952-- >>> printSQL $ "abc" `like` "a%"
953-- >>> printSQL $ "abc" `like` "a%"
953-- (E'abc' LIKE E'a%')
954-- (E'abc' LIKE E'a%')
955− :: Expression db params grp from (nullity 'PGtext)
956+ :: Expression commons schemas params grp from (nullity 'PGtext)
956 -- ^ string
957 -- ^ string
957− -> Expression db params grp from (nullity 'PGtext)
958+ -> Expression commons schemas params grp from (nullity 'PGtext)
958 -- ^ pattern
959 -- ^ pattern
959− -> Expression db params grp from (nullity 'PGbool)
960+ -> Expression commons schemas params grp from (nullity 'PGbool)
960like = unsafeBinaryOp "LIKE"
961like = unsafeBinaryOp "LIKE"
962-- | The key word ILIKE can be used instead of LIKE to make the
963-- | The key word ILIKE can be used instead of LIKE to make the
@@ -965,11 +966,11 @@ like = unsafeBinaryOp "LIKE"
965-- >>> printSQL $ "abc" `ilike` "a%"
966-- >>> printSQL $ "abc" `ilike` "a%"
966-- (E'abc' ILIKE E'a%')
967-- (E'abc' ILIKE E'a%')
968− :: Expression db params grp from (nullity 'PGtext)
969+ :: Expression commons schemas params grp from (nullity 'PGtext)
969 -- ^ string
970 -- ^ string
970− -> Expression db params grp from (nullity 'PGtext)
971+ -> Expression commons schemas params grp from (nullity 'PGtext)
971 -- ^ pattern
972 -- ^ pattern
972− -> Expression db params grp from (nullity 'PGbool)
973+ -> Expression commons schemas params grp from (nullity 'PGbool)
973ilike = unsafeBinaryOp "ILIKE"
974ilike = unsafeBinaryOp "ILIKE"
975{-----------------------------------------
976{-----------------------------------------
@@ -984,36 +985,36 @@ Table 9.44: json and jsonb operators
984-- | Get JSON value (object field or array element) at a key.
985-- | Get JSON value (object field or array element) at a key.
986 :: (json `In` PGJsonType, key `In` PGJsonKey)
987 :: (json `In` PGJsonType, key `In` PGJsonKey)
987− => Expression db params grp from (nullity json)
988+ => Expression commons schemas params grp from (nullity json)
988− -> Expression db params grp from (nullity key)
989+ -> Expression commons schemas params grp from (nullity key)
989− -> Expression db params grp from ('Null json)
990+ -> Expression commons schemas params grp from ('Null json)
990infixl 8 .->
991infixl 8 .->
991(.->) = unsafeBinaryOp "->"
992(.->) = unsafeBinaryOp "->"
993-- | Get JSON value (object field or array element) at a key, as text.
994-- | Get JSON value (object field or array element) at a key, as text.
995 :: (json `In` PGJsonType, key `In` PGJsonKey)
996 :: (json `In` PGJsonType, key `In` PGJsonKey)
996− => Expression db params grp from (nullity json)
997+ => Expression commons schemas params grp from (nullity json)
997− -> Expression db params grp from (nullity key)
998+ -> Expression commons schemas params grp from (nullity key)
998− -> Expression db params grp from ('Null 'PGtext)
999+ -> Expression commons schemas params grp from ('Null 'PGtext)
999infixl 8 .->>
1000infixl 8 .->>
1000(.->>) = unsafeBinaryOp "->>"
1001(.->>) = unsafeBinaryOp "->>"
1002-- | Get JSON value at a specified path.
1003-- | Get JSON value at a specified path.
1004 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1005 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1005− => Expression db params grp from (nullity json)
1006+ => Expression commons schemas params grp from (nullity json)
1006− -> Expression db params grp from (nullity path)
1007+ -> Expression commons schemas params grp from (nullity path)
1007− -> Expression db params grp from ('Null json)
1008+ -> Expression commons schemas params grp from ('Null json)
1008infixl 8 .#>
1009infixl 8 .#>
1009(.#>) = unsafeBinaryOp "#>"
1010(.#>) = unsafeBinaryOp "#>"
1011-- | Get JSON value at a specified path as text.
1012-- | Get JSON value at a specified path as text.
1013 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1014 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1014− => Expression db params grp from (nullity json)
1015+ => Expression commons schemas params grp from (nullity json)
1015− -> Expression db params grp from (nullity path)
1016+ -> Expression commons schemas params grp from (nullity path)
1016− -> Expression db params grp from ('Null 'PGtext)
1017+ -> Expression commons schemas params grp from ('Null 'PGtext)
1017infixl 8 .#>>
1018infixl 8 .#>>
1018(.#>>) = unsafeBinaryOp "#>>"
1019(.#>>) = unsafeBinaryOp "#>>"
@@ -1022,48 +1023,48 @@ infixl 8 .#>>
1022-- | Does the left JSON value contain the right JSON path/value entries at the
1023-- | Does the left JSON value contain the right JSON path/value entries at the
1023-- top level?
1024-- top level?
1025− :: Expression db params grp from (nullity 'PGjsonb)
1026+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1026− -> Expression db params grp from (nullity 'PGjsonb)
1027+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1027− -> Condition db params grp from
1028+ -> Condition commons schemas params grp from
1028infixl 9 .@>
1029infixl 9 .@>
1029(.@>) = unsafeBinaryOp "@>"
1030(.@>) = unsafeBinaryOp "@>"
1031-- | Are the left JSON path/value entries contained at the top level within the
1032-- | Are the left JSON path/value entries contained at the top level within the
1032-- right JSON value?
1033-- right JSON value?
1034− :: Expression db params grp from (nullity 'PGjsonb)
1035+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1035− -> Expression db params grp from (nullity 'PGjsonb)
1036+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1036− -> Condition db params grp from
1037+ -> Condition commons schemas params grp from
1037infixl 9 .<@
1038infixl 9 .<@
1038(.<@) = unsafeBinaryOp "<@"
1039(.<@) = unsafeBinaryOp "<@"
1040-- | Does the string exist as a top-level key within the JSON value?
1041-- | Does the string exist as a top-level key within the JSON value?
1042− :: Expression db params grp from (nullity 'PGjsonb)
1043+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1043− -> Expression db params grp from (nullity 'PGtext)
1044+ -> Expression commons schemas params grp from (nullity 'PGtext)
1044− -> Condition db params grp from
1045+ -> Condition commons schemas params grp from
1045infixl 9 .?
1046infixl 9 .?
1046(.?) = unsafeBinaryOp "?"
1047(.?) = unsafeBinaryOp "?"
1048-- | Do any of these array strings exist as top-level keys?
1049-- | Do any of these array strings exist as top-level keys?
1050− :: Expression db params grp from (nullity 'PGjsonb)
1051+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1051− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1052+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1052− -> Condition db params grp from
1053+ -> Condition commons schemas params grp from
1053infixl 9 .?|
1054infixl 9 .?|
1054(.?|) = unsafeBinaryOp "?|"
1055(.?|) = unsafeBinaryOp "?|"
1056-- | Do all of these array strings exist as top-level keys?
1057-- | Do all of these array strings exist as top-level keys?
1058− :: Expression db params grp from (nullity 'PGjsonb)
1059+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1059− -> Expression db params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1060+ -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1060− -> Condition db params grp from
1061+ -> Condition commons schemas params grp from
1061infixl 9 .?&
1062infixl 9 .?&
1062(.?&) = unsafeBinaryOp "?&"
1063(.?&) = unsafeBinaryOp "?&"
1064-- | Concatenate two jsonb values into a new jsonb value.
1065-- | Concatenate two jsonb values into a new jsonb value.
1066− Semigroup (Expression db from grouping param (nullity 'PGjsonb)) where
1067+ Semigroup (Expression commons schemas from grouping param (nullity 'PGjsonb)) where
1067 (<>) = unsafeBinaryOp "||"
1068 (<>) = unsafeBinaryOp "||"
1069-- | Delete a key or keys from a JSON object, or remove an array element.
1070-- | Delete a key or keys from a JSON object, or remove an array element.
@@ -1080,9 +1081,9 @@ instance
1080-- count from the end). Throws an error if top level container is not an array.
1081-- count from the end). Throws an error if top level container is not an array.
1082 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1083 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1083− => Expression db params grp from (nullity 'PGjsonb)
1084+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1084− -> Expression db params grp from (nullity key)
1085+ -> Expression commons schemas params grp from (nullity key)
1085− -> Expression db params grp from (nullity 'PGjsonb)
1086+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1086infixl 6 .-.
1087infixl 6 .-.
1087(.-.) = unsafeBinaryOp "-"
1088(.-.) = unsafeBinaryOp "-"
@@ -1090,9 +1091,9 @@ infixl 6 .-.
1090-- integers count from the end)
1091-- integers count from the end)
1092 :: PGTextArray "(#-.)" arrayty
1093 :: PGTextArray "(#-.)" arrayty
1093− => Expression db params grp from (nullity 'PGjsonb)
1094+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1094− -> Expression db params grp from (nullity arrayty)
1095+ -> Expression commons schemas params grp from (nullity arrayty)
1095− -> Expression db params grp from (nullity 'PGjsonb)
1096+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1096infixl 6 #-.
1097infixl 6 #-.
1097(#-.) = unsafeBinaryOp "#-"
1098(#-.) = unsafeBinaryOp "#-"
@@ -1103,14 +1104,14 @@ Table 9.45: JSON creation functions
1103-- | Literal binary JSON
1104-- | Literal binary JSON
1105 :: JSON.ToJSON x
1106 :: JSON.ToJSON x
1106− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjsonb)
1107+ => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
1107jsonbLit = cast jsonb . UnsafeExpression
1108jsonbLit = cast jsonb . UnsafeExpression
1108 . singleQuotedUtf8 . toStrict . JSON.encode
1109 . singleQuotedUtf8 . toStrict . JSON.encode
1110-- | Literal JSON
1111-- | Literal JSON
1112 :: JSON.ToJSON x
1113 :: JSON.ToJSON x
1113− => x -> Expression (commons :=> schemas) params grp from (nullity 'PGjson)
1114+ => x -> Expression commons schemas params grp from (nullity 'PGjson)
1114jsonLit = cast json . UnsafeExpression
1115jsonLit = cast json . UnsafeExpression
1115 . singleQuotedUtf8 . toStrict . JSON.encode
1116 . singleQuotedUtf8 . toStrict . JSON.encode
@@ -1121,8 +1122,8 @@ jsonLit = cast json . UnsafeExpression
1121-- number, a Boolean, or a null value, the text representation will be used, in
1122-- number, a Boolean, or a null value, the text representation will be used, in
1122-- such a fashion that it is a valid json value.
1123-- such a fashion that it is a valid json value.
1124− :: Expression db params grp from (nullity ty)
1125+ :: Expression commons schemas params grp from (nullity ty)
1125− -> Expression db params grp from (nullity 'PGjson)
1126+ -> Expression commons schemas params grp from (nullity 'PGjson)
1126toJson = unsafeFunction "to_json"
1127toJson = unsafeFunction "to_json"
1128-- | Returns the value as jsonb. Arrays and composites are converted
1129-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1132,43 +1133,43 @@ toJson = unsafeFunction "to_json"
1132-- number, a Boolean, or a null value, the text representation will be used, in
1133-- number, a Boolean, or a null value, the text representation will be used, in
1133-- such a fashion that it is a valid jsonb value.
1134-- such a fashion that it is a valid jsonb value.
1135− :: Expression db params grp from (nullity ty)
1136+ :: Expression commons schemas params grp from (nullity ty)
1136− -> Expression db params grp from (nullity 'PGjsonb)
1137+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1137toJsonb = unsafeFunction "to_jsonb"
1138toJsonb = unsafeFunction "to_jsonb"
1139-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1140-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1140-- becomes a JSON array of arrays.
1141-- becomes a JSON array of arrays.
1141arrayToJson
1142arrayToJson
1142 :: PGArray "arrayToJson" arr
1143 :: PGArray "arrayToJson" arr
1143− => Expression db params grp from (nullity arr)
1144+ => Expression commons schemas params grp from (nullity arr)
1144− -> Expression db params grp from (nullity 'PGjson)
1145+ -> Expression commons schemas params grp from (nullity 'PGjson)
1145arrayToJson = unsafeFunction "array_to_json"
1146arrayToJson = unsafeFunction "array_to_json"
1147-- | Returns the row as a JSON object.
1148-- | Returns the row as a JSON object.
1148rowToJson
1149rowToJson
1149− :: Expression db params grp from (nullity ('PGcomposite ty))
1150+ :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1150− -> Expression db params grp from (nullity 'PGjson)
1151+ -> Expression commons schemas params grp from (nullity 'PGjson)
1151rowToJson = unsafeFunction "row_to_json"
1152rowToJson = unsafeFunction "row_to_json"
1153-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1154-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1154-- argument list.
1155-- argument list.
1155jsonBuildArray
1156jsonBuildArray
1156 :: SListI elems
1157 :: SListI elems
1157− => NP (Expression db params grp from) elems
1158+ => NP (Expression commons schemas params grp from) elems
1158− -> Expression db params grp from (nullity 'PGjson)
1159+ -> Expression commons schemas params grp from (nullity 'PGjson)
1159jsonBuildArray = unsafeVariadicFunction "json_build_array"
1160jsonBuildArray = unsafeVariadicFunction "json_build_array"
1161-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1162-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1162-- variadic argument list.
1163-- variadic argument list.
1163jsonbBuildArray
1164jsonbBuildArray
1164 :: SListI elems
1165 :: SListI elems
1165− => NP (Expression db params grp from) elems
1166+ => NP (Expression commons schemas params grp from) elems
1166− -> Expression db params grp from (nullity 'PGjsonb)
1167+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1167jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1168jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1169unsafeRowFunction
1170unsafeRowFunction
1170 :: All Top elems
1171 :: All Top elems
1171− => NP (Aliased (Expression db params grp from)) elems
1172+ => NP (Aliased (Expression commons schemas params grp from)) elems
1172 -> [ByteString]
1173 -> [ByteString]
1173unsafeRowFunction =
1174unsafeRowFunction =
1174 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1175 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1183,8 +1184,8 @@ unsafeRowFunction =
1183-- and values.
1184-- and values.
1184jsonBuildObject
1185jsonBuildObject
1185 :: All Top elems
1186 :: All Top elems
1186− => NP (Aliased (Expression db params grp from)) elems
1187+ => NP (Aliased (Expression commons schemas params grp from)) elems
1187− -> Expression db params grp from (nullity 'PGjson)
1188+ -> Expression commons schemas params grp from (nullity 'PGjson)
1188jsonBuildObject
1189jsonBuildObject
1189 = unsafeFunction "json_build_object"
1190 = unsafeFunction "json_build_object"
1190 . UnsafeExpression
1191 . UnsafeExpression
@@ -1196,8 +1197,8 @@ jsonBuildObject
1196-- between text and values.
1197-- between text and values.
1197jsonbBuildObject
1198jsonbBuildObject
1198 :: All Top elems
1199 :: All Top elems
1199− => NP (Aliased (Expression db params grp from)) elems
1200+ => NP (Aliased (Expression commons schemas params grp from)) elems
1200− -> Expression db params grp from (nullity 'PGjsonb)
1201+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1201jsonbBuildObject
1202jsonbBuildObject
1202 = unsafeFunction "jsonb_build_object"
1203 = unsafeFunction "jsonb_build_object"
1203 . UnsafeExpression
1204 . UnsafeExpression
@@ -1210,8 +1211,8 @@ jsonbBuildObject
1210-- array has exactly two elements, which are taken as a key/value pair.
1211-- array has exactly two elements, which are taken as a key/value pair.
1211jsonObject
1212jsonObject
1212 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1213 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1213− => Expression db params grp from (nullity arr)
1214+ => Expression commons schemas params grp from (nullity arr)
1214− -> Expression db params grp from (nullity 'PGjson)
1215+ -> Expression commons schemas params grp from (nullity 'PGjson)
1215jsonObject = unsafeFunction "json_object"
1216jsonObject = unsafeFunction "json_object"
1217-- | Builds a binary JSON object out of a text array. The array must have either
1218-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1220,8 +1221,8 @@ jsonObject = unsafeFunction "json_object"
1220-- array has exactly two elements, which are taken as a key/value pair.
1221-- array has exactly two elements, which are taken as a key/value pair.
1221jsonbObject
1222jsonbObject
1222 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1223 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1223− => Expression db params grp from (nullity arr)
1224+ => Expression commons schemas params grp from (nullity arr)
1224− -> Expression db params grp from (nullity 'PGjsonb)
1225+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1225jsonbObject = unsafeFunction "jsonb_object"
1226jsonbObject = unsafeFunction "jsonb_object"
1227-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1228-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1229,9 +1230,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1229jsonZipObject
1230jsonZipObject
1230 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1231 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1231 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1232 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1232− => Expression db params grp from (nullity keysArray)
1233+ => Expression commons schemas params grp from (nullity keysArray)
1233− -> Expression db params grp from (nullity valuesArray)
1234+ -> Expression commons schemas params grp from (nullity valuesArray)
1234− -> Expression db params grp from (nullity 'PGjson)
1235+ -> Expression commons schemas params grp from (nullity 'PGjson)
1235jsonZipObject ks vs =
1236jsonZipObject ks vs =
1236 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1237 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
@@ -1241,9 +1242,9 @@ jsonZipObject ks vs =
1241jsonbZipObject
1242jsonbZipObject
1242 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1243 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1243 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1244 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1244− => Expression db params grp from (nullity keysArray)
1245+ => Expression commons schemas params grp from (nullity keysArray)
1245− -> Expression db params grp from (nullity valuesArray)
1246+ -> Expression commons schemas params grp from (nullity valuesArray)
1246− -> Expression db params grp from (nullity 'PGjsonb)
1247+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1247jsonbZipObject ks vs =
1248jsonbZipObject ks vs =
1248 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1249 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
@@ -1253,23 +1254,23 @@ Table 9.46: JSON processing functions
1254-- | Returns the number of elements in the outermost JSON array.
1255-- | Returns the number of elements in the outermost JSON array.
1255jsonArrayLength
1256jsonArrayLength
1256− :: Expression db params grp from (nullity 'PGjson)
1257+ :: Expression commons schemas params grp from (nullity 'PGjson)
1257− -> Expression db params grp from (nullity 'PGint4)
1258+ -> Expression commons schemas params grp from (nullity 'PGint4)
1258jsonArrayLength = unsafeFunction "json_array_length"
1259jsonArrayLength = unsafeFunction "json_array_length"
1260-- | Returns the number of elements in the outermost binary JSON array.
1261-- | Returns the number of elements in the outermost binary JSON array.
1261jsonbArrayLength
1262jsonbArrayLength
1262− :: Expression db params grp from (nullity 'PGjsonb)
1263+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1263− -> Expression db params grp from (nullity 'PGint4)
1264+ -> Expression commons schemas params grp from (nullity 'PGint4)
1264jsonbArrayLength = unsafeFunction "jsonb_array_length"
1265jsonbArrayLength = unsafeFunction "jsonb_array_length"
1266-- | Returns JSON value pointed to by the given path (equivalent to #>
1267-- | Returns JSON value pointed to by the given path (equivalent to #>
1267-- operator).
1268-- operator).
1268jsonExtractPath
1269jsonExtractPath
1269 :: SListI elems
1270 :: SListI elems
1270− => Expression db params grp from (nullity 'PGjson)
1271+ => Expression commons schemas params grp from (nullity 'PGjson)
1271− -> NP (Expression db params grp from) elems
1272+ -> NP (Expression commons schemas params grp from) elems
1272− -> Expression db params grp from (nullity 'PGjsonb)
1273+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1273jsonExtractPath x xs =
1274jsonExtractPath x xs =
1274 unsafeVariadicFunction "json_extract_path" (x :* xs)
1275 unsafeVariadicFunction "json_extract_path" (x :* xs)
@@ -1277,9 +1278,9 @@ jsonExtractPath x xs =
1277-- operator).
1278-- operator).
1278jsonbExtractPath
1279jsonbExtractPath
1279 :: SListI elems
1280 :: SListI elems
1280− => Expression db params grp from (nullity 'PGjsonb)
1281+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1281− -> NP (Expression db params grp from) elems
1282+ -> NP (Expression commons schemas params grp from) elems
1282− -> Expression db params grp from (nullity 'PGjsonb)
1283+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1283jsonbExtractPath x xs =
1284jsonbExtractPath x xs =
1284 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1285 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
@@ -1287,9 +1288,9 @@ jsonbExtractPath x xs =
1287-- operator), as text.
1288-- operator), as text.
1288jsonExtractPathAsText
1289jsonExtractPathAsText
1289 :: SListI elems
1290 :: SListI elems
1290− => Expression db params grp from (nullity 'PGjson)
1291+ => Expression commons schemas params grp from (nullity 'PGjson)
1291− -> NP (Expression db params grp from) elems
1292+ -> NP (Expression commons schemas params grp from) elems
1292− -> Expression db params grp from (nullity 'PGjson)
1293+ -> Expression commons schemas params grp from (nullity 'PGjson)
1293jsonExtractPathAsText x xs =
1294jsonExtractPathAsText x xs =
1294 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1295 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
@@ -1297,38 +1298,38 @@ jsonExtractPathAsText x xs =
1297-- operator), as text.
1298-- operator), as text.
1298jsonbExtractPathAsText
1299jsonbExtractPathAsText
1299 :: SListI elems
1300 :: SListI elems
1300− => Expression db params grp from (nullity 'PGjsonb)
1301+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1301− -> NP (Expression db params grp from) elems
1302+ -> NP (Expression commons schemas params grp from) elems
1302− -> Expression db params grp from (nullity 'PGjsonb)
1303+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1303jsonbExtractPathAsText x xs =
1304jsonbExtractPathAsText x xs =
1304 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1305 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1306-- | Returns the type of the outermost JSON value as a text string. Possible
1307-- | Returns the type of the outermost JSON value as a text string. Possible
1307-- types are object, array, string, number, boolean, and null.
1308-- types are object, array, string, number, boolean, and null.
1308jsonTypeof
1309jsonTypeof
1309− :: Expression db params grp from (nullity 'PGjson)
1310+ :: Expression commons schemas params grp from (nullity 'PGjson)
1310− -> Expression db params grp from (nullity 'PGtext)
1311+ -> Expression commons schemas params grp from (nullity 'PGtext)
1311jsonTypeof = unsafeFunction "json_typeof"
1312jsonTypeof = unsafeFunction "json_typeof"
1313-- | Returns the type of the outermost binary JSON value as a text string.
1314-- | Returns the type of the outermost binary JSON value as a text string.
1314-- Possible types are object, array, string, number, boolean, and null.
1315-- Possible types are object, array, string, number, boolean, and null.
1315jsonbTypeof
1316jsonbTypeof
1316− :: Expression db params grp from (nullity 'PGjsonb)
1317+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1317− -> Expression db params grp from (nullity 'PGtext)
1318+ -> Expression commons schemas params grp from (nullity 'PGtext)
1318jsonbTypeof = unsafeFunction "jsonb_typeof"
1319jsonbTypeof = unsafeFunction "jsonb_typeof"
1320-- | Returns its argument with all object fields that have null values omitted.
1321-- | Returns its argument with all object fields that have null values omitted.
1321-- Other null values are untouched.
1322-- Other null values are untouched.
1322jsonStripNulls
1323jsonStripNulls
1323− :: Expression db params grp from (nullity 'PGjson)
1324+ :: Expression commons schemas params grp from (nullity 'PGjson)
1324− -> Expression db params grp from (nullity 'PGjson)
1325+ -> Expression commons schemas params grp from (nullity 'PGjson)
1325jsonStripNulls = unsafeFunction "json_strip_nulls"
1326jsonStripNulls = unsafeFunction "json_strip_nulls"
1327-- | Returns its argument with all object fields that have null values omitted.
1328-- | Returns its argument with all object fields that have null values omitted.
1328-- Other null values are untouched.
1329-- Other null values are untouched.
1329jsonbStripNulls
1330jsonbStripNulls
1330− :: Expression db params grp from (nullity 'PGjsonb)
1331+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1331− -> Expression db params grp from (nullity 'PGjsonb)
1332+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1332jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1333jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1334-- | @ jsonbSet target path new_value create_missing @
1335-- | @ jsonbSet target path new_value create_missing @
@@ -1340,11 +1341,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1340-- arrays.
1341-- arrays.
1342 :: PGTextArray "jsonbSet" arr
1343 :: PGTextArray "jsonbSet" arr
1343− => Expression db params grp from (nullity 'PGjsonb)
1344+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1344− -> Expression db params grp from (nullity arr)
1345+ -> Expression commons schemas params grp from (nullity arr)
1345− -> Expression db params grp from (nullity 'PGjsonb)
1346+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1346− -> Maybe (Expression db params grp from (nullity 'PGbool))
1347+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1347− -> Expression db params grp from (nullity 'PGjsonb)
1348+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1348jsonbSet tgt path val createMissing = case createMissing of
1349jsonbSet tgt path val createMissing = case createMissing of
1349 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1350 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1350 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1351 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1359,19 +1360,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1359-- in path count from the end of JSON arrays.
1360-- in path count from the end of JSON arrays.
1360jsonbInsert
1361jsonbInsert
1361 :: PGTextArray "jsonbInsert" arr
1362 :: PGTextArray "jsonbInsert" arr
1362− => Expression db params grp from (nullity 'PGjsonb)
1363+ => Expression commons schemas params grp from (nullity 'PGjsonb)
1363− -> Expression db params grp from (nullity arr)
1364+ -> Expression commons schemas params grp from (nullity arr)
1364− -> Expression db params grp from (nullity 'PGjsonb)
1365+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1365− -> Maybe (Expression db params grp from (nullity 'PGbool))
1366+ -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1366− -> Expression db params grp from (nullity 'PGjsonb)
1367+ -> Expression commons schemas params grp from (nullity 'PGjsonb)
1367jsonbInsert tgt path val insertAfter = case insertAfter of
1368jsonbInsert tgt path val insertAfter = case insertAfter of
1368 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1369 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1369 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1370 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1371-- | Returns its argument as indented JSON text.
1372-- | Returns its argument as indented JSON text.
1372jsonbPretty
1373jsonbPretty
1373− :: Expression db params grp from (nullity 'PGjsonb)
1374+ :: Expression commons schemas params grp from (nullity 'PGjsonb)
1374− -> Expression db params grp from (nullity 'PGtext)
1375+ -> Expression commons schemas params grp from (nullity 'PGtext)
1375jsonbPretty = unsafeFunction "jsonb_pretty"
1376jsonbPretty = unsafeFunction "jsonb_pretty"
1377{-----------------------------------------
1378{-----------------------------------------
@@ -1381,54 +1382,54 @@ aggregation
1381-- | escape hatch to define aggregate functions
1382-- | escape hatch to define aggregate functions
1382unsafeAggregate
1383unsafeAggregate
1383 :: ByteString -- ^ aggregate function
1384 :: ByteString -- ^ aggregate function
1384− -> Expression db from 'Ungrouped params (xty)
1385+ -> Expression commons schemas from 'Ungrouped params (xty)
1385− -> Expression db from ('Grouped bys) params (yty)
1386+ -> Expression commons schemas from ('Grouped bys) params (yty)
1386unsafeAggregate fun x = UnsafeExpression $ mconcat
1387unsafeAggregate fun x = UnsafeExpression $ mconcat
1387 [fun, "(", renderSQL x, ")"]
1388 [fun, "(", renderSQL x, ")"]
1389-- | escape hatch to define aggregate functions over distinct values
1390-- | escape hatch to define aggregate functions over distinct values
1390unsafeAggregateDistinct
1391unsafeAggregateDistinct
1391 :: ByteString -- ^ aggregate function
1392 :: ByteString -- ^ aggregate function
1392− -> Expression db from 'Ungrouped params (xty)
1393+ -> Expression commons schemas from 'Ungrouped params (xty)
1393− -> Expression db from ('Grouped bys) params (yty)
1394+ -> Expression commons schemas from ('Grouped bys) params (yty)
1394unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1395unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1395 [fun, "(DISTINCT ", renderSQL x, ")"]
1396 [fun, "(DISTINCT ", renderSQL x, ")"]
1397-- | >>> :{
1398-- | >>> :{
1399−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1400+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1400-- expression = sum_ #col
1401-- expression = sum_ #col
1401-- in printSQL expression
1402-- in printSQL expression
1403-- sum("col")
1404-- sum("col")
1405 :: ty `In` PGNum
1406 :: ty `In` PGNum
1406− => Expression db from 'Ungrouped params (nullity ty)
1407+ => Expression commons schemas from 'Ungrouped params (nullity ty)
1407 -- ^ what to sum
1408 -- ^ what to sum
1408− -> Expression db from ('Grouped bys) params (nullity ty)
1409+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1409sum_ = unsafeAggregate "sum"
1410sum_ = unsafeAggregate "sum"
1411-- | >>> :{
1412-- | >>> :{
1413−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1414+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1414-- expression = sumDistinct #col
1415-- expression = sumDistinct #col
1415-- in printSQL expression
1416-- in printSQL expression
1417-- sum(DISTINCT "col")
1418-- sum(DISTINCT "col")
1418sumDistinct
1419sumDistinct
1419 :: ty `In` PGNum
1420 :: ty `In` PGNum
1420− => Expression db from 'Ungrouped params (nullity ty)
1421+ => Expression commons schemas from 'Ungrouped params (nullity ty)
1421 -- ^ what to sum
1422 -- ^ what to sum
1422− -> Expression db from ('Grouped bys) params (nullity ty)
1423+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1423sumDistinct = unsafeAggregateDistinct "sum"
1424sumDistinct = unsafeAggregateDistinct "sum"
1425-- | A constraint for `PGType`s that you can take averages of and the resulting
1426-- | A constraint for `PGType`s that you can take averages of and the resulting
1426-- `PGType`.
1427-- `PGType`.
1427class PGAvg ty avg | ty -> avg where
1428class PGAvg ty avg | ty -> avg where
1428 avg, avgDistinct
1429 avg, avgDistinct
1429− :: Expression db from 'Ungrouped params (nullity ty)
1430+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
1430 -- ^ what to average
1431 -- ^ what to average
1431− -> Expression db from ('Grouped bys) params (nullity avg)
1432+ -> Expression commons schemas from ('Grouped bys) params (nullity avg)
1432 avg = unsafeAggregate "avg"
1433 avg = unsafeAggregate "avg"
1433 avgDistinct = unsafeAggregateDistinct "avg"
1434 avgDistinct = unsafeAggregateDistinct "avg"
1434instance PGAvg 'PGint2 'PGnumeric
1435instance PGAvg 'PGint2 'PGnumeric
@@ -1441,110 +1442,110 @@ instance PGAvg 'PGinterval 'PGinterval
1442-- | >>> :{
1443-- | >>> :{
1444−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1445+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1445-- expression = bitAnd #col
1446-- expression = bitAnd #col
1446-- in printSQL expression
1447-- in printSQL expression
1448-- bit_and("col")
1449-- bit_and("col")
1450 :: int `In` PGIntegral
1451 :: int `In` PGIntegral
1451− => Expression db from 'Ungrouped params (nullity int)
1452+ => Expression commons schemas from 'Ungrouped params (nullity int)
1452 -- ^ what to aggregate
1453 -- ^ what to aggregate
1453− -> Expression db from ('Grouped bys) params (nullity int)
1454+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1454bitAnd = unsafeAggregate "bit_and"
1455bitAnd = unsafeAggregate "bit_and"
1456-- | >>> :{
1457-- | >>> :{
1458−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1459+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1459-- expression = bitOr #col
1460-- expression = bitOr #col
1460-- in printSQL expression
1461-- in printSQL expression
1462-- bit_or("col")
1463-- bit_or("col")
1464 :: int `In` PGIntegral
1465 :: int `In` PGIntegral
1465− => Expression db from 'Ungrouped params (nullity int)
1466+ => Expression commons schemas from 'Ungrouped params (nullity int)
1466 -- ^ what to aggregate
1467 -- ^ what to aggregate
1467− -> Expression db from ('Grouped bys) params (nullity int)
1468+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1468bitOr = unsafeAggregate "bit_or"
1469bitOr = unsafeAggregate "bit_or"
1470-- | >>> :{
1471-- | >>> :{
1472−-- expression :: Expression db params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1473+-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1473-- expression = bitAndDistinct #col
1474-- expression = bitAndDistinct #col
1474-- in printSQL expression
1475-- in printSQL expression
1476-- bit_and(DISTINCT "col")
1477-- bit_and(DISTINCT "col")
1477bitAndDistinct
1478bitAndDistinct
1478 :: int `In` PGIntegral
1479 :: int `In` PGIntegral
1479− => Expression db from 'Ungrouped params (nullity int)
1480+ => Expression commons schemas from 'Ungrouped params (nullity int)
1480 -- ^ what to aggregate
1481 -- ^ what to aggregate
1481− -> Expression db from ('Grouped bys) params (nullity int)
1482+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1482bitAndDistinct = unsafeAggregateDistinct "bit_and"
1483bitAndDistinct = unsafeAggregateDistinct "bit_and"
1484-- | >>> :{
1485-- | >>> :{
1486−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1487+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1487-- expression = bitOrDistinct #col
1488-- expression = bitOrDistinct #col
1488-- in printSQL expression
1489-- in printSQL expression
1490-- bit_or(DISTINCT "col")
1491-- bit_or(DISTINCT "col")
1491bitOrDistinct
1492bitOrDistinct
1492 :: int `In` PGIntegral
1493 :: int `In` PGIntegral
1493− => Expression db from 'Ungrouped params (nullity int)
1494+ => Expression commons schemas from 'Ungrouped params (nullity int)
1494 -- ^ what to aggregate
1495 -- ^ what to aggregate
1495− -> Expression db from ('Grouped bys) params (nullity int)
1496+ -> Expression commons schemas from ('Grouped bys) params (nullity int)
1496bitOrDistinct = unsafeAggregateDistinct "bit_or"
1497bitOrDistinct = unsafeAggregateDistinct "bit_or"
1498-- | >>> :{
1499-- | >>> :{
1500−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1501+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1501-- expression = boolAnd #col
1502-- expression = boolAnd #col
1502-- in printSQL expression
1503-- in printSQL expression
1504-- bool_and("col")
1505-- bool_and("col")
1506− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1507+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1507 -- ^ what to aggregate
1508 -- ^ what to aggregate
1508− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1509+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1509boolAnd = unsafeAggregate "bool_and"
1510boolAnd = unsafeAggregate "bool_and"
1511-- | >>> :{
1512-- | >>> :{
1513−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1514+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1514-- expression = boolOr #col
1515-- expression = boolOr #col
1515-- in printSQL expression
1516-- in printSQL expression
1517-- bool_or("col")
1518-- bool_or("col")
1519− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1520+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1520 -- ^ what to aggregate
1521 -- ^ what to aggregate
1521− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1522+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1522boolOr = unsafeAggregate "bool_or"
1523boolOr = unsafeAggregate "bool_or"
1524-- | >>> :{
1525-- | >>> :{
1526−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1527+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1527-- expression = boolAndDistinct #col
1528-- expression = boolAndDistinct #col
1528-- in printSQL expression
1529-- in printSQL expression
1530-- bool_and(DISTINCT "col")
1531-- bool_and(DISTINCT "col")
1531boolAndDistinct
1532boolAndDistinct
1532− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1533+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1533 -- ^ what to aggregate
1534 -- ^ what to aggregate
1534− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1535+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1535boolAndDistinct = unsafeAggregateDistinct "bool_and"
1536boolAndDistinct = unsafeAggregateDistinct "bool_and"
1537-- | >>> :{
1538-- | >>> :{
1539−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1540+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1540-- expression = boolOrDistinct #col
1541-- expression = boolOrDistinct #col
1541-- in printSQL expression
1542-- in printSQL expression
1543-- bool_or(DISTINCT "col")
1544-- bool_or(DISTINCT "col")
1544boolOrDistinct
1545boolOrDistinct
1545− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1546+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1546 -- ^ what to aggregate
1547 -- ^ what to aggregate
1547− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1548+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1548boolOrDistinct = unsafeAggregateDistinct "bool_or"
1549boolOrDistinct = unsafeAggregateDistinct "bool_or"
1550-- | A special aggregation that does not require an input
1551-- | A special aggregation that does not require an input
@@ -1552,70 +1553,70 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1552-- >>> printSQL countStar
1553-- >>> printSQL countStar
1553-- count(*)
1554-- count(*)
1554countStar
1555countStar
1555− :: Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1556+ :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1556countStar = UnsafeExpression $ "count(*)"
1557countStar = UnsafeExpression $ "count(*)"
1558-- | >>> :{
1559-- | >>> :{
1560−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1561+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1561-- expression = count #col
1562-- expression = count #col
1562-- in printSQL expression
1563-- in printSQL expression
1564-- count("col")
1565-- count("col")
1566− :: Expression db from 'Ungrouped params ty
1567+ :: Expression commons schemas from 'Ungrouped params ty
1567 -- ^ what to count
1568 -- ^ what to count
1568− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1569+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1569count = unsafeAggregate "count"
1570count = unsafeAggregate "count"
1571-- | >>> :{
1572-- | >>> :{
1573−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1574+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity ty]] ('NotNull 'PGint8)
1574-- expression = countDistinct #col
1575-- expression = countDistinct #col
1575-- in printSQL expression
1576-- in printSQL expression
1577-- count(DISTINCT "col")
1578-- count(DISTINCT "col")
1578countDistinct
1579countDistinct
1579− :: Expression db from 'Ungrouped params ty
1580+ :: Expression commons schemas from 'Ungrouped params ty
1580 -- ^ what to count
1581 -- ^ what to count
1581− -> Expression db from ('Grouped bys) params ('NotNull 'PGint8)
1582+ -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1582countDistinct = unsafeAggregateDistinct "count"
1583countDistinct = unsafeAggregateDistinct "count"
1584-- | synonym for `boolAnd`
1585-- | synonym for `boolAnd`
1586-- >>> :{
1587-- >>> :{
1588−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1589+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1589-- expression = every #col
1590-- expression = every #col
1590-- in printSQL expression
1591-- in printSQL expression
1592-- every("col")
1593-- every("col")
1594− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1595+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1595 -- ^ what to aggregate
1596 -- ^ what to aggregate
1596− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1597+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1597every = unsafeAggregate "every"
1598every = unsafeAggregate "every"
1599-- | synonym for `boolAndDistinct`
1600-- | synonym for `boolAndDistinct`
1601-- >>> :{
1602-- >>> :{
1603−-- expression :: Expression db params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1604+-- expression :: Expression commons schemas params (Grouped bys) '[tab ::: '["col" ::: nullity 'PGbool]] (nullity 'PGbool)
1604-- expression = everyDistinct #col
1605-- expression = everyDistinct #col
1605-- in printSQL expression
1606-- in printSQL expression
1607-- every(DISTINCT "col")
1608-- every(DISTINCT "col")
1608everyDistinct
1609everyDistinct
1609− :: Expression db from 'Ungrouped params (nullity 'PGbool)
1610+ :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1610 -- ^ what to aggregate
1611 -- ^ what to aggregate
1611− -> Expression db from ('Grouped bys) params (nullity 'PGbool)
1612+ -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1612everyDistinct = unsafeAggregateDistinct "every"
1613everyDistinct = unsafeAggregateDistinct "every"
1614-- | minimum and maximum aggregation
1615-- | minimum and maximum aggregation
1615max_, min_, maxDistinct, minDistinct
1616max_, min_, maxDistinct, minDistinct
1616− :: Expression db from 'Ungrouped params (nullity ty)
1617+ :: Expression commons schemas from 'Ungrouped params (nullity ty)
1617 -- ^ what to aggregate
1618 -- ^ what to aggregate
1618− -> Expression db from ('Grouped bys) params (nullity ty)
1619+ -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1619max_ = unsafeAggregate "max"
1620max_ = unsafeAggregate "max"
1620min_ = unsafeAggregate "min"
1621min_ = unsafeAggregate "min"
1621maxDistinct = unsafeAggregateDistinct "max"
1622maxDistinct = unsafeAggregateDistinct "max"