on dev help sign in
change Grouping location
96360bfEitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+3−3
@@ -298,7 +298,7 @@ check
298 , HasAll aliases (TableToRow table) subcolumns )
298 , HasAll aliases (TableToRow table) subcolumns )
299 => NP Alias aliases
299 => NP Alias aliases
300 -- ^ specify the subcolumns which are getting checked
300 -- ^ specify the subcolumns which are getting checked
301− -> (forall t. Condition '[] schemas '[] 'Ungrouped '[t ::: subcolumns])
301+ -> (forall t. Condition 'Ungrouped '[] schemas '[] '[t ::: subcolumns])
302 -- ^ a closed `Condition` on those subcolumns
302 -- ^ a closed `Condition` on those subcolumns
303 -> TableConstraintExpression sch tab schemas ('Check aliases)
303 -> TableConstraintExpression sch tab schemas ('Check aliases)
304check _cols condition = UnsafeTableConstraintExpression $
304check _cols condition = UnsafeTableConstraintExpression $
@@ -759,7 +759,7 @@ newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnT
759-- :}
759-- :}
760-- ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;
760-- ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;
761setDefault
761setDefault
762− :: Expression '[] schemas '[] 'Ungrouped '[] ty -- ^ default value to set
762+ :: Expression 'Ungrouped '[] schemas '[] '[] ty -- ^ default value to set
763 -> AlterColumn schemas (constraint :=> ty) ('Def :=> ty)
763 -> AlterColumn schemas (constraint :=> ty) ('Def :=> ty)
764setDefault expression = UnsafeAlterColumn $
764setDefault expression = UnsafeAlterColumn $
765 "SET DEFAULT" <+> renderExpression expression
765 "SET DEFAULT" <+> renderExpression expression
@@ -1010,7 +1010,7 @@ notNullable ty = UnsafeColumnTypeExpression $ renderSQL ty <+> "NOT NULL"
1010
1010
1011-- | used in `createTable` commands as a column constraint to give a default
1011-- | used in `createTable` commands as a column constraint to give a default
1012default_
1012default_
1013− :: Expression '[] schemas '[] 'Ungrouped '[] ty
1013+ :: Expression 'Ungrouped '[] schemas '[] '[] ty
1014 -> ColumnTypeExpression schemas ('NoDef :=> ty)
1014 -> ColumnTypeExpression schemas ('NoDef :=> ty)
1015 -> ColumnTypeExpression schemas ('Def :=> ty)
1015 -> ColumnTypeExpression schemas ('Def :=> ty)
1016default_ x ty = UnsafeColumnTypeExpression $
1016default_ x ty = UnsafeColumnTypeExpression $
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+334−334
@@ -239,16 +239,16 @@ values from primitive expression using arithmetic, logical,
239and other operations.
239and other operations.
240-}
240-}
241newtype Expression
241newtype Expression
242+ (grp :: Grouping)
242 (commons :: FromType)
243 (commons :: FromType)
243 (schemas :: SchemasType)
244 (schemas :: SchemasType)
244 (params :: [NullityType])
245 (params :: [NullityType])
245− (grp :: Grouping)
246 (from :: FromType)
246 (from :: FromType)
247 (ty :: NullityType)
247 (ty :: NullityType)
248 = UnsafeExpression { renderExpression :: ByteString }
248 = UnsafeExpression { renderExpression :: ByteString }
249 deriving (GHC.Generic,Show,Eq,Ord,NFData)
249 deriving (GHC.Generic,Show,Eq,Ord,NFData)
250
250
251−instance RenderSQL (Expression commons schemas params grp from ty) where
251+instance RenderSQL (Expression grp commons schemas params from ty) where
252 renderSQL = renderExpression
252 renderSQL = renderExpression
253
253
254{- | A `HasParameter` constraint is used to indicate a value that is
254{- | A `HasParameter` constraint is used to indicate a value that is
@@ -271,7 +271,7 @@ class KnownNat n => HasParameter
271 -- ($1 :: int4)
271 -- ($1 :: int4)
272 parameter
272 parameter
273 :: TypeExpression schemas ty
273 :: TypeExpression schemas ty
274− -> Expression commons schemas params grp from ty
274+ -> Expression grp commons schemas params from ty
275 parameter ty = UnsafeExpression $ parenthesized $
275 parameter ty = UnsafeExpression $ parenthesized $
276 "$" <> renderNat @n <+> "::"
276 "$" <> renderNat @n <+> "::"
277 <+> renderSQL ty
277 <+> renderSQL ty
@@ -288,32 +288,32 @@ instance {-# OVERLAPPABLE #-} (KnownNat n, HasParameter (n-1) params ty)
288param
288param
289 :: forall n commons schemas params from grp ty
289 :: forall n commons schemas params from grp ty
290 . (PGTyped schemas ty, HasParameter n params ty)
290 . (PGTyped schemas ty, HasParameter n params ty)
291− => Expression commons schemas params grp from ty -- ^ param
291+ => Expression grp commons schemas params from ty -- ^ param
292param = parameter @n (pgtype @schemas)
292param = parameter @n (pgtype @schemas)
293
293
294instance (HasUnique tab from row, Has col row ty)
294instance (HasUnique tab from row, Has col row ty)
295− => IsLabel col (Expression commons schemas params 'Ungrouped from ty) where
295+ => IsLabel col (Expression 'Ungrouped commons schemas params from ty) where
296 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
296 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
297instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
297instance (HasUnique tab from row, Has col row ty, column ~ (col ::: ty))
298 => IsLabel col
298 => IsLabel col
299− (Aliased (Expression commons schemas params 'Ungrouped from) column) where
299+ (Aliased (Expression 'Ungrouped commons schemas params from) column) where
300 fromLabel = fromLabel @col `As` Alias
300 fromLabel = fromLabel @col `As` Alias
301instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
301instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: ty])
302 => IsLabel col
302 => IsLabel col
303− (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
303+ (NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns) where
304 fromLabel = fromLabel @col :* Nil
304 fromLabel = fromLabel @col :* Nil
305
305
306instance (Has tab from row, Has col row ty)
306instance (Has tab from row, Has col row ty)
307− => IsQualified tab col (Expression commons schemas params 'Ungrouped from ty) where
307+ => IsQualified tab col (Expression 'Ungrouped commons schemas params from ty) where
308 tab ! col = UnsafeExpression $
308 tab ! col = UnsafeExpression $
309 renderSQL tab <> "." <> renderSQL col
309 renderSQL tab <> "." <> renderSQL col
310instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
310instance (Has tab from row, Has col row ty, column ~ (col ::: ty))
311 => IsQualified tab col
311 => IsQualified tab col
312− (Aliased (Expression commons schemas params 'Ungrouped from) column) where
312+ (Aliased (Expression 'Ungrouped commons schemas params from) column) where
313 tab ! col = tab ! col `As` col
313 tab ! col = tab ! col `As` col
314instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
314instance (Has tab from row, Has col row ty, columns ~ '[col ::: ty])
315 => IsQualified tab col
315 => IsQualified tab col
316− (NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns) where
316+ (NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns) where
317 tab ! col = tab ! col :* Nil
317 tab ! col = tab ! col :* Nil
318
318
319instance
319instance
@@ -321,7 +321,7 @@ instance
321 , Has col row ty
321 , Has col row ty
322 , GroupedBy tab col bys
322 , GroupedBy tab col bys
323 ) => IsLabel col
323 ) => IsLabel col
324− (Expression commons schemas params ('Grouped bys) from ty) where
324+ (Expression ('Grouped bys) commons schemas params from ty) where
325 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
325 fromLabel = UnsafeExpression $ renderSQL (Alias @col)
326instance
326instance
327 ( HasUnique tab from row
327 ( HasUnique tab from row
@@ -329,7 +329,7 @@ instance
329 , GroupedBy tab col bys
329 , GroupedBy tab col bys
330 , column ~ (col ::: ty)
330 , column ~ (col ::: ty)
331 ) => IsLabel col
331 ) => IsLabel col
332− (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
332+ (Aliased (Expression ('Grouped bys) commons schemas params from) column) where
333 fromLabel = fromLabel @col `As` Alias
333 fromLabel = fromLabel @col `As` Alias
334instance
334instance
335 ( HasUnique tab from row
335 ( HasUnique tab from row
@@ -337,7 +337,7 @@ instance
337 , GroupedBy tab col bys
337 , GroupedBy tab col bys
338 , columns ~ '[col ::: ty]
338 , columns ~ '[col ::: ty]
339 ) => IsLabel col
339 ) => IsLabel col
340− (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
340+ (NP (Aliased (Expression ('Grouped bys) commons schemas params from)) columns) where
341 fromLabel = fromLabel @col :* Nil
341 fromLabel = fromLabel @col :* Nil
342
342
343instance
343instance
@@ -345,7 +345,7 @@ instance
345 , Has col row ty
345 , Has col row ty
346 , GroupedBy tab col bys
346 , GroupedBy tab col bys
347 ) => IsQualified tab col
347 ) => IsQualified tab col
348− (Expression commons schemas params ('Grouped bys) from ty) where
348+ (Expression ('Grouped bys) commons schemas params from ty) where
349 tab ! col = UnsafeExpression $
349 tab ! col = UnsafeExpression $
350 renderSQL tab <> "." <> renderSQL col
350 renderSQL tab <> "." <> renderSQL col
351instance
351instance
@@ -354,7 +354,7 @@ instance
354 , GroupedBy tab col bys
354 , GroupedBy tab col bys
355 , column ~ (col ::: ty)
355 , column ~ (col ::: ty)
356 ) => IsQualified tab col
356 ) => IsQualified tab col
357− (Aliased (Expression commons schemas params ('Grouped bys) from) column) where
357+ (Aliased (Expression ('Grouped bys) commons schemas params from) column) where
358 tab ! col = tab ! col `As` col
358 tab ! col = tab ! col `As` col
359instance
359instance
360 ( Has tab from row
360 ( Has tab from row
@@ -362,7 +362,7 @@ instance
362 , GroupedBy tab col bys
362 , GroupedBy tab col bys
363 , columns ~ '[col ::: ty]
363 , columns ~ '[col ::: ty]
364 ) => IsQualified tab col
364 ) => IsQualified tab col
365− (NP (Aliased (Expression commons schemas params ('Grouped bys) from)) columns) where
365+ (NP (Aliased (Expression ('Grouped bys) commons schemas params from)) columns) where
366 tab ! col = tab ! col :* Nil
366 tab ! col = tab ! col :* Nil
367
367
368-- | analagous to `Nothing`
368-- | analagous to `Nothing`
@@ -386,11 +386,11 @@ notNull = UnsafeExpression . renderSQL
386-- >>> printSQL $ coalesce [null_, true] false
386-- >>> printSQL $ coalesce [null_, true] false
387-- COALESCE(NULL, TRUE, FALSE)
387-- COALESCE(NULL, TRUE, FALSE)
388coalesce
388coalesce
389− :: [Expression commons schemas params grp from ('Null ty)]
389+ :: [Expression grp commons schemas params from ('Null ty)]
390 -- ^ @NULL@s may be present
390 -- ^ @NULL@s may be present
391− -> Expression commons schemas params grp from ('NotNull ty)
391+ -> Expression grp commons schemas params from ('NotNull ty)
392 -- ^ @NULL@ is absent
392 -- ^ @NULL@ is absent
393− -> Expression commons schemas params grp from ('NotNull ty)
393+ -> Expression grp commons schemas params from ('NotNull ty)
394coalesce nullxs notNullx = UnsafeExpression $
394coalesce nullxs notNullx = UnsafeExpression $
395 "COALESCE" <> parenthesized (commaSeparated
395 "COALESCE" <> parenthesized (commaSeparated
396 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
396 ((renderSQL <$> nullxs) <> [renderSQL notNullx]))
@@ -400,26 +400,26 @@ coalesce nullxs notNullx = UnsafeExpression $
400-- >>> printSQL $ fromNull true null_
400-- >>> printSQL $ fromNull true null_
401-- COALESCE(NULL, TRUE)
401-- COALESCE(NULL, TRUE)
402fromNull
402fromNull
403− :: Expression commons schemas params grp from ('NotNull ty)
403+ :: Expression grp commons schemas params from ('NotNull ty)
404 -- ^ what to convert @NULL@ to
404 -- ^ what to convert @NULL@ to
405− -> Expression commons schemas params grp from ('Null ty)
405+ -> Expression grp commons schemas params from ('Null ty)
406− -> Expression commons schemas params grp from ('NotNull ty)
406+ -> Expression grp commons schemas params from ('NotNull ty)
407fromNull notNullx nullx = coalesce [nullx] notNullx
407fromNull notNullx nullx = coalesce [nullx] notNullx
408
408
409-- | >>> printSQL $ null_ & isNull
409-- | >>> printSQL $ null_ & isNull
410-- NULL IS NULL
410-- NULL IS NULL
411isNull
411isNull
412− :: Expression commons schemas params grp from ('Null ty)
412+ :: Expression grp commons schemas params from ('Null ty)
413 -- ^ possibly @NULL@
413 -- ^ possibly @NULL@
414− -> Condition commons schemas params grp from
414+ -> Condition grp commons schemas params from
415isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
415isNull x = UnsafeExpression $ renderSQL x <+> "IS NULL"
416
416
417-- | >>> printSQL $ null_ & isNotNull
417-- | >>> printSQL $ null_ & isNotNull
418-- NULL IS NOT NULL
418-- NULL IS NOT NULL
419isNotNull
419isNotNull
420− :: Expression commons schemas params grp from ('Null ty)
420+ :: Expression grp commons schemas params from ('Null ty)
421 -- ^ possibly @NULL@
421 -- ^ possibly @NULL@
422− -> Condition commons schemas params grp from
422+ -> Condition grp commons schemas params from
423isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
423isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
424
424
425-- | analagous to `maybe` using @IS NULL@
425-- | analagous to `maybe` using @IS NULL@
@@ -427,13 +427,13 @@ isNotNull x = UnsafeExpression $ renderSQL x <+> "IS NOT NULL"
427-- >>> printSQL $ matchNull true not_ null_
427-- >>> printSQL $ matchNull true not_ null_
428-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
428-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
429matchNull
429matchNull
430− :: Expression commons schemas params grp from (nullty)
430+ :: Expression grp commons schemas params from (nullty)
431 -- ^ what to convert @NULL@ to
431 -- ^ what to convert @NULL@ to
432− -> ( Expression commons schemas params grp from ('NotNull ty)
432+ -> ( Expression grp commons schemas params from ('NotNull ty)
433− -> Expression commons schemas params grp from (nullty) )
433+ -> Expression grp commons schemas params from (nullty) )
434 -- ^ function to perform when @NULL@ is absent
434 -- ^ function to perform when @NULL@ is absent
435− -> Expression commons schemas params grp from ('Null ty)
435+ -> Expression grp commons schemas params from ('Null ty)
436− -> Expression commons schemas params grp from (nullty)
436+ -> Expression grp commons schemas params from (nullty)
437matchNull y f x = ifThenElse (isNull x) y
437matchNull y f x = ifThenElse (isNull x) y
438 (f (UnsafeExpression (renderSQL x)))
438 (f (UnsafeExpression (renderSQL x)))
439
439
@@ -446,20 +446,20 @@ matchNull y f x = ifThenElse (isNull x) y
446NULL IF (FALSE, ($1 :: bool))
446NULL IF (FALSE, ($1 :: bool))
447-}
447-}
448nullIf
448nullIf
449− :: Expression commons schemas params grp from ('NotNull ty)
449+ :: Expression grp commons schemas params from ('NotNull ty)
450 -- ^ @NULL@ is absent
450 -- ^ @NULL@ is absent
451− -> Expression commons schemas params grp from ('NotNull ty)
451+ -> Expression grp commons schemas params from ('NotNull ty)
452 -- ^ @NULL@ is absent
452 -- ^ @NULL@ is absent
453− -> Expression commons schemas params grp from ('Null ty)
453+ -> Expression grp commons schemas params from ('Null ty)
454nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
454nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
455 (renderSQL x <> ", " <> renderSQL y)
455 (renderSQL x <> ", " <> renderSQL y)
456
456
457-- | >>> printSQL $ array [null_, false, true]
457-- | >>> printSQL $ array [null_, false, true]
458-- ARRAY[NULL, FALSE, TRUE]
458-- ARRAY[NULL, FALSE, TRUE]
459array
459array
460− :: [Expression commons schemas params grp from ty]
460+ :: [Expression grp commons schemas params from ty]
461 -- ^ array elements
461 -- ^ array elements
462− -> Expression commons schemas params grp from (nullity ('PGvararray ty))
462+ -> Expression grp commons schemas params from (nullity ('PGvararray ty))
463array xs = UnsafeExpression $
463array xs = UnsafeExpression $
464 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
464 "ARRAY[" <> commaSeparated (renderSQL <$> xs) <> "]"
465
465
@@ -467,13 +467,13 @@ array xs = UnsafeExpression $
467-- (ARRAY[NULL, FALSE, TRUE])[2]
467-- (ARRAY[NULL, FALSE, TRUE])[2]
468index
468index
469 :: Word64 -- ^ index
469 :: Word64 -- ^ index
470− -> Expression commons schemas params grp from (nullity ('PGvararray ty)) -- ^ array
470+ -> Expression grp commons schemas params from (nullity ('PGvararray ty)) -- ^ array
471− -> Expression commons schemas params grp from (NullifyType ty)
471+ -> Expression grp commons schemas params from (NullifyType ty)
472index n expr = UnsafeExpression $
472index n expr = UnsafeExpression $
473 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
473 parenthesized (renderSQL expr) <> "[" <> fromString (show n) <> "]"
474
474
475instance (KnownSymbol label, label `In` labels) => IsPGlabel label
475instance (KnownSymbol label, label `In` labels) => IsPGlabel label
476− (Expression commons schemas params grp from (nullity ('PGenum labels))) where
476+ (Expression grp commons schemas params from (nullity ('PGenum labels))) where
477 label = UnsafeExpression $ renderSQL (PGlabel @label)
477 label = UnsafeExpression $ renderSQL (PGlabel @label)
478
478
479-- | A row constructor is an expression that builds a row value
479-- | A row constructor is an expression that builds a row value
@@ -485,14 +485,14 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
485-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
485-- , "imaginary" ::: 'NotNull 'PGfloat8 ]
486-- :}
486-- :}
487--
487--
488−-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression commons schemas from grp params ('NotNull Complex)
488+-- >>> let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression grp commons schemas params from ('NotNull Complex)
489-- >>> printSQL i
489-- >>> printSQL i
490-- ROW(0, 1)
490-- ROW(0, 1)
491row
491row
492 :: SListI row
492 :: SListI row
493− => NP (Aliased (Expression commons schemas params grp from)) row
493+ => NP (Aliased (Expression grp commons schemas params from)) row
494 -- ^ zero or more expressions for the row field values
494 -- ^ zero or more expressions for the row field values
495− -> Expression commons schemas params grp from (nullity ('PGcomposite row))
495+ -> Expression grp commons schemas params from (nullity ('PGcomposite row))
496row exprs = UnsafeExpression $ "ROW" <> parenthesized
496row exprs = UnsafeExpression $ "ROW" <> parenthesized
497 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
497 (renderCommaSeparated (\ (expr `As` _) -> renderSQL expr) exprs)
498
498
@@ -512,18 +512,18 @@ field
512 , Has field row ty)
512 , Has field row ty)
513 => QualifiedAlias sch tydef -- ^ row type
513 => QualifiedAlias sch tydef -- ^ row type
514 -> Alias field -- ^ field name
514 -> Alias field -- ^ field name
515− -> Expression commons schemas params grp from ('NotNull ('PGcomposite row))
515+ -> Expression grp commons schemas params from ('NotNull ('PGcomposite row))
516− -> Expression commons schemas params grp from ty
516+ -> Expression grp commons schemas params from ty
517field td fld expr = UnsafeExpression $
517field td fld expr = UnsafeExpression $
518 parenthesized (renderSQL expr <> "::" <> renderSQL td)
518 parenthesized (renderSQL expr <> "::" <> renderSQL td)
519 <> "." <> renderSQL fld
519 <> "." <> renderSQL fld
520
520
521instance Semigroup
521instance Semigroup
522− (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
522+ (Expression grp commons schemas params from (nullity ('PGvararray ty))) where
523 (<>) = unsafeBinaryOp "||"
523 (<>) = unsafeBinaryOp "||"
524
524
525instance Monoid
525instance Monoid
526− (Expression commons schemas params grp from (nullity ('PGvararray ty))) where
526+ (Expression grp commons schemas params from (nullity ('PGvararray ty))) where
527 mempty = array []
527 mempty = array []
528 mappend = (<>)
528 mappend = (<>)
529
529
@@ -531,22 +531,22 @@ instance Monoid
531-- >>> printSQL expr
531-- >>> printSQL expr
532-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
532-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
533greatest
533greatest
534− :: Expression commons schemas params grp from (nullty)
534+ :: Expression grp commons schemas params from (nullty)
535 -- ^ needs at least 1 argument
535 -- ^ needs at least 1 argument
536− -> [Expression commons schemas params grp from (nullty)]
536+ -> [Expression grp commons schemas params from (nullty)]
537 -- ^ or more
537 -- ^ or more
538− -> Expression commons schemas params grp from (nullty)
538+ -> Expression grp commons schemas params from (nullty)
539greatest x xs = UnsafeExpression $ "GREATEST("
539greatest x xs = UnsafeExpression $ "GREATEST("
540 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
540 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
541
541
542-- | >>> printSQL $ least currentTimestamp [null_]
542-- | >>> printSQL $ least currentTimestamp [null_]
543-- LEAST(CURRENT_TIMESTAMP, NULL)
543-- LEAST(CURRENT_TIMESTAMP, NULL)
544least
544least
545− :: Expression commons schemas params grp from (nullty)
545+ :: Expression grp commons schemas params from (nullty)
546 -- ^ needs at least 1 argument
546 -- ^ needs at least 1 argument
547− -> [Expression commons schemas params grp from (nullty)]
547+ -> [Expression grp commons schemas params from (nullty)]
548 -- ^ or more
548 -- ^ or more
549− -> Expression commons schemas params grp from (nullty)
549+ -> Expression grp commons schemas params from (nullty)
550least x xs = UnsafeExpression $ "LEAST("
550least x xs = UnsafeExpression $ "LEAST("
551 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
551 <> commaSeparated (renderSQL <$> (x:xs)) <> ")"
552
552
@@ -555,9 +555,9 @@ least x xs = UnsafeExpression $ "LEAST("
555unsafeBinaryOp
555unsafeBinaryOp
556 :: ByteString
556 :: ByteString
557 -- ^ operator
557 -- ^ operator
558− -> Expression commons schemas params grp from (ty0)
558+ -> Expression grp commons schemas params from (ty0)
559− -> Expression commons schemas params grp from (ty1)
559+ -> Expression grp commons schemas params from (ty1)
560− -> Expression commons schemas params grp from (ty2)
560+ -> Expression grp commons schemas params from (ty2)
561unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
561unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
562 renderSQL x <+> op <+> renderSQL y
562 renderSQL x <+> op <+> renderSQL y
563
563
@@ -566,8 +566,8 @@ unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
566unsafeUnaryOp
566unsafeUnaryOp
567 :: ByteString
567 :: ByteString
568 -- ^ operator
568 -- ^ operator
569− -> Expression commons schemas params grp from (ty0)
569+ -> Expression grp commons schemas params from (ty0)
570− -> Expression commons schemas params grp from (ty1)
570+ -> Expression grp commons schemas params from (ty1)
571unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
571unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
572 op <+> renderSQL x
572 op <+> renderSQL x
573
573
@@ -576,8 +576,8 @@ unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
576unsafeFunction
576unsafeFunction
577 :: ByteString
577 :: ByteString
578 -- ^ function
578 -- ^ function
579− -> Expression commons schemas params grp from (xty)
579+ -> Expression grp commons schemas params from (xty)
580− -> Expression commons schemas params grp from (yty)
580+ -> Expression grp commons schemas params from (yty)
581unsafeFunction fun x = UnsafeExpression $
581unsafeFunction fun x = UnsafeExpression $
582 fun <> parenthesized (renderSQL x)
582 fun <> parenthesized (renderSQL x)
583
583
@@ -586,13 +586,13 @@ unsafeVariadicFunction
586 :: SListI elems
586 :: SListI elems
587 => ByteString
587 => ByteString
588 -- ^ function
588 -- ^ function
589− -> NP (Expression commons schemas params grp from) elems
589+ -> NP (Expression grp commons schemas params from) elems
590− -> Expression commons schemas params grp from ret
590+ -> Expression grp commons schemas params from ret
591unsafeVariadicFunction fun x = UnsafeExpression $
591unsafeVariadicFunction fun x = UnsafeExpression $
592 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
592 fun <> parenthesized (commaSeparated (hcollapse (hmap (K . renderSQL) x)))
593
593
594instance ty `In` PGNum
594instance ty `In` PGNum
595− => Num (Expression commons schemas params grp from (nullity ty)) where
595+ => Num (Expression grp commons schemas params from (nullity ty)) where
596 (+) = unsafeBinaryOp "+"
596 (+) = unsafeBinaryOp "+"
597 (-) = unsafeBinaryOp "-"
597 (-) = unsafeBinaryOp "-"
598 (*) = unsafeBinaryOp "*"
598 (*) = unsafeBinaryOp "*"
@@ -604,12 +604,12 @@ instance ty `In` PGNum
604 . show
604 . show
605
605
606instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
606instance (ty `In` PGNum, ty `In` PGFloating) => Fractional
607− (Expression commons schemas params grp from (nullity ty)) where
607+ (Expression grp commons schemas params from (nullity ty)) where
608 (/) = unsafeBinaryOp "/"
608 (/) = unsafeBinaryOp "/"
609 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
609 fromRational x = fromInteger (numerator x) / fromInteger (denominator x)
610
610
611instance (ty `In` PGNum, ty `In` PGFloating) => Floating
611instance (ty `In` PGNum, ty `In` PGFloating) => Floating
612− (Expression commons schemas params grp from (nullity ty)) where
612+ (Expression grp commons schemas params from (nullity ty)) where
613 pi = UnsafeExpression "pi()"
613 pi = UnsafeExpression "pi()"
614 exp = unsafeFunction "exp"
614 exp = unsafeFunction "exp"
615 log = unsafeFunction "ln"
615 log = unsafeFunction "ln"
@@ -632,18 +632,18 @@ instance (ty `In` PGNum, ty `In` PGFloating) => Floating
632
632
633-- | >>> :{
633-- | >>> :{
634-- let
634-- let
635−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
635+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
636-- expression = atan2_ pi 2
636-- expression = atan2_ pi 2
637-- in printSQL expression
637-- in printSQL expression
638-- :}
638-- :}
639-- atan2(pi(), 2)
639-- atan2(pi(), 2)
640atan2_
640atan2_
641 :: float `In` PGFloating
641 :: float `In` PGFloating
642− => Expression commons schemas params grp from (nullity float)
642+ => Expression grp commons schemas params from (nullity float)
643 -- ^ numerator
643 -- ^ numerator
644− -> Expression commons schemas params grp from (nullity float)
644+ -> Expression grp commons schemas params from (nullity float)
645 -- ^ denominator
645 -- ^ denominator
646− -> Expression commons schemas params grp from (nullity float)
646+ -> Expression grp commons schemas params from (nullity float)
647atan2_ y x = UnsafeExpression $
647atan2_ y x = UnsafeExpression $
648 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
648 "atan2(" <> renderSQL y <> ", " <> renderSQL x <> ")"
649
649
@@ -656,9 +656,9 @@ atan2_ y x = UnsafeExpression $
656cast
656cast
657 :: TypeExpression schemas ty1
657 :: TypeExpression schemas ty1
658 -- ^ type to cast as
658 -- ^ type to cast as
659− -> Expression commons schemas params grp from ty0
659+ -> Expression grp commons schemas params from ty0
660 -- ^ value to convert
660 -- ^ value to convert
661− -> Expression commons schemas params grp from ty1
661+ -> Expression grp commons schemas params from ty1
662cast ty x = UnsafeExpression $ parenthesized $
662cast ty x = UnsafeExpression $ parenthesized $
663 renderSQL x <+> "::" <+> renderSQL ty
663 renderSQL x <+> "::" <+> renderSQL ty
664
664
@@ -666,136 +666,136 @@ cast ty x = UnsafeExpression $ parenthesized $
666--
666--
667-- >>> :{
667-- >>> :{
668-- let
668-- let
669−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
669+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
670-- expression = 5 `quot_` 2
670-- expression = 5 `quot_` 2
671-- in printSQL expression
671-- in printSQL expression
672-- :}
672-- :}
673-- (5 / 2)
673-- (5 / 2)
674quot_
674quot_
675 :: int `In` PGIntegral
675 :: int `In` PGIntegral
676− => Expression commons schemas params grp from (nullity int)
676+ => Expression grp commons schemas params from (nullity int)
677 -- ^ numerator
677 -- ^ numerator
678− -> Expression commons schemas params grp from (nullity int)
678+ -> Expression grp commons schemas params from (nullity int)
679 -- ^ denominator
679 -- ^ denominator
680− -> Expression commons schemas params grp from (nullity int)
680+ -> Expression grp commons schemas params from (nullity int)
681quot_ = unsafeBinaryOp "/"
681quot_ = unsafeBinaryOp "/"
682
682
683-- | remainder upon integer division
683-- | remainder upon integer division
684--
684--
685-- >>> :{
685-- >>> :{
686-- let
686-- let
687−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
687+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
688-- expression = 5 `rem_` 2
688-- expression = 5 `rem_` 2
689-- in printSQL expression
689-- in printSQL expression
690-- :}
690-- :}
691-- (5 % 2)
691-- (5 % 2)
692rem_
692rem_
693 :: int `In` PGIntegral
693 :: int `In` PGIntegral
694− => Expression commons schemas params grp from (nullity int)
694+ => Expression grp commons schemas params from (nullity int)
695 -- ^ numerator
695 -- ^ numerator
696− -> Expression commons schemas params grp from (nullity int)
696+ -> Expression grp commons schemas params from (nullity int)
697 -- ^ denominator
697 -- ^ denominator
698− -> Expression commons schemas params grp from (nullity int)
698+ -> Expression grp commons schemas params from (nullity int)
699rem_ = unsafeBinaryOp "%"
699rem_ = unsafeBinaryOp "%"
700
700
701-- | >>> :{
701-- | >>> :{
702-- let
702-- let
703−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
703+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
704-- expression = trunc pi
704-- expression = trunc pi
705-- in printSQL expression
705-- in printSQL expression
706-- :}
706-- :}
707-- trunc(pi())
707-- trunc(pi())
708trunc
708trunc
709 :: frac `In` PGFloating
709 :: frac `In` PGFloating
710− => Expression commons schemas params grp from (nullity frac)
710+ => Expression grp commons schemas params from (nullity frac)
711 -- ^ fractional number
711 -- ^ fractional number
712− -> Expression commons schemas params grp from (nullity frac)
712+ -> Expression grp commons schemas params from (nullity frac)
713trunc = unsafeFunction "trunc"
713trunc = unsafeFunction "trunc"
714
714
715-- | >>> :{
715-- | >>> :{
716-- let
716-- let
717−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
717+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
718-- expression = round_ pi
718-- expression = round_ pi
719-- in printSQL expression
719-- in printSQL expression
720-- :}
720-- :}
721-- round(pi())
721-- round(pi())
722round_
722round_
723 :: frac `In` PGFloating
723 :: frac `In` PGFloating
724− => Expression commons schemas params grp from (nullity frac)
724+ => Expression grp commons schemas params from (nullity frac)
725 -- ^ fractional number
725 -- ^ fractional number
726− -> Expression commons schemas params grp from (nullity frac)
726+ -> Expression grp commons schemas params from (nullity frac)
727round_ = unsafeFunction "round"
727round_ = unsafeFunction "round"
728
728
729-- | >>> :{
729-- | >>> :{
730-- let
730-- let
731−-- expression :: Expression commons schemas params grp from (nullity 'PGfloat4)
731+-- expression :: Expression grp commons schemas params from (nullity 'PGfloat4)
732-- expression = ceiling_ pi
732-- expression = ceiling_ pi
733-- in printSQL expression
733-- in printSQL expression
734-- :}
734-- :}
735-- ceiling(pi())
735-- ceiling(pi())
736ceiling_
736ceiling_
737 :: frac `In` PGFloating
737 :: frac `In` PGFloating
738− => Expression commons schemas params grp from (nullity frac)
738+ => Expression grp commons schemas params from (nullity frac)
739 -- ^ fractional number
739 -- ^ fractional number
740− -> Expression commons schemas params grp from (nullity frac)
740+ -> Expression grp commons schemas params from (nullity frac)
741ceiling_ = unsafeFunction "ceiling"
741ceiling_ = unsafeFunction "ceiling"
742
742
743-- | A `Condition` is an `Expression`, which can evaluate
743-- | A `Condition` is an `Expression`, which can evaluate
744-- to `true`, `false` or `null_`. This is because SQL uses
744-- to `true`, `false` or `null_`. This is because SQL uses
745-- a three valued logic.
745-- a three valued logic.
746−type Condition commons schemas params grp from =
746+type Condition grp commons schemas params from =
747− Expression commons schemas params grp from ('Null 'PGbool)
747+ Expression grp commons schemas params from ('Null 'PGbool)
748
748
749-- | >>> printSQL true
749-- | >>> printSQL true
750-- TRUE
750-- TRUE
751−true :: Expression commons schemas params grp from (nullity 'PGbool)
751+true :: Expression grp commons schemas params from (nullity 'PGbool)
752true = UnsafeExpression "TRUE"
752true = UnsafeExpression "TRUE"
753
753
754-- | >>> printSQL false
754-- | >>> printSQL false
755-- FALSE
755-- FALSE
756−false :: Expression commons schemas params grp from (nullity 'PGbool)
756+false :: Expression grp commons schemas params from (nullity 'PGbool)
757false = UnsafeExpression "FALSE"
757false = UnsafeExpression "FALSE"
758
758
759-- | >>> printSQL $ not_ true
759-- | >>> printSQL $ not_ true
760-- (NOT TRUE)
760-- (NOT TRUE)
761not_
761not_
762− :: Expression commons schemas params grp from (nullity 'PGbool)
762+ :: Expression grp commons schemas params from (nullity 'PGbool)
763− -> Expression commons schemas params grp from (nullity 'PGbool)
763+ -> Expression grp commons schemas params from (nullity 'PGbool)
764not_ = unsafeUnaryOp "NOT"
764not_ = unsafeUnaryOp "NOT"
765
765
766-- | >>> printSQL $ true .&& false
766-- | >>> printSQL $ true .&& false
767-- (TRUE AND FALSE)
767-- (TRUE AND FALSE)
768(.&&)
768(.&&)
769− :: Expression commons schemas params grp from (nullity 'PGbool)
769+ :: Expression grp commons schemas params from (nullity 'PGbool)
770− -> Expression commons schemas params grp from (nullity 'PGbool)
770+ -> Expression grp commons schemas params from (nullity 'PGbool)
771− -> Expression commons schemas params grp from (nullity 'PGbool)
771+ -> Expression grp commons schemas params from (nullity 'PGbool)
772infixr 3 .&&
772infixr 3 .&&
773(.&&) = unsafeBinaryOp "AND"
773(.&&) = unsafeBinaryOp "AND"
774
774
775-- | >>> printSQL $ true .|| false
775-- | >>> printSQL $ true .|| false
776-- (TRUE OR FALSE)
776-- (TRUE OR FALSE)
777(.||)
777(.||)
778− :: Expression commons schemas params grp from (nullity 'PGbool)
778+ :: Expression grp commons schemas params from (nullity 'PGbool)
779− -> Expression commons schemas params grp from (nullity 'PGbool)
779+ -> Expression grp commons schemas params from (nullity 'PGbool)
780− -> Expression commons schemas params grp from (nullity 'PGbool)
780+ -> Expression grp commons schemas params from (nullity 'PGbool)
781infixr 2 .||
781infixr 2 .||
782(.||) = unsafeBinaryOp "OR"
782(.||) = unsafeBinaryOp "OR"
783
783
784-- | >>> :{
784-- | >>> :{
785-- let
785-- let
786−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
786+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
787-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
787-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
788-- in printSQL expression
788-- in printSQL expression
789-- :}
789-- :}
790-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
790-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
791caseWhenThenElse
791caseWhenThenElse
792− :: [ ( Condition commons schemas params grp from
792+ :: [ ( Condition grp commons schemas params from
793− , Expression commons schemas params grp from ty
793+ , Expression grp commons schemas params from ty
794 ) ]
794 ) ]
795 -- ^ whens and thens
795 -- ^ whens and thens
796− -> Expression commons schemas params grp from ty
796+ -> Expression grp commons schemas params from ty
797 -- ^ else
797 -- ^ else
798− -> Expression commons schemas params grp from ty
798+ -> Expression grp commons schemas params from ty
799caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
799caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
800 [ "CASE"
800 [ "CASE"
801 , mconcat
801 , mconcat
@@ -811,16 +811,16 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
811
811
812-- | >>> :{
812-- | >>> :{
813-- let
813-- let
814−-- expression :: Expression commons schemas params grp from (nullity 'PGint2)
814+-- expression :: Expression grp commons schemas params from (nullity 'PGint2)
815-- expression = ifThenElse true 1 0
815-- expression = ifThenElse true 1 0
816-- in printSQL expression
816-- in printSQL expression
817-- :}
817-- :}
818-- CASE WHEN TRUE THEN 1 ELSE 0 END
818-- CASE WHEN TRUE THEN 1 ELSE 0 END
819ifThenElse
819ifThenElse
820− :: Condition commons schemas params grp from
820+ :: Condition grp commons schemas params from
821− -> Expression commons schemas params grp from ty -- ^ then
821+ -> Expression grp commons schemas params from ty -- ^ then
822− -> Expression commons schemas params grp from ty -- ^ else
822+ -> Expression grp commons schemas params from ty -- ^ else
823− -> Expression commons schemas params grp from ty
823+ -> Expression grp commons schemas params from ty
824ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
824ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
825
825
826-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
826-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
@@ -829,85 +829,85 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
829-- >>> printSQL $ true .== null_
829-- >>> printSQL $ true .== null_
830-- (TRUE = NULL)
830-- (TRUE = NULL)
831(.==)
831(.==)
832− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
832+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
833− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
833+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
834− -> Condition commons schemas params grp from
834+ -> Condition grp commons schemas params from
835(.==) = unsafeBinaryOp "="
835(.==) = unsafeBinaryOp "="
836infix 4 .==
836infix 4 .==
837
837
838-- | >>> printSQL $ true ./= null_
838-- | >>> printSQL $ true ./= null_
839-- (TRUE <> NULL)
839-- (TRUE <> NULL)
840(./=)
840(./=)
841− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
841+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
842− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
842+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
843− -> Condition commons schemas params grp from
843+ -> Condition grp commons schemas params from
844(./=) = unsafeBinaryOp "<>"
844(./=) = unsafeBinaryOp "<>"
845infix 4 ./=
845infix 4 ./=
846
846
847-- | >>> printSQL $ true .>= null_
847-- | >>> printSQL $ true .>= null_
848-- (TRUE >= NULL)
848-- (TRUE >= NULL)
849(.>=)
849(.>=)
850− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
850+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
851− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
851+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
852− -> Condition commons schemas params grp from
852+ -> Condition grp commons schemas params from
853(.>=) = unsafeBinaryOp ">="
853(.>=) = unsafeBinaryOp ">="
854infix 4 .>=
854infix 4 .>=
855
855
856-- | >>> printSQL $ true .< null_
856-- | >>> printSQL $ true .< null_
857-- (TRUE < NULL)
857-- (TRUE < NULL)
858(.<)
858(.<)
859− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
859+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
860− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
860+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
861− -> Condition commons schemas params grp from
861+ -> Condition grp commons schemas params from
862(.<) = unsafeBinaryOp "<"
862(.<) = unsafeBinaryOp "<"
863infix 4 .<
863infix 4 .<
864
864
865-- | >>> printSQL $ true .<= null_
865-- | >>> printSQL $ true .<= null_
866-- (TRUE <= NULL)
866-- (TRUE <= NULL)
867(.<=)
867(.<=)
868− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
868+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
869− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
869+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
870− -> Condition commons schemas params grp from
870+ -> Condition grp commons schemas params from
871(.<=) = unsafeBinaryOp "<="
871(.<=) = unsafeBinaryOp "<="
872infix 4 .<=
872infix 4 .<=
873
873
874-- | >>> printSQL $ true .> null_
874-- | >>> printSQL $ true .> null_
875-- (TRUE > NULL)
875-- (TRUE > NULL)
876(.>)
876(.>)
877− :: Expression commons schemas params grp from (nullity0 ty) -- ^ lhs
877+ :: Expression grp commons schemas params from (nullity0 ty) -- ^ lhs
878− -> Expression commons schemas params grp from (nullity1 ty) -- ^ rhs
878+ -> Expression grp commons schemas params from (nullity1 ty) -- ^ rhs
879− -> Condition commons schemas params grp from
879+ -> Condition grp commons schemas params from
880(.>) = unsafeBinaryOp ">"
880(.>) = unsafeBinaryOp ">"
881infix 4 .>
881infix 4 .>
882
882
883-- | >>> printSQL currentDate
883-- | >>> printSQL currentDate
884-- CURRENT_DATE
884-- CURRENT_DATE
885currentDate
885currentDate
886− :: Expression commons schemas params grp from (nullity 'PGdate)
886+ :: Expression grp commons schemas params from (nullity 'PGdate)
887currentDate = UnsafeExpression "CURRENT_DATE"
887currentDate = UnsafeExpression "CURRENT_DATE"
888
888
889-- | >>> printSQL currentTime
889-- | >>> printSQL currentTime
890-- CURRENT_TIME
890-- CURRENT_TIME
891currentTime
891currentTime
892− :: Expression commons schemas params grp from (nullity 'PGtimetz)
892+ :: Expression grp commons schemas params from (nullity 'PGtimetz)
893currentTime = UnsafeExpression "CURRENT_TIME"
893currentTime = UnsafeExpression "CURRENT_TIME"
894
894
895-- | >>> printSQL currentTimestamp
895-- | >>> printSQL currentTimestamp
896-- CURRENT_TIMESTAMP
896-- CURRENT_TIMESTAMP
897currentTimestamp
897currentTimestamp
898− :: Expression commons schemas params grp from (nullity 'PGtimestamptz)
898+ :: Expression grp commons schemas params from (nullity 'PGtimestamptz)
899currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
899currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
900
900
901-- | >>> printSQL localTime
901-- | >>> printSQL localTime
902-- LOCALTIME
902-- LOCALTIME
903localTime
903localTime
904− :: Expression commons schemas params grp from (nullity 'PGtime)
904+ :: Expression grp commons schemas params from (nullity 'PGtime)
905localTime = UnsafeExpression "LOCALTIME"
905localTime = UnsafeExpression "LOCALTIME"
906
906
907-- | >>> printSQL localTimestamp
907-- | >>> printSQL localTimestamp
908-- LOCALTIMESTAMP
908-- LOCALTIMESTAMP
909localTimestamp
909localTimestamp
910− :: Expression commons schemas params grp from (nullity 'PGtimestamp)
910+ :: Expression grp commons schemas params from (nullity 'PGtimestamp)
911localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
911localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
912
912
913{-----------------------------------------
913{-----------------------------------------
@@ -915,7 +915,7 @@ text
915-----------------------------------------}
915-----------------------------------------}
916
916
917instance IsString
917instance IsString
918− (Expression commons schemas params grp from (nullity 'PGtext)) where
918+ (Expression grp commons schemas params from (nullity 'PGtext)) where
919 fromString str = UnsafeExpression $
919 fromString str = UnsafeExpression $
920 "E\'" <> fromString (escape =<< str) <> "\'"
920 "E\'" <> fromString (escape =<< str) <> "\'"
921 where
921 where
@@ -931,36 +931,36 @@ instance IsString
931 c -> [c]
931 c -> [c]
932
932
933instance Semigroup
933instance Semigroup
934− (Expression commons schemas params grp from (nullity 'PGtext)) where
934+ (Expression grp commons schemas params from (nullity 'PGtext)) where
935 (<>) = unsafeBinaryOp "||"
935 (<>) = unsafeBinaryOp "||"
936
936
937instance Monoid
937instance Monoid
938− (Expression commons schemas params grp from (nullity 'PGtext)) where
938+ (Expression grp commons schemas params from (nullity 'PGtext)) where
939 mempty = fromString ""
939 mempty = fromString ""
940 mappend = (<>)
940 mappend = (<>)
941
941
942-- | >>> printSQL $ lower "ARRRGGG"
942-- | >>> printSQL $ lower "ARRRGGG"
943-- lower(E'ARRRGGG')
943-- lower(E'ARRRGGG')
944lower
944lower
945− :: Expression commons schemas params grp from (nullity 'PGtext)
945+ :: Expression grp commons schemas params from (nullity 'PGtext)
946 -- ^ string to lower case
946 -- ^ string to lower case
947− -> Expression commons schemas params grp from (nullity 'PGtext)
947+ -> Expression grp commons schemas params from (nullity 'PGtext)
948lower = unsafeFunction "lower"
948lower = unsafeFunction "lower"
949
949
950-- | >>> printSQL $ upper "eeee"
950-- | >>> printSQL $ upper "eeee"
951-- upper(E'eeee')
951-- upper(E'eeee')
952upper
952upper
953− :: Expression commons schemas params grp from (nullity 'PGtext)
953+ :: Expression grp commons schemas params from (nullity 'PGtext)
954 -- ^ string to upper case
954 -- ^ string to upper case
955− -> Expression commons schemas params grp from (nullity 'PGtext)
955+ -> Expression grp commons schemas params from (nullity 'PGtext)
956upper = unsafeFunction "upper"
956upper = unsafeFunction "upper"
957
957
958-- | >>> printSQL $ charLength "four"
958-- | >>> printSQL $ charLength "four"
959-- char_length(E'four')
959-- char_length(E'four')
960charLength
960charLength
961− :: Expression commons schemas params grp from (nullity 'PGtext)
961+ :: Expression grp commons schemas params from (nullity 'PGtext)
962 -- ^ string to measure
962 -- ^ string to measure
963− -> Expression commons schemas params grp from (nullity 'PGint4)
963+ -> Expression grp commons schemas params from (nullity 'PGint4)
964charLength = unsafeFunction "char_length"
964charLength = unsafeFunction "char_length"
965
965
966-- | The `like` expression returns true if the @string@ matches
966-- | The `like` expression returns true if the @string@ matches
@@ -973,11 +973,11 @@ charLength = unsafeFunction "char_length"
973-- >>> printSQL $ "abc" `like` "a%"
973-- >>> printSQL $ "abc" `like` "a%"
974-- (E'abc' LIKE E'a%')
974-- (E'abc' LIKE E'a%')
975like
975like
976− :: Expression commons schemas params grp from (nullity 'PGtext)
976+ :: Expression grp commons schemas params from (nullity 'PGtext)
977 -- ^ string
977 -- ^ string
978− -> Expression commons schemas params grp from (nullity 'PGtext)
978+ -> Expression grp commons schemas params from (nullity 'PGtext)
979 -- ^ pattern
979 -- ^ pattern
980− -> Expression commons schemas params grp from (nullity 'PGbool)
980+ -> Expression grp commons schemas params from (nullity 'PGbool)
981like = unsafeBinaryOp "LIKE"
981like = unsafeBinaryOp "LIKE"
982
982
983-- | The key word ILIKE can be used instead of LIKE to make the
983-- | The key word ILIKE can be used instead of LIKE to make the
@@ -986,11 +986,11 @@ like = unsafeBinaryOp "LIKE"
986-- >>> printSQL $ "abc" `ilike` "a%"
986-- >>> printSQL $ "abc" `ilike` "a%"
987-- (E'abc' ILIKE E'a%')
987-- (E'abc' ILIKE E'a%')
988ilike
988ilike
989− :: Expression commons schemas params grp from (nullity 'PGtext)
989+ :: Expression grp commons schemas params from (nullity 'PGtext)
990 -- ^ string
990 -- ^ string
991− -> Expression commons schemas params grp from (nullity 'PGtext)
991+ -> Expression grp commons schemas params from (nullity 'PGtext)
992 -- ^ pattern
992 -- ^ pattern
993− -> Expression commons schemas params grp from (nullity 'PGbool)
993+ -> Expression grp commons schemas params from (nullity 'PGbool)
994ilike = unsafeBinaryOp "ILIKE"
994ilike = unsafeBinaryOp "ILIKE"
995
995
996{-----------------------------------------
996{-----------------------------------------
@@ -1005,36 +1005,36 @@ Table 9.44: json and jsonb operators
1005-- | Get JSON value (object field or array element) at a key.
1005-- | Get JSON value (object field or array element) at a key.
1006(.->)
1006(.->)
1007 :: (json `In` PGJsonType, key `In` PGJsonKey)
1007 :: (json `In` PGJsonType, key `In` PGJsonKey)
1008− => Expression commons schemas params grp from (nullity json)
1008+ => Expression grp commons schemas params from (nullity json)
1009− -> Expression commons schemas params grp from (nullity key)
1009+ -> Expression grp commons schemas params from (nullity key)
1010− -> Expression commons schemas params grp from ('Null json)
1010+ -> Expression grp commons schemas params from ('Null json)
1011infixl 8 .->
1011infixl 8 .->
1012(.->) = unsafeBinaryOp "->"
1012(.->) = unsafeBinaryOp "->"
1013
1013
1014-- | Get JSON value (object field or array element) at a key, as text.
1014-- | Get JSON value (object field or array element) at a key, as text.
1015(.->>)
1015(.->>)
1016 :: (json `In` PGJsonType, key `In` PGJsonKey)
1016 :: (json `In` PGJsonType, key `In` PGJsonKey)
1017− => Expression commons schemas params grp from (nullity json)
1017+ => Expression grp commons schemas params from (nullity json)
1018− -> Expression commons schemas params grp from (nullity key)
1018+ -> Expression grp commons schemas params from (nullity key)
1019− -> Expression commons schemas params grp from ('Null 'PGtext)
1019+ -> Expression grp commons schemas params from ('Null 'PGtext)
1020infixl 8 .->>
1020infixl 8 .->>
1021(.->>) = unsafeBinaryOp "->>"
1021(.->>) = unsafeBinaryOp "->>"
1022
1022
1023-- | Get JSON value at a specified path.
1023-- | Get JSON value at a specified path.
1024(.#>)
1024(.#>)
1025 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1025 :: (json `In` PGJsonType, PGTextArray "(.#>)" path)
1026− => Expression commons schemas params grp from (nullity json)
1026+ => Expression grp commons schemas params from (nullity json)
1027− -> Expression commons schemas params grp from (nullity path)
1027+ -> Expression grp commons schemas params from (nullity path)
1028− -> Expression commons schemas params grp from ('Null json)
1028+ -> Expression grp commons schemas params from ('Null json)
1029infixl 8 .#>
1029infixl 8 .#>
1030(.#>) = unsafeBinaryOp "#>"
1030(.#>) = unsafeBinaryOp "#>"
1031
1031
1032-- | Get JSON value at a specified path as text.
1032-- | Get JSON value at a specified path as text.
1033(.#>>)
1033(.#>>)
1034 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1034 :: (json `In` PGJsonType, PGTextArray "(.#>>)" path)
1035− => Expression commons schemas params grp from (nullity json)
1035+ => Expression grp commons schemas params from (nullity json)
1036− -> Expression commons schemas params grp from (nullity path)
1036+ -> Expression grp commons schemas params from (nullity path)
1037− -> Expression commons schemas params grp from ('Null 'PGtext)
1037+ -> Expression grp commons schemas params from ('Null 'PGtext)
1038infixl 8 .#>>
1038infixl 8 .#>>
1039(.#>>) = unsafeBinaryOp "#>>"
1039(.#>>) = unsafeBinaryOp "#>>"
1040
1040
@@ -1043,42 +1043,42 @@ infixl 8 .#>>
1043-- | Does the left JSON value contain the right JSON path/value entries at the
1043-- | Does the left JSON value contain the right JSON path/value entries at the
1044-- top level?
1044-- top level?
1045(.@>)
1045(.@>)
1046− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1046+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1047− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1047+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1048− -> Condition commons schemas params grp from
1048+ -> Condition grp commons schemas params from
1049infixl 9 .@>
1049infixl 9 .@>
1050(.@>) = unsafeBinaryOp "@>"
1050(.@>) = unsafeBinaryOp "@>"
1051
1051
1052-- | Are the left JSON path/value entries contained at the top level within the
1052-- | Are the left JSON path/value entries contained at the top level within the
1053-- right JSON value?
1053-- right JSON value?
1054(.<@)
1054(.<@)
1055− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1055+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1056− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1056+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1057− -> Condition commons schemas params grp from
1057+ -> Condition grp commons schemas params from
1058infixl 9 .<@
1058infixl 9 .<@
1059(.<@) = unsafeBinaryOp "<@"
1059(.<@) = unsafeBinaryOp "<@"
1060
1060
1061-- | Does the string exist as a top-level key within the JSON value?
1061-- | Does the string exist as a top-level key within the JSON value?
1062(.?)
1062(.?)
1063− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1063+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1064− -> Expression commons schemas params grp from (nullity 'PGtext)
1064+ -> Expression grp commons schemas params from (nullity 'PGtext)
1065− -> Condition commons schemas params grp from
1065+ -> Condition grp commons schemas params from
1066infixl 9 .?
1066infixl 9 .?
1067(.?) = unsafeBinaryOp "?"
1067(.?) = unsafeBinaryOp "?"
1068
1068
1069-- | Do any of these array strings exist as top-level keys?
1069-- | Do any of these array strings exist as top-level keys?
1070(.?|)
1070(.?|)
1071− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1071+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1072− -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1072+ -> Expression grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1073− -> Condition commons schemas params grp from
1073+ -> Condition grp commons schemas params from
1074infixl 9 .?|
1074infixl 9 .?|
1075(.?|) = unsafeBinaryOp "?|"
1075(.?|) = unsafeBinaryOp "?|"
1076
1076
1077-- | Do all of these array strings exist as top-level keys?
1077-- | Do all of these array strings exist as top-level keys?
1078(.?&)
1078(.?&)
1079− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1079+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1080− -> Expression commons schemas params grp from (nullity ('PGvararray ('NotNull 'PGtext)))
1080+ -> Expression grp commons schemas params from (nullity ('PGvararray ('NotNull 'PGtext)))
1081− -> Condition commons schemas params grp from
1081+ -> Condition grp commons schemas params from
1082infixl 9 .?&
1082infixl 9 .?&
1083(.?&) = unsafeBinaryOp "?&"
1083(.?&) = unsafeBinaryOp "?&"
1084
1084
@@ -1101,9 +1101,9 @@ instance
1101-- count from the end). Throws an error if top level container is not an array.
1101-- count from the end). Throws an error if top level container is not an array.
1102(.-.)
1102(.-.)
1103 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1103 :: (key `In` '[ 'PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2 ]) -- hlint error without parens here
1104− => Expression commons schemas params grp from (nullity 'PGjsonb)
1104+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1105− -> Expression commons schemas params grp from (nullity key)
1105+ -> Expression grp commons schemas params from (nullity key)
1106− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1106+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1107infixl 6 .-.
1107infixl 6 .-.
1108(.-.) = unsafeBinaryOp "-"
1108(.-.) = unsafeBinaryOp "-"
1109
1109
@@ -1111,9 +1111,9 @@ infixl 6 .-.
1111-- integers count from the end)
1111-- integers count from the end)
1112(#-.)
1112(#-.)
1113 :: PGTextArray "(#-.)" arrayty
1113 :: PGTextArray "(#-.)" arrayty
1114− => Expression commons schemas params grp from (nullity 'PGjsonb)
1114+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1115− -> Expression commons schemas params grp from (nullity arrayty)
1115+ -> Expression grp commons schemas params from (nullity arrayty)
1116− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1116+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1117infixl 6 #-.
1117infixl 6 #-.
1118(#-.) = unsafeBinaryOp "#-"
1118(#-.) = unsafeBinaryOp "#-"
1119
1119
@@ -1124,14 +1124,14 @@ Table 9.45: JSON creation functions
1124-- | Literal binary JSON
1124-- | Literal binary JSON
1125jsonbLit
1125jsonbLit
1126 :: JSON.ToJSON x
1126 :: JSON.ToJSON x
1127− => x -> Expression commons schemas params grp from (nullity 'PGjsonb)
1127+ => x -> Expression grp commons schemas params from (nullity 'PGjsonb)
1128jsonbLit = cast jsonb . UnsafeExpression
1128jsonbLit = cast jsonb . UnsafeExpression
1129 . singleQuotedUtf8 . toStrict . JSON.encode
1129 . singleQuotedUtf8 . toStrict . JSON.encode
1130
1130
1131-- | Literal JSON
1131-- | Literal JSON
1132jsonLit
1132jsonLit
1133 :: JSON.ToJSON x
1133 :: JSON.ToJSON x
1134− => x -> Expression commons schemas params grp from (nullity 'PGjson)
1134+ => x -> Expression grp commons schemas params from (nullity 'PGjson)
1135jsonLit = cast json . UnsafeExpression
1135jsonLit = cast json . UnsafeExpression
1136 . singleQuotedUtf8 . toStrict . JSON.encode
1136 . singleQuotedUtf8 . toStrict . JSON.encode
1137
1137
@@ -1142,8 +1142,8 @@ jsonLit = cast json . UnsafeExpression
1142-- number, a Boolean, or a null value, the text representation will be used, in
1142-- number, a Boolean, or a null value, the text representation will be used, in
1143-- such a fashion that it is a valid json value.
1143-- such a fashion that it is a valid json value.
1144toJson
1144toJson
1145− :: Expression commons schemas params grp from (nullity ty)
1145+ :: Expression grp commons schemas params from (nullity ty)
1146− -> Expression commons schemas params grp from (nullity 'PGjson)
1146+ -> Expression grp commons schemas params from (nullity 'PGjson)
1147toJson = unsafeFunction "to_json"
1147toJson = unsafeFunction "to_json"
1148
1148
1149-- | Returns the value as jsonb. Arrays and composites are converted
1149-- | Returns the value as jsonb. Arrays and composites are converted
@@ -1153,43 +1153,43 @@ toJson = unsafeFunction "to_json"
1153-- number, a Boolean, or a null value, the text representation will be used, in
1153-- number, a Boolean, or a null value, the text representation will be used, in
1154-- such a fashion that it is a valid jsonb value.
1154-- such a fashion that it is a valid jsonb value.
1155toJsonb
1155toJsonb
1156− :: Expression commons schemas params grp from (nullity ty)
1156+ :: Expression grp commons schemas params from (nullity ty)
1157− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1157+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1158toJsonb = unsafeFunction "to_jsonb"
1158toJsonb = unsafeFunction "to_jsonb"
1159
1159
1160-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1160-- | Returns the array as a JSON array. A PostgreSQL multidimensional array
1161-- becomes a JSON array of arrays.
1161-- becomes a JSON array of arrays.
1162arrayToJson
1162arrayToJson
1163 :: PGArray "arrayToJson" arr
1163 :: PGArray "arrayToJson" arr
1164− => Expression commons schemas params grp from (nullity arr)
1164+ => Expression grp commons schemas params from (nullity arr)
1165− -> Expression commons schemas params grp from (nullity 'PGjson)
1165+ -> Expression grp commons schemas params from (nullity 'PGjson)
1166arrayToJson = unsafeFunction "array_to_json"
1166arrayToJson = unsafeFunction "array_to_json"
1167
1167
1168-- | Returns the row as a JSON object.
1168-- | Returns the row as a JSON object.
1169rowToJson
1169rowToJson
1170− :: Expression commons schemas params grp from (nullity ('PGcomposite ty))
1170+ :: Expression grp commons schemas params from (nullity ('PGcomposite ty))
1171− -> Expression commons schemas params grp from (nullity 'PGjson)
1171+ -> Expression grp commons schemas params from (nullity 'PGjson)
1172rowToJson = unsafeFunction "row_to_json"
1172rowToJson = unsafeFunction "row_to_json"
1173
1173
1174-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1174-- | Builds a possibly-heterogeneously-typed JSON array out of a variadic
1175-- argument list.
1175-- argument list.
1176jsonBuildArray
1176jsonBuildArray
1177 :: SListI elems
1177 :: SListI elems
1178− => NP (Expression commons schemas params grp from) elems
1178+ => NP (Expression grp commons schemas params from) elems
1179− -> Expression commons schemas params grp from (nullity 'PGjson)
1179+ -> Expression grp commons schemas params from (nullity 'PGjson)
1180jsonBuildArray = unsafeVariadicFunction "json_build_array"
1180jsonBuildArray = unsafeVariadicFunction "json_build_array"
1181
1181
1182-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1182-- | Builds a possibly-heterogeneously-typed (binary) JSON array out of a
1183-- variadic argument list.
1183-- variadic argument list.
1184jsonbBuildArray
1184jsonbBuildArray
1185 :: SListI elems
1185 :: SListI elems
1186− => NP (Expression commons schemas params grp from) elems
1186+ => NP (Expression grp commons schemas params from) elems
1187− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1187+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1188jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1188jsonbBuildArray = unsafeVariadicFunction "jsonb_build_array"
1189
1189
1190unsafeRowFunction
1190unsafeRowFunction
1191 :: All Top elems
1191 :: All Top elems
1192− => NP (Aliased (Expression commons schemas params grp from)) elems
1192+ => NP (Aliased (Expression grp commons schemas params from)) elems
1193 -> [ByteString]
1193 -> [ByteString]
1194unsafeRowFunction =
1194unsafeRowFunction =
1195 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
1195 (`appEndo` []) . hcfoldMap (Proxy :: Proxy Top)
@@ -1204,8 +1204,8 @@ unsafeRowFunction =
1204-- and values.
1204-- and values.
1205jsonBuildObject
1205jsonBuildObject
1206 :: All Top elems
1206 :: All Top elems
1207− => NP (Aliased (Expression commons schemas params grp from)) elems
1207+ => NP (Aliased (Expression grp commons schemas params from)) elems
1208− -> Expression commons schemas params grp from (nullity 'PGjson)
1208+ -> Expression grp commons schemas params from (nullity 'PGjson)
1209jsonBuildObject
1209jsonBuildObject
1210 = unsafeFunction "json_build_object"
1210 = unsafeFunction "json_build_object"
1211 . UnsafeExpression
1211 . UnsafeExpression
@@ -1217,8 +1217,8 @@ jsonBuildObject
1217-- between text and values.
1217-- between text and values.
1218jsonbBuildObject
1218jsonbBuildObject
1219 :: All Top elems
1219 :: All Top elems
1220− => NP (Aliased (Expression commons schemas params grp from)) elems
1220+ => NP (Aliased (Expression grp commons schemas params from)) elems
1221− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1221+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1222jsonbBuildObject
1222jsonbBuildObject
1223 = unsafeFunction "jsonb_build_object"
1223 = unsafeFunction "jsonb_build_object"
1224 . UnsafeExpression
1224 . UnsafeExpression
@@ -1231,8 +1231,8 @@ jsonbBuildObject
1231-- array has exactly two elements, which are taken as a key/value pair.
1231-- array has exactly two elements, which are taken as a key/value pair.
1232jsonObject
1232jsonObject
1233 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1233 :: PGArrayOf "jsonObject" arr ('NotNull 'PGtext)
1234− => Expression commons schemas params grp from (nullity arr)
1234+ => Expression grp commons schemas params from (nullity arr)
1235− -> Expression commons schemas params grp from (nullity 'PGjson)
1235+ -> Expression grp commons schemas params from (nullity 'PGjson)
1236jsonObject = unsafeFunction "json_object"
1236jsonObject = unsafeFunction "json_object"
1237
1237
1238-- | Builds a binary JSON object out of a text array. The array must have either
1238-- | Builds a binary JSON object out of a text array. The array must have either
@@ -1241,8 +1241,8 @@ jsonObject = unsafeFunction "json_object"
1241-- array has exactly two elements, which are taken as a key/value pair.
1241-- array has exactly two elements, which are taken as a key/value pair.
1242jsonbObject
1242jsonbObject
1243 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1243 :: PGArrayOf "jsonbObject" arr ('NotNull 'PGtext)
1244− => Expression commons schemas params grp from (nullity arr)
1244+ => Expression grp commons schemas params from (nullity arr)
1245− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1245+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1246jsonbObject = unsafeFunction "jsonb_object"
1246jsonbObject = unsafeFunction "jsonb_object"
1247
1247
1248-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
1248-- | This is an alternate form of 'jsonObject' that takes two arrays; one for
@@ -1250,9 +1250,9 @@ jsonbObject = unsafeFunction "jsonb_object"
1250jsonZipObject
1250jsonZipObject
1251 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1251 :: ( PGArrayOf "jsonZipObject" keysArray ('NotNull 'PGtext)
1252 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1252 , PGArrayOf "jsonZipObject" valuesArray ('NotNull 'PGtext))
1253− => Expression commons schemas params grp from (nullity keysArray)
1253+ => Expression grp commons schemas params from (nullity keysArray)
1254− -> Expression commons schemas params grp from (nullity valuesArray)
1254+ -> Expression grp commons schemas params from (nullity valuesArray)
1255− -> Expression commons schemas params grp from (nullity 'PGjson)
1255+ -> Expression grp commons schemas params from (nullity 'PGjson)
1256jsonZipObject ks vs =
1256jsonZipObject ks vs =
1257 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1257 unsafeVariadicFunction "json_object" (ks :* vs :* Nil)
1258
1258
@@ -1262,9 +1262,9 @@ jsonZipObject ks vs =
1262jsonbZipObject
1262jsonbZipObject
1263 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1263 :: ( PGArrayOf "jsonbZipObject" keysArray ('NotNull 'PGtext)
1264 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1264 , PGArrayOf "jsonbZipObject" valuesArray ('NotNull 'PGtext))
1265− => Expression commons schemas params grp from (nullity keysArray)
1265+ => Expression grp commons schemas params from (nullity keysArray)
1266− -> Expression commons schemas params grp from (nullity valuesArray)
1266+ -> Expression grp commons schemas params from (nullity valuesArray)
1267− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1267+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1268jsonbZipObject ks vs =
1268jsonbZipObject ks vs =
1269 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1269 unsafeVariadicFunction "jsonb_object" (ks :* vs :* Nil)
1270
1270
@@ -1274,23 +1274,23 @@ Table 9.46: JSON processing functions
1274
1274
1275-- | Returns the number of elements in the outermost JSON array.
1275-- | Returns the number of elements in the outermost JSON array.
1276jsonArrayLength
1276jsonArrayLength
1277− :: Expression commons schemas params grp from (nullity 'PGjson)
1277+ :: Expression grp commons schemas params from (nullity 'PGjson)
1278− -> Expression commons schemas params grp from (nullity 'PGint4)
1278+ -> Expression grp commons schemas params from (nullity 'PGint4)
1279jsonArrayLength = unsafeFunction "json_array_length"
1279jsonArrayLength = unsafeFunction "json_array_length"
1280
1280
1281-- | Returns the number of elements in the outermost binary JSON array.
1281-- | Returns the number of elements in the outermost binary JSON array.
1282jsonbArrayLength
1282jsonbArrayLength
1283− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1283+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1284− -> Expression commons schemas params grp from (nullity 'PGint4)
1284+ -> Expression grp commons schemas params from (nullity 'PGint4)
1285jsonbArrayLength = unsafeFunction "jsonb_array_length"
1285jsonbArrayLength = unsafeFunction "jsonb_array_length"
1286
1286
1287-- | Returns JSON value pointed to by the given path (equivalent to #>
1287-- | Returns JSON value pointed to by the given path (equivalent to #>
1288-- operator).
1288-- operator).
1289jsonExtractPath
1289jsonExtractPath
1290 :: SListI elems
1290 :: SListI elems
1291− => Expression commons schemas params grp from (nullity 'PGjson)
1291+ => Expression grp commons schemas params from (nullity 'PGjson)
1292− -> NP (Expression commons schemas params grp from) elems
1292+ -> NP (Expression grp commons schemas params from) elems
1293− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1293+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1294jsonExtractPath x xs =
1294jsonExtractPath x xs =
1295 unsafeVariadicFunction "json_extract_path" (x :* xs)
1295 unsafeVariadicFunction "json_extract_path" (x :* xs)
1296
1296
@@ -1298,9 +1298,9 @@ jsonExtractPath x xs =
1298-- operator).
1298-- operator).
1299jsonbExtractPath
1299jsonbExtractPath
1300 :: SListI elems
1300 :: SListI elems
1301− => Expression commons schemas params grp from (nullity 'PGjsonb)
1301+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1302− -> NP (Expression commons schemas params grp from) elems
1302+ -> NP (Expression grp commons schemas params from) elems
1303− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1303+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1304jsonbExtractPath x xs =
1304jsonbExtractPath x xs =
1305 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1305 unsafeVariadicFunction "jsonb_extract_path" (x :* xs)
1306
1306
@@ -1308,9 +1308,9 @@ jsonbExtractPath x xs =
1308-- operator), as text.
1308-- operator), as text.
1309jsonExtractPathAsText
1309jsonExtractPathAsText
1310 :: SListI elems
1310 :: SListI elems
1311− => Expression commons schemas params grp from (nullity 'PGjson)
1311+ => Expression grp commons schemas params from (nullity 'PGjson)
1312− -> NP (Expression commons schemas params grp from) elems
1312+ -> NP (Expression grp commons schemas params from) elems
1313− -> Expression commons schemas params grp from (nullity 'PGjson)
1313+ -> Expression grp commons schemas params from (nullity 'PGjson)
1314jsonExtractPathAsText x xs =
1314jsonExtractPathAsText x xs =
1315 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1315 unsafeVariadicFunction "json_extract_path_text" (x :* xs)
1316
1316
@@ -1318,38 +1318,38 @@ jsonExtractPathAsText x xs =
1318-- operator), as text.
1318-- operator), as text.
1319jsonbExtractPathAsText
1319jsonbExtractPathAsText
1320 :: SListI elems
1320 :: SListI elems
1321− => Expression commons schemas params grp from (nullity 'PGjsonb)
1321+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1322− -> NP (Expression commons schemas params grp from) elems
1322+ -> NP (Expression grp commons schemas params from) elems
1323− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1323+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1324jsonbExtractPathAsText x xs =
1324jsonbExtractPathAsText x xs =
1325 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1325 unsafeVariadicFunction "jsonb_extract_path_text" (x :* xs)
1326
1326
1327-- | Returns the type of the outermost JSON value as a text string. Possible
1327-- | Returns the type of the outermost JSON value as a text string. Possible
1328-- types are object, array, string, number, boolean, and null.
1328-- types are object, array, string, number, boolean, and null.
1329jsonTypeof
1329jsonTypeof
1330− :: Expression commons schemas params grp from (nullity 'PGjson)
1330+ :: Expression grp commons schemas params from (nullity 'PGjson)
1331− -> Expression commons schemas params grp from (nullity 'PGtext)
1331+ -> Expression grp commons schemas params from (nullity 'PGtext)
1332jsonTypeof = unsafeFunction "json_typeof"
1332jsonTypeof = unsafeFunction "json_typeof"
1333
1333
1334-- | Returns the type of the outermost binary JSON value as a text string.
1334-- | Returns the type of the outermost binary JSON value as a text string.
1335-- Possible types are object, array, string, number, boolean, and null.
1335-- Possible types are object, array, string, number, boolean, and null.
1336jsonbTypeof
1336jsonbTypeof
1337− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1337+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1338− -> Expression commons schemas params grp from (nullity 'PGtext)
1338+ -> Expression grp commons schemas params from (nullity 'PGtext)
1339jsonbTypeof = unsafeFunction "jsonb_typeof"
1339jsonbTypeof = unsafeFunction "jsonb_typeof"
1340
1340
1341-- | Returns its argument with all object fields that have null values omitted.
1341-- | Returns its argument with all object fields that have null values omitted.
1342-- Other null values are untouched.
1342-- Other null values are untouched.
1343jsonStripNulls
1343jsonStripNulls
1344− :: Expression commons schemas params grp from (nullity 'PGjson)
1344+ :: Expression grp commons schemas params from (nullity 'PGjson)
1345− -> Expression commons schemas params grp from (nullity 'PGjson)
1345+ -> Expression grp commons schemas params from (nullity 'PGjson)
1346jsonStripNulls = unsafeFunction "json_strip_nulls"
1346jsonStripNulls = unsafeFunction "json_strip_nulls"
1347
1347
1348-- | Returns its argument with all object fields that have null values omitted.
1348-- | Returns its argument with all object fields that have null values omitted.
1349-- Other null values are untouched.
1349-- Other null values are untouched.
1350jsonbStripNulls
1350jsonbStripNulls
1351− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1351+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1352− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1352+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1353jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1353jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1354
1354
1355-- | @ jsonbSet target path new_value create_missing @
1355-- | @ jsonbSet target path new_value create_missing @
@@ -1361,11 +1361,11 @@ jsonbStripNulls = unsafeFunction "jsonb_strip_nulls"
1361-- arrays.
1361-- arrays.
1362jsonbSet
1362jsonbSet
1363 :: PGTextArray "jsonbSet" arr
1363 :: PGTextArray "jsonbSet" arr
1364− => Expression commons schemas params grp from (nullity 'PGjsonb)
1364+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1365− -> Expression commons schemas params grp from (nullity arr)
1365+ -> Expression grp commons schemas params from (nullity arr)
1366− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1366+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1367− -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1367+ -> Maybe (Expression grp commons schemas params from (nullity 'PGbool))
1368− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1368+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1369jsonbSet tgt path val createMissing = case createMissing of
1369jsonbSet tgt path val createMissing = case createMissing of
1370 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1370 Just m -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* m :* Nil)
1371 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
1371 Nothing -> unsafeVariadicFunction "jsonb_set" (tgt :* path :* val :* Nil)
@@ -1380,19 +1380,19 @@ jsonbSet tgt path val createMissing = case createMissing of
1380-- in path count from the end of JSON arrays.
1380-- in path count from the end of JSON arrays.
1381jsonbInsert
1381jsonbInsert
1382 :: PGTextArray "jsonbInsert" arr
1382 :: PGTextArray "jsonbInsert" arr
1383− => Expression commons schemas params grp from (nullity 'PGjsonb)
1383+ => Expression grp commons schemas params from (nullity 'PGjsonb)
1384− -> Expression commons schemas params grp from (nullity arr)
1384+ -> Expression grp commons schemas params from (nullity arr)
1385− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1385+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1386− -> Maybe (Expression commons schemas params grp from (nullity 'PGbool))
1386+ -> Maybe (Expression grp commons schemas params from (nullity 'PGbool))
1387− -> Expression commons schemas params grp from (nullity 'PGjsonb)
1387+ -> Expression grp commons schemas params from (nullity 'PGjsonb)
1388jsonbInsert tgt path val insertAfter = case insertAfter of
1388jsonbInsert tgt path val insertAfter = case insertAfter of
1389 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1389 Just i -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* i :* Nil)
1390 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1390 Nothing -> unsafeVariadicFunction "jsonb_insert" (tgt :* path :* val :* Nil)
1391
1391
1392-- | Returns its argument as indented JSON text.
1392-- | Returns its argument as indented JSON text.
1393jsonbPretty
1393jsonbPretty
1394− :: Expression commons schemas params grp from (nullity 'PGjsonb)
1394+ :: Expression grp commons schemas params from (nullity 'PGjsonb)
1395− -> Expression commons schemas params grp from (nullity 'PGtext)
1395+ -> Expression grp commons schemas params from (nullity 'PGtext)
1396jsonbPretty = unsafeFunction "jsonb_pretty"
1396jsonbPretty = unsafeFunction "jsonb_pretty"
1397
1397
1398{-----------------------------------------
1398{-----------------------------------------
@@ -1402,54 +1402,54 @@ aggregation
1402-- | escape hatch to define aggregate functions
1402-- | escape hatch to define aggregate functions
1403unsafeAggregate
1403unsafeAggregate
1404 :: ByteString -- ^ aggregate function
1404 :: ByteString -- ^ aggregate function
1405− -> Expression commons schemas from 'Ungrouped params (xty)
1405+ -> Expression 'Ungrouped commons schemas params from xty
1406− -> Expression commons schemas from ('Grouped bys) params (yty)
1406+ -> Expression ('Grouped bys) commons schemas params from yty
1407unsafeAggregate fun x = UnsafeExpression $ mconcat
1407unsafeAggregate fun x = UnsafeExpression $ mconcat
1408 [fun, "(", renderSQL x, ")"]
1408 [fun, "(", renderSQL x, ")"]
1409
1409
1410-- | escape hatch to define aggregate functions over distinct values
1410-- | escape hatch to define aggregate functions over distinct values
1411unsafeAggregateDistinct
1411unsafeAggregateDistinct
1412 :: ByteString -- ^ aggregate function
1412 :: ByteString -- ^ aggregate function
1413− -> Expression commons schemas from 'Ungrouped params (xty)
1413+ -> Expression 'Ungrouped commons schemas params from xty
1414− -> Expression commons schemas from ('Grouped bys) params (yty)
1414+ -> Expression ('Grouped bys) commons schemas params from yty
1415unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1415unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
1416 [fun, "(DISTINCT ", renderSQL x, ")"]
1416 [fun, "(DISTINCT ", renderSQL x, ")"]
1417
1417
1418-- | >>> :{
1418-- | >>> :{
1419-- let
1419-- let
1420−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1420+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric)
1421-- expression = sum_ #col
1421-- expression = sum_ #col
1422-- in printSQL expression
1422-- in printSQL expression
1423-- :}
1423-- :}
1424-- sum("col")
1424-- sum("col")
1425sum_
1425sum_
1426 :: ty `In` PGNum
1426 :: ty `In` PGNum
1427− => Expression commons schemas from 'Ungrouped params (nullity ty)
1427+ => Expression 'Ungrouped commons schemas params from (nullity ty)
1428 -- ^ what to sum
1428 -- ^ what to sum
1429− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1429+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
1430sum_ = unsafeAggregate "sum"
1430sum_ = unsafeAggregate "sum"
1431
1431
1432-- | >>> :{
1432-- | >>> :{
1433-- let
1433-- let
1434−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1434+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGnumeric]] (nullity 'PGnumeric)
1435-- expression = sumDistinct #col
1435-- expression = sumDistinct #col
1436-- in printSQL expression
1436-- in printSQL expression
1437-- :}
1437-- :}
1438-- sum(DISTINCT "col")
1438-- sum(DISTINCT "col")
1439sumDistinct
1439sumDistinct
1440 :: ty `In` PGNum
1440 :: ty `In` PGNum
1441− => Expression commons schemas from 'Ungrouped params (nullity ty)
1441+ => Expression 'Ungrouped commons schemas params from (nullity ty)
1442 -- ^ what to sum
1442 -- ^ what to sum
1443− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1443+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
1444sumDistinct = unsafeAggregateDistinct "sum"
1444sumDistinct = unsafeAggregateDistinct "sum"
1445
1445
1446-- | A constraint for `PGType`s that you can take averages of and the resulting
1446-- | A constraint for `PGType`s that you can take averages of and the resulting
1447-- `PGType`.
1447-- `PGType`.
1448class PGAvg ty avg | ty -> avg where
1448class PGAvg ty avg | ty -> avg where
1449 avg, avgDistinct
1449 avg, avgDistinct
1450− :: Expression commons schemas from 'Ungrouped params (nullity ty)
1450+ :: Expression 'Ungrouped commons schemas params from (nullity ty)
1451 -- ^ what to average
1451 -- ^ what to average
1452− -> Expression commons schemas from ('Grouped bys) params (nullity avg)
1452+ -> Expression ('Grouped bys) commons schemas params from (nullity avg)
1453 avg = unsafeAggregate "avg"
1453 avg = unsafeAggregate "avg"
1454 avgDistinct = unsafeAggregateDistinct "avg"
1454 avgDistinct = unsafeAggregateDistinct "avg"
1455instance PGAvg 'PGint2 'PGnumeric
1455instance PGAvg 'PGint2 'PGnumeric
@@ -1469,37 +1469,37 @@ instance PGAvg 'PGinterval 'PGinterval
1469-- bit_and("col")
1469-- bit_and("col")
1470bitAnd
1470bitAnd
1471 :: int `In` PGIntegral
1471 :: int `In` PGIntegral
1472− => Expression commons schemas from 'Ungrouped params (nullity int)
1472+ => Expression 'Ungrouped commons schemas params from (nullity int)
1473 -- ^ what to aggregate
1473 -- ^ what to aggregate
1474− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1474+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1475bitAnd = unsafeAggregate "bit_and"
1475bitAnd = unsafeAggregate "bit_and"
1476
1476
1477-- | >>> :{
1477-- | >>> :{
1478-- let
1478-- let
1479−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1479+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1480-- expression = bitOr #col
1480-- expression = bitOr #col
1481-- in printSQL expression
1481-- in printSQL expression
1482-- :}
1482-- :}
1483-- bit_or("col")
1483-- bit_or("col")
1484bitOr
1484bitOr
1485 :: int `In` PGIntegral
1485 :: int `In` PGIntegral
1486− => Expression commons schemas from 'Ungrouped params (nullity int)
1486+ => Expression 'Ungrouped commons schemas params from (nullity int)
1487 -- ^ what to aggregate
1487 -- ^ what to aggregate
1488− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1488+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1489bitOr = unsafeAggregate "bit_or"
1489bitOr = unsafeAggregate "bit_or"
1490
1490
1491-- | >>> :{
1491-- | >>> :{
1492-- let
1492-- let
1493−-- expression :: Expression commons schemas params ('Grouped bys) '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1493+-- expression :: Expression ('Grouped bys) commons schemas params '[tab ::: '["col" ::: nullity 'PGint4]] (nullity 'PGint4)
1494-- expression = bitAndDistinct #col
1494-- expression = bitAndDistinct #col
1495-- in printSQL expression
1495-- in printSQL expression
1496-- :}
1496-- :}
1497-- bit_and(DISTINCT "col")
1497-- bit_and(DISTINCT "col")
1498bitAndDistinct
1498bitAndDistinct
1499 :: int `In` PGIntegral
1499 :: int `In` PGIntegral
1500− => Expression commons schemas from 'Ungrouped params (nullity int)
1500+ => Expression 'Ungrouped commons schemas params from (nullity int)
1501 -- ^ what to aggregate
1501 -- ^ what to aggregate
1502− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1502+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1503bitAndDistinct = unsafeAggregateDistinct "bit_and"
1503bitAndDistinct = unsafeAggregateDistinct "bit_and"
1504
1504
1505-- | >>> :{
1505-- | >>> :{
@@ -1511,9 +1511,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
1511-- bit_or(DISTINCT "col")
1511-- bit_or(DISTINCT "col")
1512bitOrDistinct
1512bitOrDistinct
1513 :: int `In` PGIntegral
1513 :: int `In` PGIntegral
1514− => Expression commons schemas from 'Ungrouped params (nullity int)
1514+ => Expression 'Ungrouped commons schemas params from (nullity int)
1515 -- ^ what to aggregate
1515 -- ^ what to aggregate
1516− -> Expression commons schemas from ('Grouped bys) params (nullity int)
1516+ -> Expression ('Grouped bys) commons schemas params from (nullity int)
1517bitOrDistinct = unsafeAggregateDistinct "bit_or"
1517bitOrDistinct = unsafeAggregateDistinct "bit_or"
1518
1518
1519-- | >>> :{
1519-- | >>> :{
@@ -1524,9 +1524,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
1524-- :}
1524-- :}
1525-- bool_and("col")
1525-- bool_and("col")
1526boolAnd
1526boolAnd
1527− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1527+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1528 -- ^ what to aggregate
1528 -- ^ what to aggregate
1529− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1529+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1530boolAnd = unsafeAggregate "bool_and"
1530boolAnd = unsafeAggregate "bool_and"
1531
1531
1532-- | >>> :{
1532-- | >>> :{
@@ -1537,9 +1537,9 @@ boolAnd = unsafeAggregate "bool_and"
1537-- :}
1537-- :}
1538-- bool_or("col")
1538-- bool_or("col")
1539boolOr
1539boolOr
1540− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1540+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1541 -- ^ what to aggregate
1541 -- ^ what to aggregate
1542− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1542+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1543boolOr = unsafeAggregate "bool_or"
1543boolOr = unsafeAggregate "bool_or"
1544
1544
1545-- | >>> :{
1545-- | >>> :{
@@ -1550,9 +1550,9 @@ boolOr = unsafeAggregate "bool_or"
1550-- :}
1550-- :}
1551-- bool_and(DISTINCT "col")
1551-- bool_and(DISTINCT "col")
1552boolAndDistinct
1552boolAndDistinct
1553− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1553+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1554 -- ^ what to aggregate
1554 -- ^ what to aggregate
1555− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1555+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1556boolAndDistinct = unsafeAggregateDistinct "bool_and"
1556boolAndDistinct = unsafeAggregateDistinct "bool_and"
1557
1557
1558-- | >>> :{
1558-- | >>> :{
@@ -1563,9 +1563,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
1563-- :}
1563-- :}
1564-- bool_or(DISTINCT "col")
1564-- bool_or(DISTINCT "col")
1565boolOrDistinct
1565boolOrDistinct
1566− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1566+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1567 -- ^ what to aggregate
1567 -- ^ what to aggregate
1568− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1568+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1569boolOrDistinct = unsafeAggregateDistinct "bool_or"
1569boolOrDistinct = unsafeAggregateDistinct "bool_or"
1570
1570
1571-- | A special aggregation that does not require an input
1571-- | A special aggregation that does not require an input
@@ -1573,7 +1573,7 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1573-- >>> printSQL countStar
1573-- >>> printSQL countStar
1574-- count(*)
1574-- count(*)
1575countStar
1575countStar
1576− :: Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1576+ :: Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1577countStar = UnsafeExpression $ "count(*)"
1577countStar = UnsafeExpression $ "count(*)"
1578
1578
1579-- | >>> :{
1579-- | >>> :{
@@ -1584,9 +1584,9 @@ countStar = UnsafeExpression $ "count(*)"
1584-- :}
1584-- :}
1585-- count("col")
1585-- count("col")
1586count
1586count
1587− :: Expression commons schemas from 'Ungrouped params ty
1587+ :: Expression 'Ungrouped commons schemas params from ty
1588 -- ^ what to count
1588 -- ^ what to count
1589− -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1589+ -> Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1590count = unsafeAggregate "count"
1590count = unsafeAggregate "count"
1591
1591
1592-- | >>> :{
1592-- | >>> :{
@@ -1597,9 +1597,9 @@ count = unsafeAggregate "count"
1597-- :}
1597-- :}
1598-- count(DISTINCT "col")
1598-- count(DISTINCT "col")
1599countDistinct
1599countDistinct
1600− :: Expression commons schemas from 'Ungrouped params ty
1600+ :: Expression 'Ungrouped commons schemas params from ty
1601 -- ^ what to count
1601 -- ^ what to count
1602− -> Expression commons schemas from ('Grouped bys) params ('NotNull 'PGint8)
1602+ -> Expression ('Grouped bys) commons schemas params from ('NotNull 'PGint8)
1603countDistinct = unsafeAggregateDistinct "count"
1603countDistinct = unsafeAggregateDistinct "count"
1604
1604
1605-- | synonym for `boolAnd`
1605-- | synonym for `boolAnd`
@@ -1612,9 +1612,9 @@ countDistinct = unsafeAggregateDistinct "count"
1612-- :}
1612-- :}
1613-- every("col")
1613-- every("col")
1614every
1614every
1615− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1615+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1616 -- ^ what to aggregate
1616 -- ^ what to aggregate
1617− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1617+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1618every = unsafeAggregate "every"
1618every = unsafeAggregate "every"
1619
1619
1620-- | synonym for `boolAndDistinct`
1620-- | synonym for `boolAndDistinct`
@@ -1627,16 +1627,16 @@ every = unsafeAggregate "every"
1627-- :}
1627-- :}
1628-- every(DISTINCT "col")
1628-- every(DISTINCT "col")
1629everyDistinct
1629everyDistinct
1630− :: Expression commons schemas from 'Ungrouped params (nullity 'PGbool)
1630+ :: Expression 'Ungrouped commons schemas params from (nullity 'PGbool)
1631 -- ^ what to aggregate
1631 -- ^ what to aggregate
1632− -> Expression commons schemas from ('Grouped bys) params (nullity 'PGbool)
1632+ -> Expression ('Grouped bys) commons schemas params from (nullity 'PGbool)
1633everyDistinct = unsafeAggregateDistinct "every"
1633everyDistinct = unsafeAggregateDistinct "every"
1634
1634
1635-- | minimum and maximum aggregation
1635-- | minimum and maximum aggregation
1636max_, min_, maxDistinct, minDistinct
1636max_, min_, maxDistinct, minDistinct
1637− :: Expression commons schemas from 'Ungrouped params (nullity ty)
1637+ :: Expression 'Ungrouped commons schemas params from (nullity ty)
1638 -- ^ what to aggregate
1638 -- ^ what to aggregate
1639− -> Expression commons schemas from ('Grouped bys) params (nullity ty)
1639+ -> Expression ('Grouped bys) commons schemas params from (nullity ty)
1640max_ = unsafeAggregate "max"
1640max_ = unsafeAggregate "max"
1641min_ = unsafeAggregate "min"
1641min_ = unsafeAggregate "min"
1642maxDistinct = unsafeAggregateDistinct "max"
1642maxDistinct = unsafeAggregateDistinct "max"
@@ -1822,35 +1822,35 @@ Sorting
1822-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
1822-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
1823-- determine whether nulls appear before or after non-null values in the sort
1823-- determine whether nulls appear before or after non-null values in the sort
1824-- ordering of a `Null` result column.
1824-- ordering of a `Null` result column.
1825−data SortExpression commons schemas params grp from where
1825+data SortExpression grp commons schemas params from where
1826 Asc
1826 Asc
1827− :: Expression commons schemas params grp from ('NotNull ty)
1827+ :: Expression grp commons schemas params from ('NotNull ty)
1828− -> SortExpression commons schemas params grp from
1828+ -> SortExpression grp commons schemas params from
1829 Desc
1829 Desc
1830− :: Expression commons schemas params grp from ('NotNull ty)
1830+ :: Expression grp commons schemas params from ('NotNull ty)
1831− -> SortExpression commons schemas params grp from
1831+ -> SortExpression grp commons schemas params from
1832 AscNullsFirst
1832 AscNullsFirst
1833− :: Expression commons schemas params grp from ('Null ty)
1833+ :: Expression grp commons schemas params from ('Null ty)
1834− -> SortExpression commons schemas params grp from
1834+ -> SortExpression grp commons schemas params from
1835 AscNullsLast
1835 AscNullsLast
1836− :: Expression commons schemas params grp from ('Null ty)
1836+ :: Expression grp commons schemas params from ('Null ty)
1837− -> SortExpression commons schemas params grp from
1837+ -> SortExpression grp commons schemas params from
1838 DescNullsFirst
1838 DescNullsFirst
1839− :: Expression commons schemas params grp from ('Null ty)
1839+ :: Expression grp commons schemas params from ('Null ty)
1840− -> SortExpression commons schemas params grp from
1840+ -> SortExpression grp commons schemas params from
1841 DescNullsLast
1841 DescNullsLast
1842− :: Expression commons schemas params grp from ('Null ty)
1842+ :: Expression grp commons schemas params from ('Null ty)
1843− -> SortExpression commons schemas params grp from
1843+ -> SortExpression grp commons schemas params from
1844−deriving instance Show (SortExpression commons schemas params grp from)
1844+deriving instance Show (SortExpression grp commons schemas params from)
1845
1845
1846class OrderBy expr where
1846class OrderBy expr where
1847 orderBy
1847 orderBy
1848− :: [SortExpression commons schemas params grp from]
1848+ :: [SortExpression grp commons schemas params from]
1849− -> expr commons schemas params grp from
1849+ -> expr grp commons schemas params from
1850− -> expr commons schemas params grp from
1850+ -> expr grp commons schemas params from
1851
1851
1852-- | Render a `SortExpression`.
1852-- | Render a `SortExpression`.
1853−instance RenderSQL (SortExpression commons schemas params grp from) where
1853+instance RenderSQL (SortExpression grp commons schemas params from) where
1854 renderSQL = \case
1854 renderSQL = \case
1855 Asc expression -> renderSQL expression <+> "ASC"
1855 Asc expression -> renderSQL expression <+> "ASC"
1856 Desc expression -> renderSQL expression <+> "DESC"
1856 Desc expression -> renderSQL expression <+> "DESC"
@@ -1861,12 +1861,12 @@ instance RenderSQL (SortExpression commons schemas params grp from) where
1861 AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
1861 AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
1862 DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
1862 DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
1863
1863
1864−data WindowDefinition commons schemas params grp from where
1864+data WindowDefinition grp commons schemas params from where
1865 WindowDefinition
1865 WindowDefinition
1866 :: SListI bys
1866 :: SListI bys
1867− => NP (Expression commons schemas params grp from) bys
1867+ => NP (Expression grp commons schemas params from) bys
1868− -> [SortExpression commons schemas params grp from]
1868+ -> [SortExpression grp commons schemas params from]
1869− -> WindowDefinition commons schemas params grp from
1869+ -> WindowDefinition grp commons schemas params from
1870
1870
1871instance OrderBy WindowDefinition where
1871instance OrderBy WindowDefinition where
1872 orderBy sortsR (WindowDefinition parts sortsL)
1872 orderBy sortsR (WindowDefinition parts sortsL)
@@ -1886,49 +1886,49 @@ instance RenderSQL (WindowDefinition commons schemas from grp params) where
1886
1886
1887partitionBy
1887partitionBy
1888 :: SListI bys
1888 :: SListI bys
1889− => NP (Expression commons schemas params grp from) bys
1889+ => NP (Expression grp commons schemas params from) bys
1890− -> WindowDefinition commons schemas params grp from
1890+ -> WindowDefinition grp commons schemas params from
1891partitionBy bys = WindowDefinition bys []
1891partitionBy bys = WindowDefinition bys []
1892
1892
1893newtype WindowFunction
1893newtype WindowFunction
1894+ (grp :: Grouping)
1894 (commons :: FromType)
1895 (commons :: FromType)
1895 (schemas :: SchemasType)
1896 (schemas :: SchemasType)
1896 (params :: [NullityType])
1897 (params :: [NullityType])
1897− (grp :: Grouping)
1898 (from :: FromType)
1898 (from :: FromType)
1899 (ty :: NullityType)
1899 (ty :: NullityType)
1900 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
1900 = UnsafeWindowFunction { renderWindowFunction :: ByteString }
1901 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1901 deriving (GHC.Generic,Show,Eq,Ord,NFData)
1902
1902
1903−instance RenderSQL (WindowFunction commons schemas params grp from ty) where
1903+instance RenderSQL (WindowFunction grp commons schemas params from ty) where
1904 renderSQL = renderWindowFunction
1904 renderSQL = renderWindowFunction
1905
1905
1906{- | rank of the current row with gaps; same as `rowNumber` of its first peer
1906{- | rank of the current row with gaps; same as `rowNumber` of its first peer
1907>>> printSQL rank
1907>>> printSQL rank
1908rank()
1908rank()
1909-}
1909-}
1910−rank :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1910+rank :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
1911rank = UnsafeWindowFunction "rank()"
1911rank = UnsafeWindowFunction "rank()"
1912
1912
1913{- | number of the current row within its partition, counting from 1
1913{- | number of the current row within its partition, counting from 1
1914>>> printSQL rowNumber
1914>>> printSQL rowNumber
1915row_number()
1915row_number()
1916-}
1916-}
1917−rowNumber :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1917+rowNumber :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
1918rowNumber = UnsafeWindowFunction "row_number()"
1918rowNumber = UnsafeWindowFunction "row_number()"
1919
1919
1920{- | rank of the current row without gaps; this function counts peer groups
1920{- | rank of the current row without gaps; this function counts peer groups
1921>>> printSQL denseRank
1921>>> printSQL denseRank
1922dense_rank()
1922dense_rank()
1923-}
1923-}
1924−denseRank :: WindowFunction commons schemas from grp params ('NotNull 'PGint8)
1924+denseRank :: WindowFunction grp commons schemas params from ('NotNull 'PGint8)
1925denseRank = UnsafeWindowFunction "dense_rank()"
1925denseRank = UnsafeWindowFunction "dense_rank()"
1926
1926
1927{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
1927{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
1928>>> printSQL percentRank
1928>>> printSQL percentRank
1929percent_rank()
1929percent_rank()
1930-}
1930-}
1931−percentRank :: WindowFunction commons schemas from grp params ('NotNull 'PGfloat8)
1931+percentRank :: WindowFunction grp commons schemas params from ('NotNull 'PGfloat8)
1932percentRank = UnsafeWindowFunction "percent_rank()"
1932percentRank = UnsafeWindowFunction "percent_rank()"
1933
1933
1934{- | cumulative distribution: (number of partition rows
1934{- | cumulative distribution: (number of partition rows
@@ -1936,16 +1936,16 @@ preceding or peer with current row) / total partition rows
1936>>> printSQL cumeDist
1936>>> printSQL cumeDist
1937cume_dist()
1937cume_dist()
1938-}
1938-}
1939−cumeDist :: WindowFunction commons schemas from grp params ('NotNull 'PGfloat8)
1939+cumeDist :: WindowFunction grp commons schemas params from ('NotNull 'PGfloat8)
1940cumeDist = UnsafeWindowFunction "cume_dist()"
1940cumeDist = UnsafeWindowFunction "cume_dist()"
1941
1941
1942{- | integer ranging from 1 to the argument value,
1942{- | integer ranging from 1 to the argument value,
1943dividing the partition as equally as possible
1943dividing the partition as equally as possible
1944-}
1944-}
1945ntile
1945ntile
1946− :: Expression commons schemas from grp params ('NotNull 'PGint4)
1946+ :: Expression grp commons schemas params from ('NotNull 'PGint4)
1947 -- ^ numuckets
1947 -- ^ numuckets
1948− -> WindowFunction commons schemas from grp params ('NotNull 'PGint4)
1948+ -> WindowFunction grp commons schemas params from ('NotNull 'PGint4)
1949ntile numBuckets = UnsafeWindowFunction $ "ntile"
1949ntile numBuckets = UnsafeWindowFunction $ "ntile"
1950 <> parenthesized (renderSQL numBuckets)
1950 <> parenthesized (renderSQL numBuckets)
1951
1951
@@ -1955,13 +1955,13 @@ row within the partition; if there is no such row, instead return default
1955evaluated with respect to the current row.
1955evaluated with respect to the current row.
1956-}
1956-}
1957lag
1957lag
1958− :: Expression commons schemas from grp params ty
1958+ :: Expression grp commons schemas params from ty
1959 -- ^ value
1959 -- ^ value
1960− -> Expression commons schemas from grp params ('NotNull 'PGint4)
1960+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
1961 -- ^ offset
1961 -- ^ offset
1962− -> Expression commons schemas from grp params ty
1962+ -> Expression grp commons schemas params from ty
1963 -- ^ default
1963 -- ^ default
1964− -> WindowFunction commons schemas from grp params ty
1964+ -> WindowFunction grp commons schemas params from ty
1965lag value offset def = UnsafeWindowFunction $ "lag"
1965lag value offset def = UnsafeWindowFunction $ "lag"
1966 <> parenthesized
1966 <> parenthesized
1967 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
1967 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
@@ -1972,13 +1972,13 @@ row within the partition; if there is no such row, instead return default
1972evaluated with respect to the current row.
1972evaluated with respect to the current row.
1973-}
1973-}
1974lead
1974lead
1975− :: Expression commons schemas from grp params ty
1975+ :: Expression grp commons schemas params from ty
1976 -- ^ value
1976 -- ^ value
1977− -> Expression commons schemas from grp params ('NotNull 'PGint4)
1977+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
1978 -- ^ offset
1978 -- ^ offset
1979− -> Expression commons schemas from grp params ty
1979+ -> Expression grp commons schemas params from ty
1980 -- ^ default
1980 -- ^ default
1981− -> WindowFunction commons schemas from grp params ty
1981+ -> WindowFunction grp commons schemas params from ty
1982lead value offset def = UnsafeWindowFunction $ "lag"
1982lead value offset def = UnsafeWindowFunction $ "lag"
1983 <> parenthesized
1983 <> parenthesized
1984 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
1984 (commaSeparated ([renderSQL value, renderSQL offset, renderSQL def]))
@@ -1987,9 +1987,9 @@ lead value offset def = UnsafeWindowFunction $ "lag"
1987first row of the window frame
1987first row of the window frame
1988-}
1988-}
1989firstValue
1989firstValue
1990− :: Expression commons schemas from grp params ty
1990+ :: Expression grp commons schemas params from ty
1991 -- ^ value
1991 -- ^ value
1992− -> WindowFunction commons schemas from grp params ty
1992+ -> WindowFunction grp commons schemas params from ty
1993firstValue value = UnsafeWindowFunction $ "first_value"
1993firstValue value = UnsafeWindowFunction $ "first_value"
1994 <> parenthesized (renderSQL value)
1994 <> parenthesized (renderSQL value)
1995
1995
@@ -1997,9 +1997,9 @@ firstValue value = UnsafeWindowFunction $ "first_value"
1997last row of the window frame
1997last row of the window frame
1998-}
1998-}
1999lastValue
1999lastValue
2000− :: Expression commons schemas from grp params ty
2000+ :: Expression grp commons schemas params from ty
2001 -- ^ value
2001 -- ^ value
2002− -> WindowFunction commons schemas from grp params ty
2002+ -> WindowFunction grp commons schemas params from ty
2003lastValue value = UnsafeWindowFunction $ "last_value"
2003lastValue value = UnsafeWindowFunction $ "last_value"
2004 <> parenthesized (renderSQL value)
2004 <> parenthesized (renderSQL value)
2005
2005
@@ -2007,10 +2007,10 @@ lastValue value = UnsafeWindowFunction $ "last_value"
2007row of the window frame (counting from 1); null if no such row
2007row of the window frame (counting from 1); null if no such row
2008-}
2008-}
2009nthValue
2009nthValue
2010− :: Expression commons schemas from grp params (nullity ty)
2010+ :: Expression grp commons schemas params from (nullity ty)
2011 -- ^ value
2011 -- ^ value
2012− -> Expression commons schemas from grp params ('NotNull 'PGint4)
2012+ -> Expression grp commons schemas params from ('NotNull 'PGint4)
2013 -- ^ nth
2013 -- ^ nth
2014− -> WindowFunction commons schemas from grp params ('Null ty)
2014+ -> WindowFunction grp commons schemas params from ('Null ty)
2015nthValue value nth = UnsafeWindowFunction $ "nth_value"
2015nthValue value nth = UnsafeWindowFunction $ "nth_value"
2016 <> parenthesized (commaSeparated [renderSQL value, renderSQL nth])
2016 <> parenthesized (commaSeparated [renderSQL value, renderSQL nth])
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+36−36
@@ -263,13 +263,13 @@ insertInto_ tab qry =
263data QueryClause commons schemas params columns where
263data QueryClause commons schemas params columns where
264 Values
264 Values
265 :: SOP.SListI columns
265 :: SOP.SListI columns
266− => NP (ColumnExpression schemas params 'Ungrouped '[]) columns
266+ => NP (ColumnExpression 'Ungrouped schemas params '[]) columns
267− -> [NP (ColumnExpression schemas params 'Ungrouped '[]) columns]
267+ -> [NP (ColumnExpression 'Ungrouped schemas params '[]) columns]
268 -> QueryClause commons schemas params columns
268 -> QueryClause commons schemas params columns
269 Select
269 Select
270 :: SOP.SListI columns
270 :: SOP.SListI columns
271− => NP (ColumnExpression schemas params grp from) columns
271+ => NP (ColumnExpression grp schemas params from) columns
272− -> TableExpression commons schemas params grp from
272+ -> TableExpression grp commons schemas params from
273 -> QueryClause commons schemas params columns
273 -> QueryClause commons schemas params columns
274 Subquery
274 Subquery
275 :: ColumnsToRow columns ~ row
275 :: ColumnsToRow columns ~ row
@@ -292,7 +292,7 @@ instance RenderSQL (QueryClause commons schemas params columns) where
292 Subquery qry -> renderQuery qry
292 Subquery qry -> renderQuery qry
293 where
293 where
294 renderSQLPartMaybe, renderValuePartMaybe
294 renderSQLPartMaybe, renderValuePartMaybe
295− :: ColumnExpression schemas params grp from column -> Maybe ByteString
295+ :: ColumnExpression grp schemas params from column -> Maybe ByteString
296 renderSQLPartMaybe = \case
296 renderSQLPartMaybe = \case
297 DefaultAs _ -> Nothing
297 DefaultAs _ -> Nothing
298 Specific (_ `As` name) -> Just $ renderSQL name
298 Specific (_ `As` name) -> Just $ renderSQL name
@@ -300,7 +300,7 @@ instance RenderSQL (QueryClause commons schemas params columns) where
300 DefaultAs _ -> Nothing
300 DefaultAs _ -> Nothing
301 Specific (value `As` _) -> Just $ renderExpression value
301 Specific (value `As` _) -> Just $ renderExpression value
302 renderSQLPart, renderValuePart
302 renderSQLPart, renderValuePart
303− :: ColumnExpression schemas params grp from column -> ByteString
303+ :: ColumnExpression grp schemas params from column -> ByteString
304 renderSQLPart = \case
304 renderSQLPart = \case
305 DefaultAs name -> renderSQL name
305 DefaultAs name -> renderSQL name
306 Specific (_ `As` name) -> renderSQL name
306 Specific (_ `As` name) -> renderSQL name
@@ -310,49 +310,49 @@ instance RenderSQL (QueryClause commons schemas params columns) where
310
310
311pattern Values_
311pattern Values_
312 :: SOP.SListI columns
312 :: SOP.SListI columns
313− => NP (ColumnExpression schemas params 'Ungrouped '[]) columns
313+ => NP (ColumnExpression 'Ungrouped schemas params '[]) columns
314 -> QueryClause commons schemas params columns
314 -> QueryClause commons schemas params columns
315pattern Values_ vals = Values vals []
315pattern Values_ vals = Values vals []
316
316
317−data ColumnExpression schemas params grp from column where
317+data ColumnExpression grp schemas params from column where
318 DefaultAs
318 DefaultAs
319 :: KnownSymbol col
319 :: KnownSymbol col
320 => Alias col
320 => Alias col
321− -> ColumnExpression schemas params grp from (col ::: 'Def :=> ty)
321+ -> ColumnExpression grp schemas params from (col ::: 'Def :=> ty)
322 Specific
322 Specific
323− :: Aliased (Expression '[] schemas params grp from) (col ::: ty)
323+ :: Aliased (Expression grp '[] schemas params from) (col ::: ty)
324− -> ColumnExpression schemas params grp from (col ::: defness :=> ty)
324+ -> ColumnExpression grp schemas params from (col ::: defness :=> ty)
325
325
326instance (KnownSymbol col, column ~ (col ::: defness :=> ty))
326instance (KnownSymbol col, column ~ (col ::: defness :=> ty))
327 => Aliasable col
327 => Aliasable col
328− (Expression '[] schemas params grp from ty)
328+ (Expression grp '[] schemas params from ty)
329− (ColumnExpression schemas params grp from column) where
329+ (ColumnExpression grp schemas params from column) where
330 expression `as` col = Specific (expression `As` col)
330 expression `as` col = Specific (expression `As` col)
331instance (KnownSymbol col, columns ~ '[col ::: defness :=> ty])
331instance (KnownSymbol col, columns ~ '[col ::: defness :=> ty])
332 => Aliasable col
332 => Aliasable col
333− (Expression '[] schemas params grp from ty)
333+ (Expression grp '[] schemas params from ty)
334− (NP (ColumnExpression schemas params grp from) columns) where
334+ (NP (ColumnExpression grp schemas params from) columns) where
335 expression `as` col = expression `as` col :* Nil
335 expression `as` col = expression `as` col :* Nil
336instance (KnownSymbol col, column ~ (col ::: 'Def :=> ty))
336instance (KnownSymbol col, column ~ (col ::: 'Def :=> ty))
337− => DefaultAliasable col (ColumnExpression schemas params grp from column) where
337+ => DefaultAliasable col (ColumnExpression grp schemas params from column) where
338 defaultAs = DefaultAs
338 defaultAs = DefaultAs
339instance (KnownSymbol col, columns ~ '[col ::: 'Def :=> ty])
339instance (KnownSymbol col, columns ~ '[col ::: 'Def :=> ty])
340− => DefaultAliasable col (NP (ColumnExpression schemas params grp from) columns) where
340+ => DefaultAliasable col (NP (ColumnExpression grp schemas params from) columns) where
341 defaultAs col = defaultAs col :* Nil
341 defaultAs col = defaultAs col :* Nil
342
342
343instance (HasUnique tab from row, Has col row ty, column ~ (col ::: defness :=> ty))
343instance (HasUnique tab from row, Has col row ty, column ~ (col ::: defness :=> ty))
344− => IsLabel col (ColumnExpression schemas params 'Ungrouped from column) where
344+ => IsLabel col (ColumnExpression 'Ungrouped schemas params from column) where
345 fromLabel = fromLabel @col `as` Alias
345 fromLabel = fromLabel @col `as` Alias
346instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: defness :=> ty])
346instance (HasUnique tab from row, Has col row ty, columns ~ '[col ::: defness :=> ty])
347 => IsLabel col
347 => IsLabel col
348− (NP (ColumnExpression schemas params 'Ungrouped from) columns) where
348+ (NP (ColumnExpression 'Ungrouped schemas params from) columns) where
349 fromLabel = fromLabel @col `as` Alias
349 fromLabel = fromLabel @col `as` Alias
350
350
351instance (Has tab from row, Has col row ty, column ~ (col ::: defness :=> ty))
351instance (Has tab from row, Has col row ty, column ~ (col ::: defness :=> ty))
352− => IsQualified tab col (ColumnExpression schemas params 'Ungrouped from column) where
352+ => IsQualified tab col (ColumnExpression 'Ungrouped schemas params from column) where
353 tab ! col = tab ! col `as` col
353 tab ! col = tab ! col `as` col
354instance (Has tab from row, Has col row ty, columns ~ '[col ::: defness :=> ty])
354instance (Has tab from row, Has col row ty, columns ~ '[col ::: defness :=> ty])
355− => IsQualified tab col (NP (ColumnExpression schemas params 'Ungrouped from) columns) where
355+ => IsQualified tab col (NP (ColumnExpression 'Ungrouped schemas params from) columns) where
356 tab ! col = tab ! col `as` col
356 tab ! col = tab ! col `as` col
357
357
358instance
358instance
@@ -361,7 +361,7 @@ instance
361 , GroupedBy tab col bys
361 , GroupedBy tab col bys
362 , column ~ (col ::: defness :=> ty)
362 , column ~ (col ::: defness :=> ty)
363 ) => IsLabel col
363 ) => IsLabel col
364− (ColumnExpression schemas params ('Grouped bys) from column) where
364+ (ColumnExpression ('Grouped bys) schemas params from column) where
365 fromLabel = fromLabel @col `as` Alias
365 fromLabel = fromLabel @col `as` Alias
366instance
366instance
367 ( HasUnique tab from row
367 ( HasUnique tab from row
@@ -369,7 +369,7 @@ instance
369 , GroupedBy tab col bys
369 , GroupedBy tab col bys
370 , columns ~ '[col ::: defness :=> ty]
370 , columns ~ '[col ::: defness :=> ty]
371 ) => IsLabel col
371 ) => IsLabel col
372− (NP (ColumnExpression schemas params ('Grouped bys) from) columns) where
372+ (NP (ColumnExpression ('Grouped bys) schemas params from) columns) where
373 fromLabel = fromLabel @col `as` Alias
373 fromLabel = fromLabel @col `as` Alias
374
374
375instance
375instance
@@ -378,7 +378,7 @@ instance
378 , GroupedBy tab col bys
378 , GroupedBy tab col bys
379 , column ~ (col ::: defness :=> ty)
379 , column ~ (col ::: defness :=> ty)
380 ) => IsQualified tab col
380 ) => IsQualified tab col
381− (ColumnExpression schemas params ('Grouped bys) from column) where
381+ (ColumnExpression ('Grouped bys) schemas params from column) where
382 tab ! col = tab ! col `as` col
382 tab ! col = tab ! col `as` col
383instance
383instance
384 ( Has tab from row
384 ( Has tab from row
@@ -386,10 +386,10 @@ instance
386 , GroupedBy tab col bys
386 , GroupedBy tab col bys
387 , columns ~ '[col ::: defness :=> ty]
387 , columns ~ '[col ::: defness :=> ty]
388 ) => IsQualified tab col
388 ) => IsQualified tab col
389− (NP (ColumnExpression schemas params ('Grouped bys) from) columns) where
389+ (NP (ColumnExpression ('Grouped bys) schemas params from) columns) where
390 tab ! col = tab ! col :* Nil
390 tab ! col = tab ! col :* Nil
391
391
392−instance RenderSQL (ColumnExpression schemas params grp from column) where
392+instance RenderSQL (ColumnExpression grp schemas params from column) where
393 renderSQL = \case
393 renderSQL = \case
394 DefaultAs col ->
394 DefaultAs col ->
395 renderSQL col <+> "=" <+> "DEFAULT"
395 renderSQL col <+> "=" <+> "DEFAULT"
@@ -407,7 +407,7 @@ instance RenderSQL (ColumnExpression schemas params grp from column) where
407-- in the row. Use @Returning Nil@ in the common case where no return
407-- in the row. Use @Returning Nil@ in the common case where no return
408-- values are desired.
408-- values are desired.
409newtype ReturningClause commons schemas params from row =
409newtype ReturningClause commons schemas params from row =
410− Returning (Selection commons schemas params 'Ungrouped from row)
410+ Returning (Selection 'Ungrouped commons schemas params from row)
411
411
412instance RenderSQL (ReturningClause commons schemas params from row) where
412instance RenderSQL (ReturningClause commons schemas params from row) where
413 renderSQL = \case
413 renderSQL = \case
@@ -416,7 +416,7 @@ instance RenderSQL (ReturningClause commons schemas params from row) where
416
416
417pattern Returning_
417pattern Returning_
418 :: SOP.SListI row
418 :: SOP.SListI row
419− => NP (Aliased (Expression commons schemas params 'Ungrouped from)) row
419+ => NP (Aliased (Expression 'Ungrouped commons schemas params from)) row
420 -> ReturningClause commons schemas params from row
420 -> ReturningClause commons schemas params from row
421pattern Returning_ list = Returning (List list)
421pattern Returning_ list = Returning (List list)
422
422
@@ -448,8 +448,8 @@ data ConflictAction tab commons schemas params columns where
448 , columns ~ (col0 ': cols)
448 , columns ~ (col0 ': cols)
449 , SOP.All (HasIn columns) subcolumns
449 , SOP.All (HasIn columns) subcolumns
450 , AllUnique subcolumns )
450 , AllUnique subcolumns )
451− => NP (ColumnExpression schemas params 'Ungrouped '[tab ::: row, "excluded" ::: row]) subcolumns
451+ => NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row, "excluded" ::: row]) subcolumns
452− -> [Condition commons schemas params 'Ungrouped '[tab ::: row, "excluded" ::: row]]
452+ -> [Condition 'Ungrouped commons schemas params '[tab ::: row, "excluded" ::: row]]
453 -> ConflictAction tab commons schemas params columns
453 -> ConflictAction tab commons schemas params columns
454
454
455instance RenderSQL (ConflictAction tab commons schemas params columns) where
455instance RenderSQL (ConflictAction tab commons schemas params columns) where
@@ -492,9 +492,9 @@ update
492 , SOP.All (HasIn columns) subcolumns
492 , SOP.All (HasIn columns) subcolumns
493 , AllUnique subcolumns )
493 , AllUnique subcolumns )
494 => QualifiedAlias sch tab -- ^ table to update
494 => QualifiedAlias sch tab -- ^ table to update
495− -> NP (ColumnExpression schemas params 'Ungrouped '[tab ::: row0]) subcolumns
495+ -> NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row0]) subcolumns
496 -- ^ modified values to replace old values
496 -- ^ modified values to replace old values
497− -> Condition commons schemas params 'Ungrouped '[tab ::: row0]
497+ -> Condition 'Ungrouped commons schemas params '[tab ::: row0]
498 -- ^ condition under which to perform update on a row
498 -- ^ condition under which to perform update on a row
499 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
499 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
500 -> Manipulation commons schemas params row1
500 -> Manipulation commons schemas params row1
@@ -517,9 +517,9 @@ update_
517 , SOP.All (HasIn columns) subcolumns
517 , SOP.All (HasIn columns) subcolumns
518 , AllUnique subcolumns )
518 , AllUnique subcolumns )
519 => QualifiedAlias sch tab -- ^ table to update
519 => QualifiedAlias sch tab -- ^ table to update
520− -> NP (ColumnExpression schemas params 'Ungrouped '[tab ::: row]) subcolumns
520+ -> NP (ColumnExpression 'Ungrouped schemas params '[tab ::: row]) subcolumns
521 -- ^ modified values to replace old values
521 -- ^ modified values to replace old values
522− -> Condition commons schemas params 'Ungrouped '[tab ::: row]
522+ -> Condition 'Ungrouped commons schemas params '[tab ::: row]
523 -- ^ condition under which to perform update on a row
523 -- ^ condition under which to perform update on a row
524 -> Manipulation commons schemas params '[]
524 -> Manipulation commons schemas params '[]
525update_ tab columns wh = update tab columns wh (Returning_ Nil)
525update_ tab columns wh = update tab columns wh (Returning_ Nil)
@@ -544,7 +544,7 @@ deleteFrom
544 , columns ~ TableToColumns table )
544 , columns ~ TableToColumns table )
545 => QualifiedAlias sch tab -- ^ table to delete from
545 => QualifiedAlias sch tab -- ^ table to delete from
546 -> UsingClause commons schemas params from
546 -> UsingClause commons schemas params from
547− -> Condition commons schemas params 'Ungrouped (tab ::: row0 ': from)
547+ -> Condition 'Ungrouped commons schemas params (tab ::: row0 ': from)
548 -- ^ condition under which to delete a row
548 -- ^ condition under which to delete a row
549 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
549 -> ReturningClause commons schemas params '[tab ::: row0] row1 -- ^ results to return
550 -> Manipulation commons schemas params row1
550 -> Manipulation commons schemas params row1
@@ -566,7 +566,7 @@ deleteFrom_
566 , columns ~ TableToColumns table )
566 , columns ~ TableToColumns table )
567 => QualifiedAlias sch tab -- ^ table to delete from
567 => QualifiedAlias sch tab -- ^ table to delete from
568 -> UsingClause commons schemas params from
568 -> UsingClause commons schemas params from
569− -> Condition commons schemas params 'Ungrouped (tab ::: row ': from)
569+ -> Condition 'Ungrouped commons schemas params (tab ::: row ': from)
570 -- ^ condition under which to delete a row
570 -- ^ condition under which to delete a row
571 -> Manipulation commons schemas params '[]
571 -> Manipulation commons schemas params '[]
572deleteFrom_ tab uses wh = deleteFrom tab uses wh (Returning_ Nil)
572deleteFrom_ tab uses wh = deleteFrom tab uses wh (Returning_ Nil)
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+147−147
@@ -405,54 +405,54 @@ q1 `exceptAll` q2 = UnsafeQuery $
405SELECT queries
405SELECT queries
406-----------------------------------------}
406-----------------------------------------}
407
407
408−data Selection commons schemas params grp from row where
408+data Selection grp commons schemas params from row where
409 List
409 List
410 :: SListI row
410 :: SListI row
411− => NP (Aliased (Expression commons schemas params grp from)) row
411+ => NP (Aliased (Expression grp commons schemas params from)) row
412− -> Selection commons schemas params grp from row
412+ -> Selection grp commons schemas params from row
413 Star
413 Star
414 :: HasUnique tab from row
414 :: HasUnique tab from row
415− => Selection commons schemas params 'Ungrouped from row
415+ => Selection 'Ungrouped commons schemas params from row
416 DotStar
416 DotStar
417 :: Has tab from row
417 :: Has tab from row
418 => Alias tab
418 => Alias tab
419− -> Selection commons schemas params 'Ungrouped from row
419+ -> Selection 'Ungrouped commons schemas params from row
420 Also
420 Also
421− :: Selection commons schemas params grp from right
421+ :: Selection grp commons schemas params from right
422− -> Selection commons schemas params grp from left
422+ -> Selection grp commons schemas params from left
423− -> Selection commons schemas params grp from (Join left right)
423+ -> Selection grp commons schemas params from (Join left right)
424 Over
424 Over
425 :: SListI row
425 :: SListI row
426− => NP (Aliased (WindowFunction commons schemas params grp from)) row
426+ => NP (Aliased (WindowFunction grp commons schemas params from)) row
427− -> WindowDefinition commons schemas params grp from
427+ -> WindowDefinition grp commons schemas params from
428− -> Selection commons schemas params grp from row
428+ -> Selection grp commons schemas params from row
429instance (KnownSymbol col, row ~ '[col ::: ty])
429instance (KnownSymbol col, row ~ '[col ::: ty])
430 => Aliasable col
430 => Aliasable col
431− (Expression commons schemas params grp from ty)
431+ (Expression grp commons schemas params from ty)
432− (Selection commons schemas params grp from row) where
432+ (Selection grp commons schemas params from row) where
433 expr `as` col = List (expr `as` col)
433 expr `as` col = List (expr `as` col)
434instance (Has tab from row0, Has col row0 ty, row1 ~ '[col ::: ty])
434instance (Has tab from row0, Has col row0 ty, row1 ~ '[col ::: ty])
435− => IsQualified tab col (Selection commons schemas params 'Ungrouped from row1) where
435+ => IsQualified tab col (Selection 'Ungrouped commons schemas params from row1) where
436 tab ! col = tab ! col `as` col
436 tab ! col = tab ! col `as` col
437instance
437instance
438 ( Has tab from row0
438 ( Has tab from row0
439 , Has col row0 ty
439 , Has col row0 ty
440 , row1 ~ '[col ::: ty]
440 , row1 ~ '[col ::: ty]
441 , GroupedBy tab col bys )
441 , GroupedBy tab col bys )
442− => IsQualified tab col (Selection commons schemas params ('Grouped bys) from row1) where
442+ => IsQualified tab col (Selection ('Grouped bys) commons schemas params from row1) where
443 tab ! col = tab ! col `as` col
443 tab ! col = tab ! col `as` col
444instance (HasUnique tab from row0, Has col row0 ty, row1 ~ '[col ::: ty])
444instance (HasUnique tab from row0, Has col row0 ty, row1 ~ '[col ::: ty])
445− => IsLabel col (Selection commons schemas params 'Ungrouped from row1) where
445+ => IsLabel col (Selection 'Ungrouped commons schemas params from row1) where
446 fromLabel = fromLabel @col `as` Alias
446 fromLabel = fromLabel @col `as` Alias
447instance
447instance
448 ( HasUnique tab from row0
448 ( HasUnique tab from row0
449 , Has col row0 ty
449 , Has col row0 ty
450 , row1 ~ '[col ::: ty]
450 , row1 ~ '[col ::: ty]
451 , GroupedBy tab col bys )
451 , GroupedBy tab col bys )
452− => IsLabel col (Selection commons schemas params ('Grouped bys) from row1) where
452+ => IsLabel col (Selection ('Grouped bys) commons schemas params from row1) where
453 fromLabel = fromLabel @col `as` Alias
453 fromLabel = fromLabel @col `as` Alias
454
454
455−instance RenderSQL (Selection commons schemas params grp from row) where
455+instance RenderSQL (Selection grp commons schemas params from row) where
456 renderSQL = \case
456 renderSQL = \case
457 List list -> renderCommaSeparated (renderAliased renderSQL) list
457 List list -> renderCommaSeparated (renderAliased renderSQL) list
458 Star -> "*"
458 Star -> "*"
@@ -461,7 +461,7 @@ instance RenderSQL (Selection commons schemas params grp from row) where
461 Over winFns winDef ->
461 Over winFns winDef ->
462 let
462 let
463 renderOver
463 renderOver
464− :: Aliased (WindowFunction commons schemas params grp from) field
464+ :: Aliased (WindowFunction grp commons schemas params from) field
465 -> ByteString
465 -> ByteString
466 renderOver (winFn `As` col) = renderSQL winFn
466 renderOver (winFn `As` col) = renderSQL winFn
467 <+> "OVER" <+> parenthesized (renderSQL winDef)
467 <+> "OVER" <+> parenthesized (renderSQL winDef)
@@ -476,9 +476,9 @@ instance RenderSQL (Selection commons schemas params grp from row) where
476-- the intermediate table are actually output.
476-- the intermediate table are actually output.
477select
477select
478 :: (SListI row, row ~ (x ': xs))
478 :: (SListI row, row ~ (x ': xs))
479− => Selection commons schemas params grp from row
479+ => Selection grp commons schemas params from row
480 -- ^ select list
480 -- ^ select list
481− -> TableExpression commons schemas params grp from
481+ -> TableExpression grp commons schemas params from
482 -- ^ intermediate virtual table
482 -- ^ intermediate virtual table
483 -> Query commons schemas params row
483 -> Query commons schemas params row
484select selection tabexpr = UnsafeQuery $
484select selection tabexpr = UnsafeQuery $
@@ -488,8 +488,8 @@ select selection tabexpr = UnsafeQuery $
488
488
489select_
489select_
490 :: (SListI row, row ~ (x ': xs))
490 :: (SListI row, row ~ (x ': xs))
491− => NP (Aliased (Expression commons schemas params grp from)) row
491+ => NP (Aliased (Expression grp commons schemas params from)) row
492− -> TableExpression commons schemas params grp from
492+ -> TableExpression grp commons schemas params from
493 -> Query commons schemas params row
493 -> Query commons schemas params row
494select_ list = select (List list)
494select_ list = select (List list)
495
495
@@ -497,9 +497,9 @@ select_ list = select (List list)
497-- be subject to the elimination of duplicate rows using `selectDistinct`.
497-- be subject to the elimination of duplicate rows using `selectDistinct`.
498selectDistinct
498selectDistinct
499 :: (SListI columns, columns ~ (col ': cols))
499 :: (SListI columns, columns ~ (col ': cols))
500− => Selection commons schemas params 'Ungrouped from columns
500+ => Selection 'Ungrouped commons schemas params from columns
501 -- ^ select list
501 -- ^ select list
502− -> TableExpression commons schemas params 'Ungrouped from
502+ -> TableExpression 'Ungrouped commons schemas params from
503 -- ^ intermediate virtual table
503 -- ^ intermediate virtual table
504 -> Query commons schemas params columns
504 -> Query commons schemas params columns
505selectDistinct selection tabexpr = UnsafeQuery $
505selectDistinct selection tabexpr = UnsafeQuery $
@@ -509,9 +509,9 @@ selectDistinct selection tabexpr = UnsafeQuery $
509
509
510selectDistinct_
510selectDistinct_
511 :: (SListI columns, columns ~ (col ': cols))
511 :: (SListI columns, columns ~ (col ': cols))
512− => NP (Aliased (Expression commons schemas params 'Ungrouped from)) columns
512+ => NP (Aliased (Expression 'Ungrouped commons schemas params from)) columns
513 -- ^ select list
513 -- ^ select list
514− -> TableExpression commons schemas params 'Ungrouped from
514+ -> TableExpression 'Ungrouped commons schemas params from
515 -- ^ intermediate virtual table
515 -- ^ intermediate virtual table
516 -> Query commons schemas params columns
516 -> Query commons schemas params columns
517selectDistinct_ list = select (List list)
517selectDistinct_ list = select (List list)
@@ -527,8 +527,8 @@ selectDistinct_ list = select (List list)
527-- SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
527-- SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
528values
528values
529 :: SListI cols
529 :: SListI cols
530− => NP (Aliased (Expression commons schemas params 'Ungrouped '[] )) cols
530+ => NP (Aliased (Expression 'Ungrouped commons schemas params '[] )) cols
531− -> [NP (Aliased (Expression commons schemas params 'Ungrouped '[] )) cols]
531+ -> [NP (Aliased (Expression 'Ungrouped commons schemas params '[] )) cols]
532 -- ^ When more than one row is specified, all the rows must
532 -- ^ When more than one row is specified, all the rows must
533 -- must have the same number of elements
533 -- must have the same number of elements
534 -> Query commons schemas params cols
534 -> Query commons schemas params cols
@@ -542,7 +542,7 @@ values rw rws = UnsafeQuery $ "SELECT * FROM"
542 <+> parenthesized (renderCommaSeparated renderAliasPart rw)
542 <+> parenthesized (renderCommaSeparated renderAliasPart rw)
543 where
543 where
544 renderAliasPart, renderValuePart
544 renderAliasPart, renderValuePart
545− :: Aliased (Expression commons schemas params 'Ungrouped '[] ) ty -> ByteString
545+ :: Aliased (Expression 'Ungrouped commons schemas params '[] ) ty -> ByteString
546 renderAliasPart (_ `As` name) = renderSQL name
546 renderAliasPart (_ `As` name) = renderSQL name
547 renderValuePart (value `As` _) = renderSQL value
547 renderValuePart (value `As` _) = renderSQL value
548
548
@@ -550,7 +550,7 @@ values rw rws = UnsafeQuery $ "SELECT * FROM"
550-- specified by value expressions.
550-- specified by value expressions.
551values_
551values_
552 :: SListI cols
552 :: SListI cols
553− => NP (Aliased (Expression commons schemas params 'Ungrouped '[] )) cols
553+ => NP (Aliased (Expression 'Ungrouped commons schemas params '[] )) cols
554 -- ^ one row of values
554 -- ^ one row of values
555 -> Query commons schemas params cols
555 -> Query commons schemas params cols
556values_ rw = values rw []
556values_ rw = values rw []
@@ -566,16 +566,16 @@ Table Expressions
566-- to a table on disk, a so-called base table, but more complex expressions
566-- to a table on disk, a so-called base table, but more complex expressions
567-- can be used to modify or combine base tables in various ways.
567-- can be used to modify or combine base tables in various ways.
568data TableExpression
568data TableExpression
569+ (grp :: Grouping)
569 (commons :: FromType)
570 (commons :: FromType)
570 (schemas :: SchemasType)
571 (schemas :: SchemasType)
571 (params :: [NullityType])
572 (params :: [NullityType])
572− (grp :: Grouping)
573 (from :: FromType)
573 (from :: FromType)
574 = TableExpression
574 = TableExpression
575 { fromClause :: FromClause commons schemas params from
575 { fromClause :: FromClause commons schemas params from
576 -- ^ A table reference that can be a table name, or a derived table such
576 -- ^ A table reference that can be a table name, or a derived table such
577 -- as a subquery, a @JOIN@ construct, or complex combinations of these.
577 -- as a subquery, a @JOIN@ construct, or complex combinations of these.
578− , whereClause :: [Condition commons schemas params 'Ungrouped from]
578+ , whereClause :: [Condition 'Ungrouped commons schemas params from]
579 -- ^ optional search coditions, combined with `.&&`. After the processing
579 -- ^ optional search coditions, combined with `.&&`. After the processing
580 -- of the `fromClause` is done, each row of the derived virtual table
580 -- of the `fromClause` is done, each row of the derived virtual table
581 -- is checked against the search condition. If the result of the
581 -- is checked against the search condition. If the result of the
@@ -591,13 +591,13 @@ data TableExpression
591 -- set of rows having common values into one group row that represents all
591 -- set of rows having common values into one group row that represents all
592 -- rows in the group. This is done to eliminate redundancy in the output
592 -- rows in the group. This is done to eliminate redundancy in the output
593 -- and/or compute aggregates that apply to these groups.
593 -- and/or compute aggregates that apply to these groups.
594− , havingClause :: HavingClause commons schemas params grp from
594+ , havingClause :: HavingClause grp commons schemas params from
595 -- ^ If a table has been grouped using `groupBy`, but only certain groups
595 -- ^ If a table has been grouped using `groupBy`, but only certain groups
596 -- are of interest, the `havingClause` can be used, much like a
596 -- are of interest, the `havingClause` can be used, much like a
597 -- `whereClause`, to eliminate groups from the result. Expressions in the
597 -- `whereClause`, to eliminate groups from the result. Expressions in the
598 -- `havingClause` can refer both to grouped expressions and to ungrouped
598 -- `havingClause` can refer both to grouped expressions and to ungrouped
599 -- expressions (which necessarily involve an aggregate function).
599 -- expressions (which necessarily involve an aggregate function).
600− , orderByClause :: [SortExpression commons schemas params grp from]
600+ , orderByClause :: [SortExpression grp commons schemas params from]
601 -- ^ The `orderByClause` is for optional sorting. When more than one
601 -- ^ The `orderByClause` is for optional sorting. When more than one
602 -- `SortExpression` is specified, the later (right) values are used to sort
602 -- `SortExpression` is specified, the later (right) values are used to sort
603 -- rows that are equal according to the earlier (left) values.
603 -- rows that are equal according to the earlier (left) values.
@@ -614,7 +614,7 @@ data TableExpression
614 }
614 }
615
615
616-- | Render a `TableExpression`
616-- | Render a `TableExpression`
617−instance RenderSQL (TableExpression commons schemas params grp from) where
617+instance RenderSQL (TableExpression grp commons schemas params from) where
618 renderSQL
618 renderSQL
619 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
619 (TableExpression frm' whs' grps' hvs' srts' lims' offs') = mconcat
620 [ "FROM ", renderSQL frm'
620 [ "FROM ", renderSQL frm'
@@ -648,15 +648,15 @@ instance RenderSQL (TableExpression commons schemas params grp from) where
648-- to match the left-to-right sequencing of their placement in SQL.
648-- to match the left-to-right sequencing of their placement in SQL.
649from
649from
650 :: FromClause commons schemas params from -- ^ table reference
650 :: FromClause commons schemas params from -- ^ table reference
651− -> TableExpression commons schemas params 'Ungrouped from
651+ -> TableExpression 'Ungrouped commons schemas params from
652from rels = TableExpression rels [] NoGroups NoHaving [] [] []
652from rels = TableExpression rels [] NoGroups NoHaving [] [] []
653
653
654-- | A `where_` is an endomorphism of `TableExpression`s which adds a
654-- | A `where_` is an endomorphism of `TableExpression`s which adds a
655-- search condition to the `whereClause`.
655-- search condition to the `whereClause`.
656where_
656where_
657− :: Condition commons schemas params 'Ungrouped from -- ^ filtering condition
657+ :: Condition 'Ungrouped commons schemas params from -- ^ filtering condition
658− -> TableExpression commons schemas params grp from
658+ -> TableExpression grp commons schemas params from
659− -> TableExpression commons schemas params grp from
659+ -> TableExpression grp commons schemas params from
660where_ wh rels = rels {whereClause = wh : whereClause rels}
660where_ wh rels = rels {whereClause = wh : whereClause rels}
661
661
662-- | A `groupBy` is a transformation of `TableExpression`s which switches
662-- | A `groupBy` is a transformation of `TableExpression`s which switches
@@ -665,8 +665,8 @@ where_ wh rels = rels {whereClause = wh : whereClause rels}
665groupBy
665groupBy
666 :: SListI bys
666 :: SListI bys
667 => NP (By from) bys -- ^ grouped columns
667 => NP (By from) bys -- ^ grouped columns
668− -> TableExpression commons schemas params 'Ungrouped from
668+ -> TableExpression 'Ungrouped commons schemas params from
669− -> TableExpression commons schemas params ('Grouped bys) from
669+ -> TableExpression ('Grouped bys) commons schemas params from
670groupBy bys rels = TableExpression
670groupBy bys rels = TableExpression
671 { fromClause = fromClause rels
671 { fromClause = fromClause rels
672 , whereClause = whereClause rels
672 , whereClause = whereClause rels
@@ -680,9 +680,9 @@ groupBy bys rels = TableExpression
680-- | A `having` is an endomorphism of `TableExpression`s which adds a
680-- | A `having` is an endomorphism of `TableExpression`s which adds a
681-- search condition to the `havingClause`.
681-- search condition to the `havingClause`.
682having
682having
683− :: Condition commons schemas params ('Grouped bys) from -- ^ having condition
683+ :: Condition ('Grouped bys) commons schemas params from -- ^ having condition
684− -> TableExpression commons schemas params ('Grouped bys) from
684+ -> TableExpression ('Grouped bys) commons schemas params from
685− -> TableExpression commons schemas params ('Grouped bys) from
685+ -> TableExpression ('Grouped bys) commons schemas params from
686having hv rels = rels
686having hv rels = rels
687 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
687 { havingClause = case havingClause rels of Having hvs -> Having (hv:hvs) }
688
688
@@ -693,16 +693,16 @@ instance OrderBy TableExpression where
693-- `limitClause`.
693-- `limitClause`.
694limit
694limit
695 :: Word64 -- ^ limit parameter
695 :: Word64 -- ^ limit parameter
696− -> TableExpression commons schemas params grp from
696+ -> TableExpression grp commons schemas params from
697− -> TableExpression commons schemas params grp from
697+ -> TableExpression grp commons schemas params from
698limit lim rels = rels {limitClause = lim : limitClause rels}
698limit lim rels = rels {limitClause = lim : limitClause rels}
699
699
700-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
700-- | An `offset` is an endomorphism of `TableExpression`s which adds to the
701-- `offsetClause`.
701-- `offsetClause`.
702offset
702offset
703 :: Word64 -- ^ offset parameter
703 :: Word64 -- ^ offset parameter
704− -> TableExpression commons schemas params grp from
704+ -> TableExpression grp commons schemas params from
705− -> TableExpression commons schemas params grp from
705+ -> TableExpression grp commons schemas params from
706offset off rels = rels {offsetClause = off : offsetClause rels}
706offset off rels = rels {offsetClause = off : offsetClause rels}
707
707
708{-----------------------------------------
708{-----------------------------------------
@@ -711,55 +711,55 @@ JSON stuff
711
711
712unsafeSetOfFunction
712unsafeSetOfFunction
713 :: ByteString
713 :: ByteString
714− -> Expression commons schemas params 'Ungrouped '[] ty
714+ -> Expression 'Ungrouped commons schemas params '[] ty
715 -> Query commons schemas params row
715 -> Query commons schemas params row
716unsafeSetOfFunction fun expr = UnsafeQuery $
716unsafeSetOfFunction fun expr = UnsafeQuery $
717 "SELECT * FROM " <> fun <> "(" <> renderSQL expr <> ")"
717 "SELECT * FROM " <> fun <> "(" <> renderSQL expr <> ")"
718
718
719-- | Expands the outermost JSON object into a set of key/value pairs.
719-- | Expands the outermost JSON object into a set of key/value pairs.
720jsonEach
720jsonEach
721− :: Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json object
721+ :: Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
722 -> Query commons schemas params
722 -> Query commons schemas params
723 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]
723 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]
724jsonEach = unsafeSetOfFunction "json_each"
724jsonEach = unsafeSetOfFunction "json_each"
725
725
726-- | Expands the outermost binary JSON object into a set of key/value pairs.
726-- | Expands the outermost binary JSON object into a set of key/value pairs.
727jsonbEach
727jsonbEach
728− :: Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb object
728+ :: Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
729 -> Query commons schemas params
729 -> Query commons schemas params
730 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjsonb]
730 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjsonb]
731jsonbEach = unsafeSetOfFunction "jsonb_each"
731jsonbEach = unsafeSetOfFunction "jsonb_each"
732
732
733-- | Expands the outermost JSON object into a set of key/value pairs.
733-- | Expands the outermost JSON object into a set of key/value pairs.
734jsonEachAsText
734jsonEachAsText
735− :: Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json object
735+ :: Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
736 -> Query commons schemas params
736 -> Query commons schemas params
737 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]
737 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]
738jsonEachAsText = unsafeSetOfFunction "json_each_text"
738jsonEachAsText = unsafeSetOfFunction "json_each_text"
739
739
740-- | Expands the outermost binary JSON object into a set of key/value pairs.
740-- | Expands the outermost binary JSON object into a set of key/value pairs.
741jsonbEachAsText
741jsonbEachAsText
742− :: Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb object
742+ :: Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
743 -> Query commons schemas params
743 -> Query commons schemas params
744 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]
744 '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]
745jsonbEachAsText = unsafeSetOfFunction "jsonb_each_text"
745jsonbEachAsText = unsafeSetOfFunction "jsonb_each_text"
746
746
747-- | Returns set of keys in the outermost JSON object.
747-- | Returns set of keys in the outermost JSON object.
748jsonObjectKeys
748jsonObjectKeys
749− :: Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json object
749+ :: Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
750 -> Query commons schemas params '["json_object_keys" ::: 'NotNull 'PGtext]
750 -> Query commons schemas params '["json_object_keys" ::: 'NotNull 'PGtext]
751jsonObjectKeys = unsafeSetOfFunction "json_object_keys"
751jsonObjectKeys = unsafeSetOfFunction "json_object_keys"
752
752
753-- | Returns set of keys in the outermost JSON object.
753-- | Returns set of keys in the outermost JSON object.
754jsonbObjectKeys
754jsonbObjectKeys
755− :: Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb object
755+ :: Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
756 -> Query commons schemas params '["jsonb_object_keys" ::: 'NotNull 'PGtext]
756 -> Query commons schemas params '["jsonb_object_keys" ::: 'NotNull 'PGtext]
757jsonbObjectKeys = unsafeSetOfFunction "jsonb_object_keys"
757jsonbObjectKeys = unsafeSetOfFunction "jsonb_object_keys"
758
758
759unsafePopulateFunction
759unsafePopulateFunction
760 :: ByteString
760 :: ByteString
761 -> TypeExpression schemas (nullity ('PGcomposite row))
761 -> TypeExpression schemas (nullity ('PGcomposite row))
762− -> Expression commons schemas params 'Ungrouped '[] ty
762+ -> Expression 'Ungrouped commons schemas params '[] ty
763 -> Query commons schemas params row
763 -> Query commons schemas params row
764unsafePopulateFunction fun ty expr = UnsafeQuery $
764unsafePopulateFunction fun ty expr = UnsafeQuery $
765 "SELECT * FROM " <> fun <> "("
765 "SELECT * FROM " <> fun <> "("
@@ -770,7 +770,7 @@ unsafePopulateFunction fun ty expr = UnsafeQuery $
770-- type defined by the given table.
770-- type defined by the given table.
771jsonPopulateRecord
771jsonPopulateRecord
772 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
772 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
773− -> Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json object
773+ -> Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
774 -> Query commons schemas params row
774 -> Query commons schemas params row
775jsonPopulateRecord = unsafePopulateFunction "json_populate_record"
775jsonPopulateRecord = unsafePopulateFunction "json_populate_record"
776
776
@@ -778,7 +778,7 @@ jsonPopulateRecord = unsafePopulateFunction "json_populate_record"
778-- type defined by the given table.
778-- type defined by the given table.
779jsonbPopulateRecord
779jsonbPopulateRecord
780 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
780 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
781− -> Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb object
781+ -> Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
782 -> Query commons schemas params row
782 -> Query commons schemas params row
783jsonbPopulateRecord = unsafePopulateFunction "jsonb_populate_record"
783jsonbPopulateRecord = unsafePopulateFunction "jsonb_populate_record"
784
784
@@ -786,7 +786,7 @@ jsonbPopulateRecord = unsafePopulateFunction "jsonb_populate_record"
786-- set of rows whose columns match the record type defined by the given table.
786-- set of rows whose columns match the record type defined by the given table.
787jsonPopulateRecordSet
787jsonPopulateRecordSet
788 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
788 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
789− -> Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json array
789+ -> Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json array
790 -> Query commons schemas params row
790 -> Query commons schemas params row
791jsonPopulateRecordSet = unsafePopulateFunction "json_populate_record_set"
791jsonPopulateRecordSet = unsafePopulateFunction "json_populate_record_set"
792
792
@@ -795,14 +795,14 @@ jsonPopulateRecordSet = unsafePopulateFunction "json_populate_record_set"
795-- table.
795-- table.
796jsonbPopulateRecordSet
796jsonbPopulateRecordSet
797 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
797 :: TypeExpression schemas (nullity ('PGcomposite row)) -- ^ row type
798− -> Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb array
798+ -> Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb array
799 -> Query commons schemas params row
799 -> Query commons schemas params row
800jsonbPopulateRecordSet = unsafePopulateFunction "jsonb_populate_record_set"
800jsonbPopulateRecordSet = unsafePopulateFunction "jsonb_populate_record_set"
801
801
802unsafeRecordFunction
802unsafeRecordFunction
803 :: (SListI record, json `In` PGJsonType)
803 :: (SListI record, json `In` PGJsonType)
804 => ByteString
804 => ByteString
805− -> Expression commons schemas params 'Ungrouped '[] (nullity json)
805+ -> Expression 'Ungrouped commons schemas params '[] (nullity json)
806 -> NP (Aliased (TypeExpression schemas)) record
806 -> NP (Aliased (TypeExpression schemas)) record
807 -> Query commons schemas params record
807 -> Query commons schemas params record
808unsafeRecordFunction fun expr types = UnsafeQuery $
808unsafeRecordFunction fun expr types = UnsafeQuery $
@@ -817,7 +817,7 @@ unsafeRecordFunction fun expr types = UnsafeQuery $
817-- | Builds an arbitrary record from a JSON object.
817-- | Builds an arbitrary record from a JSON object.
818jsonToRecord
818jsonToRecord
819 :: SListI record
819 :: SListI record
820− => Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json object
820+ => Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json object
821 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
821 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
822 -> Query commons schemas params record
822 -> Query commons schemas params record
823jsonToRecord = unsafeRecordFunction "json_to_record"
823jsonToRecord = unsafeRecordFunction "json_to_record"
@@ -825,7 +825,7 @@ jsonToRecord = unsafeRecordFunction "json_to_record"
825-- | Builds an arbitrary record from a binary JSON object.
825-- | Builds an arbitrary record from a binary JSON object.
826jsonbToRecord
826jsonbToRecord
827 :: SListI record
827 :: SListI record
828− => Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb object
828+ => Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb object
829 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
829 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
830 -> Query commons schemas params record
830 -> Query commons schemas params record
831jsonbToRecord = unsafeRecordFunction "jsonb_to_record"
831jsonbToRecord = unsafeRecordFunction "jsonb_to_record"
@@ -833,7 +833,7 @@ jsonbToRecord = unsafeRecordFunction "jsonb_to_record"
833-- | Builds an arbitrary set of records from a JSON array of objects.
833-- | Builds an arbitrary set of records from a JSON array of objects.
834jsonToRecordSet
834jsonToRecordSet
835 :: SListI record
835 :: SListI record
836− => Expression commons schemas params 'Ungrouped '[] (nullity 'PGjson) -- ^ json array
836+ => Expression 'Ungrouped commons schemas params '[] (nullity 'PGjson) -- ^ json array
837 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
837 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
838 -> Query commons schemas params record
838 -> Query commons schemas params record
839jsonToRecordSet = unsafeRecordFunction "json_to_record_set"
839jsonToRecordSet = unsafeRecordFunction "json_to_record_set"
@@ -841,7 +841,7 @@ jsonToRecordSet = unsafeRecordFunction "json_to_record_set"
841-- | Builds an arbitrary set of records from a binary JSON array of objects.
841-- | Builds an arbitrary set of records from a binary JSON array of objects.
842jsonbToRecordSet
842jsonbToRecordSet
843 :: SListI record
843 :: SListI record
844− => Expression commons schemas params 'Ungrouped '[] (nullity 'PGjsonb) -- ^ jsonb array
844+ => Expression 'Ungrouped commons schemas params '[] (nullity 'PGjsonb) -- ^ jsonb array
845 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
845 -> NP (Aliased (TypeExpression schemas)) record -- ^ record types
846 -> Query commons schemas params record
846 -> Query commons schemas params record
847jsonbToRecordSet = unsafeRecordFunction "jsonb_to_record_set"
847jsonbToRecordSet = unsafeRecordFunction "jsonb_to_record_set"
@@ -910,7 +910,7 @@ the @on@ condition.
910innerJoin
910innerJoin
911 :: FromClause commons schemas params right
911 :: FromClause commons schemas params right
912 -- ^ right
912 -- ^ right
913− -> Condition commons schemas params 'Ungrouped (Join left right)
913+ -> Condition 'Ungrouped commons schemas params (Join left right)
914 -- ^ @on@ condition
914 -- ^ @on@ condition
915 -> FromClause commons schemas params left
915 -> FromClause commons schemas params left
916 -- ^ left
916 -- ^ left
@@ -927,7 +927,7 @@ innerJoin right on left = UnsafeFromClause $
927leftOuterJoin
927leftOuterJoin
928 :: FromClause commons schemas params right
928 :: FromClause commons schemas params right
929 -- ^ right
929 -- ^ right
930− -> Condition commons schemas params 'Ungrouped (Join left right)
930+ -> Condition 'Ungrouped commons schemas params (Join left right)
931 -- ^ @on@ condition
931 -- ^ @on@ condition
932 -> FromClause commons schemas params left
932 -> FromClause commons schemas params left
933 -- ^ left
933 -- ^ left
@@ -945,7 +945,7 @@ leftOuterJoin right on left = UnsafeFromClause $
945rightOuterJoin
945rightOuterJoin
946 :: FromClause commons schemas params right
946 :: FromClause commons schemas params right
947 -- ^ right
947 -- ^ right
948− -> Condition commons schemas params 'Ungrouped (Join left right)
948+ -> Condition 'Ungrouped commons schemas params (Join left right)
949 -- ^ @on@ condition
949 -- ^ @on@ condition
950 -> FromClause commons schemas params left
950 -> FromClause commons schemas params left
951 -- ^ left
951 -- ^ left
@@ -964,7 +964,7 @@ rightOuterJoin right on left = UnsafeFromClause $
964fullOuterJoin
964fullOuterJoin
965 :: FromClause commons schemas params right
965 :: FromClause commons schemas params right
966 -- ^ right
966 -- ^ right
967− -> Condition commons schemas params 'Ungrouped (Join left right)
967+ -> Condition 'Ungrouped commons schemas params (Join left right)
968 -- ^ @on@ condition
968 -- ^ @on@ condition
969 -> FromClause commons schemas params left
969 -> FromClause commons schemas params left
970 -- ^ left
970 -- ^ left
@@ -1037,17 +1037,17 @@ instance RenderSQL (GroupByClause grp from) where
1037-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1037-- An `Ungrouped` `TableExpression` may only use `NoHaving` while a `Grouped`
1038-- `TableExpression` must use `Having` whose conditions are combined with
1038-- `TableExpression` must use `Having` whose conditions are combined with
1039-- `.&&`.
1039-- `.&&`.
1040−data HavingClause commons schemas params grp from where
1040+data HavingClause grp commons schemas params from where
1041− NoHaving :: HavingClause commons schemas params 'Ungrouped from
1041+ NoHaving :: HavingClause 'Ungrouped commons schemas params from
1042 Having
1042 Having
1043− :: [Condition commons schemas params ('Grouped bys) from]
1043+ :: [Condition ('Grouped bys) commons schemas params from]
1044− -> HavingClause commons schemas params ('Grouped bys) from
1044+ -> HavingClause ('Grouped bys) commons schemas params from
1045−deriving instance Show (HavingClause commons schemas params grp from)
1045+deriving instance Show (HavingClause grp commons schemas params from)
1046−deriving instance Eq (HavingClause commons schemas params grp from)
1046+deriving instance Eq (HavingClause grp commons schemas params from)
1047−deriving instance Ord (HavingClause commons schemas params grp from)
1047+deriving instance Ord (HavingClause grp commons schemas params from)
1048
1048
1049-- | Render a `HavingClause`.
1049-- | Render a `HavingClause`.
1050−instance RenderSQL (HavingClause commons schemas params grp from) where
1050+instance RenderSQL (HavingClause grp commons schemas params from) where
1051 renderSQL = \case
1051 renderSQL = \case
1052 NoHaving -> ""
1052 NoHaving -> ""
1053 Having [] -> ""
1053 Having [] -> ""
@@ -1056,18 +1056,18 @@ instance RenderSQL (HavingClause commons schemas params grp from) where
1056
1056
1057unsafeSubqueryExpression
1057unsafeSubqueryExpression
1058 :: ByteString
1058 :: ByteString
1059− -> Expression commons schemas params grp from ty
1059+ -> Expression grp commons schemas params from ty
1060 -> Query commons schemas params '[alias ::: ty]
1060 -> Query commons schemas params '[alias ::: ty]
1061− -> Expression commons schemas params grp from (nullity 'PGbool)
1061+ -> Expression grp commons schemas params from (nullity 'PGbool)
1062unsafeSubqueryExpression op x q = UnsafeExpression $
1062unsafeSubqueryExpression op x q = UnsafeExpression $
1063 renderSQL x <+> op <+> parenthesized (renderSQL q)
1063 renderSQL x <+> op <+> parenthesized (renderSQL q)
1064
1064
1065unsafeRowSubqueryExpression
1065unsafeRowSubqueryExpression
1066 :: SListI row
1066 :: SListI row
1067 => ByteString
1067 => ByteString
1068− -> NP (Aliased (Expression commons schemas params grp from)) row
1068+ -> NP (Aliased (Expression grp commons schemas params from)) row
1069 -> Query commons schemas params row
1069 -> Query commons schemas params row
1070− -> Expression commons schemas params grp from (nullity 'PGbool)
1070+ -> Expression grp commons schemas params from (nullity 'PGbool)
1071unsafeRowSubqueryExpression op xs q = UnsafeExpression $
1071unsafeRowSubqueryExpression op xs q = UnsafeExpression $
1072 renderSQL (row xs) <+> op <+> parenthesized (renderSQL q)
1072 renderSQL (row xs) <+> op <+> parenthesized (renderSQL q)
1073
1073
@@ -1080,9 +1080,9 @@ unsafeRowSubqueryExpression op xs q = UnsafeExpression $
1080-- >>> printSQL $ true `in_` values_ (true `as` #foo)
1080-- >>> printSQL $ true `in_` values_ (true `as` #foo)
1081-- TRUE IN (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1081-- TRUE IN (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1082in_
1082in_
1083− :: Expression commons schemas params grp from ty -- ^ expression
1083+ :: Expression grp commons schemas params from ty -- ^ expression
1084 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1084 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1085− -> Expression commons schemas params grp from (nullity 'PGbool)
1085+ -> Expression grp commons schemas params from (nullity 'PGbool)
1086in_ = unsafeSubqueryExpression "IN"
1086in_ = unsafeSubqueryExpression "IN"
1087
1087
1088{- | The left-hand side of this form of `rowIn` is a row constructor.
1088{- | The left-hand side of this form of `rowIn` is a row constructor.
@@ -1095,231 +1095,231 @@ is `true` if any equal subquery row is found.
1095The result is `false` if no equal row is found
1095The result is `false` if no equal row is found
1096(including the case where the subquery returns no rows).
1096(including the case where the subquery returns no rows).
1097
1097
1098−>>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1098+>>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1099>>> printSQL $ myRow `rowIn` values_ myRow
1099>>> printSQL $ myRow `rowIn` values_ myRow
1100ROW(1, FALSE) IN (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1100ROW(1, FALSE) IN (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1101-}
1101-}
1102rowIn
1102rowIn
1103 :: SListI row
1103 :: SListI row
1104− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1104+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1105 -> Query commons schemas params row -- ^ subquery
1105 -> Query commons schemas params row -- ^ subquery
1106− -> Expression commons schemas params grp from (nullity 'PGbool)
1106+ -> Expression grp commons schemas params from (nullity 'PGbool)
1107rowIn = unsafeRowSubqueryExpression "IN"
1107rowIn = unsafeRowSubqueryExpression "IN"
1108
1108
1109-- | >>> printSQL $ true `eqAll` values_ (true `as` #foo)
1109-- | >>> printSQL $ true `eqAll` values_ (true `as` #foo)
1110-- TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1110-- TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1111eqAll
1111eqAll
1112− :: Expression commons schemas params grp from ty -- ^ expression
1112+ :: Expression grp commons schemas params from ty -- ^ expression
1113 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1113 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1114− -> Expression commons schemas params grp from (nullity 'PGbool)
1114+ -> Expression grp commons schemas params from (nullity 'PGbool)
1115eqAll = unsafeSubqueryExpression "= ALL"
1115eqAll = unsafeSubqueryExpression "= ALL"
1116
1116
1117−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1117+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1118-- >>> printSQL $ myRow `rowEqAll` values_ myRow
1118-- >>> printSQL $ myRow `rowEqAll` values_ myRow
1119-- ROW(1, FALSE) = ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1119-- ROW(1, FALSE) = ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1120rowEqAll
1120rowEqAll
1121 :: SListI row
1121 :: SListI row
1122− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1122+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1123 -> Query commons schemas params row -- ^ subquery
1123 -> Query commons schemas params row -- ^ subquery
1124− -> Expression commons schemas params grp from (nullity 'PGbool)
1124+ -> Expression grp commons schemas params from (nullity 'PGbool)
1125rowEqAll = unsafeRowSubqueryExpression "= ALL"
1125rowEqAll = unsafeRowSubqueryExpression "= ALL"
1126
1126
1127-- | >>> printSQL $ true `eqAny` values_ (true `as` #foo)
1127-- | >>> printSQL $ true `eqAny` values_ (true `as` #foo)
1128-- TRUE = ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1128-- TRUE = ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1129eqAny
1129eqAny
1130− :: Expression commons schemas params grp from ty -- ^ expression
1130+ :: Expression grp commons schemas params from ty -- ^ expression
1131 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1131 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1132− -> Expression commons schemas params grp from (nullity 'PGbool)
1132+ -> Expression grp commons schemas params from (nullity 'PGbool)
1133eqAny = unsafeSubqueryExpression "= ANY"
1133eqAny = unsafeSubqueryExpression "= ANY"
1134
1134
1135−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1135+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1136-- >>> printSQL $ myRow `rowEqAny` values_ myRow
1136-- >>> printSQL $ myRow `rowEqAny` values_ myRow
1137-- ROW(1, FALSE) = ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1137-- ROW(1, FALSE) = ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1138rowEqAny
1138rowEqAny
1139 :: SListI row
1139 :: SListI row
1140− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1140+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1141 -> Query commons schemas params row -- ^ subquery
1141 -> Query commons schemas params row -- ^ subquery
1142− -> Expression commons schemas params grp from (nullity 'PGbool)
1142+ -> Expression grp commons schemas params from (nullity 'PGbool)
1143rowEqAny = unsafeRowSubqueryExpression "= ANY"
1143rowEqAny = unsafeRowSubqueryExpression "= ANY"
1144
1144
1145-- | >>> printSQL $ true `neqAll` values_ (true `as` #foo)
1145-- | >>> printSQL $ true `neqAll` values_ (true `as` #foo)
1146-- TRUE <> ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1146-- TRUE <> ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1147neqAll
1147neqAll
1148− :: Expression commons schemas params grp from ty -- ^ expression
1148+ :: Expression grp commons schemas params from ty -- ^ expression
1149 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1149 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1150− -> Expression commons schemas params grp from (nullity 'PGbool)
1150+ -> Expression grp commons schemas params from (nullity 'PGbool)
1151neqAll = unsafeSubqueryExpression "<> ALL"
1151neqAll = unsafeSubqueryExpression "<> ALL"
1152
1152
1153−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1153+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1154-- >>> printSQL $ myRow `rowNeqAll` values_ myRow
1154-- >>> printSQL $ myRow `rowNeqAll` values_ myRow
1155-- ROW(1, FALSE) <> ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1155-- ROW(1, FALSE) <> ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1156rowNeqAll
1156rowNeqAll
1157 :: SListI row
1157 :: SListI row
1158− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1158+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1159 -> Query commons schemas params row -- ^ subquery
1159 -> Query commons schemas params row -- ^ subquery
1160− -> Expression commons schemas params grp from (nullity 'PGbool)
1160+ -> Expression grp commons schemas params from (nullity 'PGbool)
1161rowNeqAll = unsafeRowSubqueryExpression "<> ALL"
1161rowNeqAll = unsafeRowSubqueryExpression "<> ALL"
1162
1162
1163-- | >>> printSQL $ true `neqAny` values_ (true `as` #foo)
1163-- | >>> printSQL $ true `neqAny` values_ (true `as` #foo)
1164-- TRUE <> ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1164-- TRUE <> ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1165neqAny
1165neqAny
1166− :: Expression commons schemas params grp from ty -- ^ expression
1166+ :: Expression grp commons schemas params from ty -- ^ expression
1167 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1167 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1168− -> Expression commons schemas params grp from (nullity 'PGbool)
1168+ -> Expression grp commons schemas params from (nullity 'PGbool)
1169neqAny = unsafeSubqueryExpression "<> ANY"
1169neqAny = unsafeSubqueryExpression "<> ANY"
1170
1170
1171−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1171+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1172-- >>> printSQL $ myRow `rowNeqAny` values_ myRow
1172-- >>> printSQL $ myRow `rowNeqAny` values_ myRow
1173-- ROW(1, FALSE) <> ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1173-- ROW(1, FALSE) <> ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1174rowNeqAny
1174rowNeqAny
1175 :: SListI row
1175 :: SListI row
1176− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1176+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1177 -> Query commons schemas params row -- ^ subquery
1177 -> Query commons schemas params row -- ^ subquery
1178− -> Expression commons schemas params grp from (nullity 'PGbool)
1178+ -> Expression grp commons schemas params from (nullity 'PGbool)
1179rowNeqAny = unsafeRowSubqueryExpression "<> ANY"
1179rowNeqAny = unsafeRowSubqueryExpression "<> ANY"
1180
1180
1181-- | >>> printSQL $ true `allLt` values_ (true `as` #foo)
1181-- | >>> printSQL $ true `allLt` values_ (true `as` #foo)
1182-- TRUE ALL < (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1182-- TRUE ALL < (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1183allLt
1183allLt
1184− :: Expression commons schemas params grp from ty -- ^ expression
1184+ :: Expression grp commons schemas params from ty -- ^ expression
1185 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1185 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1186− -> Expression commons schemas params grp from (nullity 'PGbool)
1186+ -> Expression grp commons schemas params from (nullity 'PGbool)
1187allLt = unsafeSubqueryExpression "ALL <"
1187allLt = unsafeSubqueryExpression "ALL <"
1188
1188
1189−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1189+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1190-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1190-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1191-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1191-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1192rowLtAll
1192rowLtAll
1193 :: SListI row
1193 :: SListI row
1194− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1194+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1195 -> Query commons schemas params row -- ^ subquery
1195 -> Query commons schemas params row -- ^ subquery
1196− -> Expression commons schemas params grp from (nullity 'PGbool)
1196+ -> Expression grp commons schemas params from (nullity 'PGbool)
1197rowLtAll = unsafeRowSubqueryExpression "ALL <"
1197rowLtAll = unsafeRowSubqueryExpression "ALL <"
1198
1198
1199-- | >>> printSQL $ true `ltAny` values_ (true `as` #foo)
1199-- | >>> printSQL $ true `ltAny` values_ (true `as` #foo)
1200-- TRUE ANY < (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1200-- TRUE ANY < (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1201ltAny
1201ltAny
1202− :: Expression commons schemas params grp from ty -- ^ expression
1202+ :: Expression grp commons schemas params from ty -- ^ expression
1203 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1203 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1204− -> Expression commons schemas params grp from (nullity 'PGbool)
1204+ -> Expression grp commons schemas params from (nullity 'PGbool)
1205ltAny = unsafeSubqueryExpression "ANY <"
1205ltAny = unsafeSubqueryExpression "ANY <"
1206
1206
1207−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1207+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1208-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1208-- >>> printSQL $ myRow `rowLtAll` values_ myRow
1209-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1209-- ROW(1, FALSE) ALL < (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1210rowLtAny
1210rowLtAny
1211 :: SListI row
1211 :: SListI row
1212− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1212+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1213 -> Query commons schemas params row -- ^ subquery
1213 -> Query commons schemas params row -- ^ subquery
1214− -> Expression commons schemas params grp from (nullity 'PGbool)
1214+ -> Expression grp commons schemas params from (nullity 'PGbool)
1215rowLtAny = unsafeRowSubqueryExpression "ANY <"
1215rowLtAny = unsafeRowSubqueryExpression "ANY <"
1216
1216
1217-- | >>> printSQL $ true `lteAll` values_ (true `as` #foo)
1217-- | >>> printSQL $ true `lteAll` values_ (true `as` #foo)
1218-- TRUE <= ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1218-- TRUE <= ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1219lteAll
1219lteAll
1220− :: Expression commons schemas params grp from ty -- ^ expression
1220+ :: Expression grp commons schemas params from ty -- ^ expression
1221 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1221 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1222− -> Expression commons schemas params grp from (nullity 'PGbool)
1222+ -> Expression grp commons schemas params from (nullity 'PGbool)
1223lteAll = unsafeSubqueryExpression "<= ALL"
1223lteAll = unsafeSubqueryExpression "<= ALL"
1224
1224
1225−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1225+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1226-- >>> printSQL $ myRow `rowLteAll` values_ myRow
1226-- >>> printSQL $ myRow `rowLteAll` values_ myRow
1227-- ROW(1, FALSE) <= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1227-- ROW(1, FALSE) <= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1228rowLteAll
1228rowLteAll
1229 :: SListI row
1229 :: SListI row
1230− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1230+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1231 -> Query commons schemas params row -- ^ subquery
1231 -> Query commons schemas params row -- ^ subquery
1232− -> Expression commons schemas params grp from (nullity 'PGbool)
1232+ -> Expression grp commons schemas params from (nullity 'PGbool)
1233rowLteAll = unsafeRowSubqueryExpression "<= ALL"
1233rowLteAll = unsafeRowSubqueryExpression "<= ALL"
1234
1234
1235-- | >>> printSQL $ true `lteAny` values_ (true `as` #foo)
1235-- | >>> printSQL $ true `lteAny` values_ (true `as` #foo)
1236-- TRUE <= ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1236-- TRUE <= ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1237lteAny
1237lteAny
1238− :: Expression commons schemas params grp from ty -- ^ expression
1238+ :: Expression grp commons schemas params from ty -- ^ expression
1239 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1239 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1240− -> Expression commons schemas params grp from (nullity 'PGbool)
1240+ -> Expression grp commons schemas params from (nullity 'PGbool)
1241lteAny = unsafeSubqueryExpression "<= ANY"
1241lteAny = unsafeSubqueryExpression "<= ANY"
1242
1242
1243−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1243+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1244-- >>> printSQL $ myRow `rowLteAny` values_ myRow
1244-- >>> printSQL $ myRow `rowLteAny` values_ myRow
1245-- ROW(1, FALSE) <= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1245-- ROW(1, FALSE) <= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1246rowLteAny
1246rowLteAny
1247 :: SListI row
1247 :: SListI row
1248− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1248+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1249 -> Query commons schemas params row -- ^ subquery
1249 -> Query commons schemas params row -- ^ subquery
1250− -> Expression commons schemas params grp from (nullity 'PGbool)
1250+ -> Expression grp commons schemas params from (nullity 'PGbool)
1251rowLteAny = unsafeRowSubqueryExpression "<= ANY"
1251rowLteAny = unsafeRowSubqueryExpression "<= ANY"
1252
1252
1253-- | >>> printSQL $ true `gtAll` values_ (true `as` #foo)
1253-- | >>> printSQL $ true `gtAll` values_ (true `as` #foo)
1254-- TRUE > ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1254-- TRUE > ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1255gtAll
1255gtAll
1256− :: Expression commons schemas params grp from ty -- ^ expression
1256+ :: Expression grp commons schemas params from ty -- ^ expression
1257 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1257 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1258− -> Expression commons schemas params grp from (nullity 'PGbool)
1258+ -> Expression grp commons schemas params from (nullity 'PGbool)
1259gtAll = unsafeSubqueryExpression "> ALL"
1259gtAll = unsafeSubqueryExpression "> ALL"
1260
1260
1261−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1261+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1262-- >>> printSQL $ myRow `rowGtAll` values_ myRow
1262-- >>> printSQL $ myRow `rowGtAll` values_ myRow
1263-- ROW(1, FALSE) > ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1263-- ROW(1, FALSE) > ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1264rowGtAll
1264rowGtAll
1265 :: SListI row
1265 :: SListI row
1266− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1266+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1267 -> Query commons schemas params row -- ^ subquery
1267 -> Query commons schemas params row -- ^ subquery
1268− -> Expression commons schemas params grp from (nullity 'PGbool)
1268+ -> Expression grp commons schemas params from (nullity 'PGbool)
1269rowGtAll = unsafeRowSubqueryExpression "> ALL"
1269rowGtAll = unsafeRowSubqueryExpression "> ALL"
1270
1270
1271-- | >>> printSQL $ true `gtAny` values_ (true `as` #foo)
1271-- | >>> printSQL $ true `gtAny` values_ (true `as` #foo)
1272-- TRUE > ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1272-- TRUE > ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1273gtAny
1273gtAny
1274− :: Expression commons schemas params grp from ty -- ^ expression
1274+ :: Expression grp commons schemas params from ty -- ^ expression
1275 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1275 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1276− -> Expression commons schemas params grp from (nullity 'PGbool)
1276+ -> Expression grp commons schemas params from (nullity 'PGbool)
1277gtAny = unsafeSubqueryExpression "> ANY"
1277gtAny = unsafeSubqueryExpression "> ANY"
1278
1278
1279−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1279+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1280-- >>> printSQL $ myRow `rowGtAny` values_ myRow
1280-- >>> printSQL $ myRow `rowGtAny` values_ myRow
1281-- ROW(1, FALSE) > ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1281-- ROW(1, FALSE) > ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1282rowGtAny
1282rowGtAny
1283 :: SListI row
1283 :: SListI row
1284− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1284+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1285 -> Query commons schemas params row -- ^ subquery
1285 -> Query commons schemas params row -- ^ subquery
1286− -> Expression commons schemas params grp from (nullity 'PGbool)
1286+ -> Expression grp commons schemas params from (nullity 'PGbool)
1287rowGtAny = unsafeRowSubqueryExpression "> ANY"
1287rowGtAny = unsafeRowSubqueryExpression "> ANY"
1288
1288
1289-- | >>> printSQL $ true `gteAll` values_ (true `as` #foo)
1289-- | >>> printSQL $ true `gteAll` values_ (true `as` #foo)
1290-- TRUE >= ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1290-- TRUE >= ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1291gteAll
1291gteAll
1292− :: Expression commons schemas params grp from ty -- ^ expression
1292+ :: Expression grp commons schemas params from ty -- ^ expression
1293 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1293 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1294− -> Expression commons schemas params grp from (nullity 'PGbool)
1294+ -> Expression grp commons schemas params from (nullity 'PGbool)
1295gteAll = unsafeSubqueryExpression ">= ALL"
1295gteAll = unsafeSubqueryExpression ">= ALL"
1296
1296
1297−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1297+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1298-- >>> printSQL $ myRow `rowGteAll` values_ myRow
1298-- >>> printSQL $ myRow `rowGteAll` values_ myRow
1299-- ROW(1, FALSE) >= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1299-- ROW(1, FALSE) >= ALL (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1300rowGteAll
1300rowGteAll
1301 :: SListI row
1301 :: SListI row
1302− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1302+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1303 -> Query commons schemas params row -- ^ subquery
1303 -> Query commons schemas params row -- ^ subquery
1304− -> Expression commons schemas params grp from (nullity 'PGbool)
1304+ -> Expression grp commons schemas params from (nullity 'PGbool)
1305rowGteAll = unsafeRowSubqueryExpression ">= ALL"
1305rowGteAll = unsafeRowSubqueryExpression ">= ALL"
1306
1306
1307-- | >>> printSQL $ true `gteAny` values_ (true `as` #foo)
1307-- | >>> printSQL $ true `gteAny` values_ (true `as` #foo)
1308-- TRUE >= ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1308-- TRUE >= ANY (SELECT * FROM (VALUES (TRUE)) AS t ("foo"))
1309gteAny
1309gteAny
1310− :: Expression commons schemas params grp from ty -- ^ expression
1310+ :: Expression grp commons schemas params from ty -- ^ expression
1311 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1311 -> Query commons schemas params '[alias ::: ty] -- ^ subquery
1312− -> Expression commons schemas params grp from (nullity 'PGbool)
1312+ -> Expression grp commons schemas params from (nullity 'PGbool)
1313gteAny = unsafeSubqueryExpression ">= ANY"
1313gteAny = unsafeSubqueryExpression ">= ANY"
1314
1314
1315−-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression commons schemas params grp from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1315+-- | >>> let myRow = 1 `as` #foo :* false `as` #bar :: NP (Aliased (Expression grp commons schemas params from)) '["foo" ::: 'NotNull 'PGint2, "bar" ::: 'NotNull 'PGbool]
1316-- >>> printSQL $ myRow `rowGteAny` values_ myRow
1316-- >>> printSQL $ myRow `rowGteAny` values_ myRow
1317-- ROW(1, FALSE) >= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1317-- ROW(1, FALSE) >= ANY (SELECT * FROM (VALUES (1, FALSE)) AS t ("foo", "bar"))
1318rowGteAny
1318rowGteAny
1319 :: SListI row
1319 :: SListI row
1320− => NP (Aliased (Expression commons schemas params grp from)) row -- ^ row constructor
1320+ => NP (Aliased (Expression grp commons schemas params from)) row -- ^ row constructor
1321 -> Query commons schemas params row -- ^ subquery
1321 -> Query commons schemas params row -- ^ subquery
1322− -> Expression commons schemas params grp from (nullity 'PGbool)
1322+ -> Expression grp commons schemas params from (nullity 'PGbool)
1323rowGteAny = unsafeRowSubqueryExpression ">= ANY"
1323rowGteAny = unsafeRowSubqueryExpression ">= ANY"
1324
1324
1325-- | A `CommonTableExpression` is an auxiliary statement in a `with` clause.
1325-- | A `CommonTableExpression` is an auxiliary statement in a `with` clause.