@@ -172,6 +172,9 @@ newtype Expression
172 = UnsafeExpression { renderExpression :: ByteString }
172 = UnsafeExpression { renderExpression :: ByteString }
173 deriving (GHC.Generic,Show,Eq,Ord,NFData)
173 deriving (GHC.Generic,Show,Eq,Ord,NFData)
175+instance RenderSQL (Expression schema relations grouping params ty) where
176+ renderSQL = renderExpression
175{- | A `HasParameter` constraint is used to indicate a value that is
178{- | A `HasParameter` constraint is used to indicate a value that is
176supplied externally to a SQL statement.
179supplied externally to a SQL statement.
177`Squeal.PostgreSQL.PQ.manipulateParams`,
180`Squeal.PostgreSQL.PQ.manipulateParams`,
@@ -278,15 +281,15 @@ instance
279-- | analagous to `Nothing`
282-- | analagous to `Nothing`
281−-- >>> renderExpression $ null_
284+-- >>> printSQL null_
283null_ :: Expression schema rels grouping params ('Null ty)
286null_ :: Expression schema rels grouping params ('Null ty)
284null_ = UnsafeExpression "NULL"
287null_ = UnsafeExpression "NULL"
286-- | analagous to `Just`
289-- | analagous to `Just`
288−-- >>> renderExpression $ notNull true
291+-- >>> printSQL $ notNull true
291 :: Expression schema rels grouping params ('NotNull ty)
294 :: Expression schema rels grouping params ('NotNull ty)
292 -> Expression schema rels grouping params ('Null ty)
295 -> Expression schema rels grouping params ('Null ty)
@@ -294,8 +297,8 @@ notNull = UnsafeExpression . renderExpression
295-- | return the leftmost value which is not NULL
298-- | return the leftmost value which is not NULL
297−-- >>> renderExpression $ coalesce [null_, notNull true] false
300+-- >>> printSQL $ coalesce [null_, notNull true] false
298−-- "COALESCE(NULL, TRUE, FALSE)"
301+-- COALESCE(NULL, TRUE, FALSE)
300 :: [Expression schema relations grouping params ('Null ty)]
303 :: [Expression schema relations grouping params ('Null ty)]
301 -- ^ @NULL@s may be present
304 -- ^ @NULL@s may be present
@@ -308,8 +311,8 @@ coalesce nullxs notNullx = UnsafeExpression $
309-- | analagous to `Data.Maybe.fromMaybe` using @COALESCE@
312-- | analagous to `Data.Maybe.fromMaybe` using @COALESCE@
311−-- >>> renderExpression $ fromNull true null_
314+-- >>> printSQL $ fromNull true null_
312−-- "COALESCE(NULL, TRUE)"
315+-- COALESCE(NULL, TRUE)
314 :: Expression schema relations grouping params ('NotNull ty)
317 :: Expression schema relations grouping params ('NotNull ty)
315 -- ^ what to convert @NULL@ to
318 -- ^ what to convert @NULL@ to
@@ -317,16 +320,16 @@ fromNull
317 -> Expression schema relations grouping params ('NotNull ty)
320 -> Expression schema relations grouping params ('NotNull ty)
318fromNull notNullx nullx = coalesce [nullx] notNullx
321fromNull notNullx nullx = coalesce [nullx] notNullx
320−-- | >>> renderExpression $ null_ & isNull
323+-- | >>> printSQL $ null_ & isNull
321−-- "NULL IS NULL"
324+-- NULL IS NULL
323 :: Expression schema relations grouping params ('Null ty)
326 :: Expression schema relations grouping params ('Null ty)
324 -- ^ possibly @NULL@
327 -- ^ possibly @NULL@
325 -> Condition schema relations grouping params
328 -> Condition schema relations grouping params
326isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
329isNull x = UnsafeExpression $ renderExpression x <+> "IS NULL"
328−-- | >>> renderExpression $ null_ & isNotNull
331+-- | >>> printSQL $ null_ & isNotNull
329−-- "NULL IS NOT NULL"
332+-- NULL IS NOT NULL
331 :: Expression schema relations grouping params ('Null ty)
334 :: Expression schema relations grouping params ('Null ty)
332 -- ^ possibly @NULL@
335 -- ^ possibly @NULL@
@@ -335,8 +338,8 @@ isNotNull x = UnsafeExpression $ renderExpression x <+> "IS NOT NULL"
336-- | analagous to `maybe` using @IS NULL@
339-- | analagous to `maybe` using @IS NULL@
338−-- >>> renderExpression $ matchNull true not_ null_
341+-- >>> printSQL $ matchNull true not_ null_
339−-- "CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END"
342+-- CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
341 :: Expression schema relations grouping params (nullty)
344 :: Expression schema relations grouping params (nullty)
342 -- ^ what to convert @NULL@ to
345 -- ^ what to convert @NULL@ to
@@ -348,12 +351,14 @@ matchNull
348matchNull y f x = ifThenElse (isNull x) y
351matchNull y f x = ifThenElse (isNull x) y
349 (f (UnsafeExpression (renderExpression x)))
352 (f (UnsafeExpression (renderExpression x)))
351−-- | right inverse to `fromNull`, if its arguments are equal then
354+{-| right inverse to `fromNull`, if its arguments are equal then
352−-- `nullIf` gives @NULL@.
355+`nullIf` gives @NULL@.
354−-- >>> :set -XTypeApplications -XDataKinds
357+>>> :set -XTypeApplications -XDataKinds
355−-- >>> renderExpression @'[] @_ @_ @'[_] $ fromNull false (nullIf false (param @1))
358+>>> let expr = nullIf false (param @1) :: Expression schema rels grp '[ 'NotNull 'PGbool] ('Null 'PGbool)
356−-- "COALESCE(NULL IF (FALSE, ($1 :: bool)), FALSE)"
360+NULL IF (FALSE, ($1 :: bool))
358 :: Expression schema relations grouping params ('NotNull ty)
363 :: Expression schema relations grouping params ('NotNull ty)
359 -- ^ @NULL@ is absent
364 -- ^ @NULL@ is absent
@@ -363,8 +368,8 @@ nullIf
363nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
368nullIf x y = UnsafeExpression $ "NULL IF" <+> parenthesized
364 (renderExpression x <> ", " <> renderExpression y)
369 (renderExpression x <> ", " <> renderExpression y)
366−-- | >>> renderExpression $ array [null_, notNull false, notNull true]
371+-- | >>> printSQL $ array [null_, notNull false, notNull true]
367−-- "ARRAY[NULL, FALSE, TRUE]"
372+-- ARRAY[NULL, FALSE, TRUE]
369 :: [Expression schema relations grouping params ('Null ty)]
374 :: [Expression schema relations grouping params ('Null ty)]
370 -- ^ array elements
375 -- ^ array elements
@@ -381,8 +386,8 @@ instance (KnownSymbol label, label `In` labels) => IsPGlabel label
382-- >>> type Complex = PGcomposite '["real" ::: 'PGfloat8, "imaginary" ::: 'PGfloat8]
387-- >>> type Complex = PGcomposite '["real" ::: 'PGfloat8, "imaginary" ::: 'PGfloat8]
383-- >>> let i = row (0 `As` #real :* 1 `As` #imaginary :* Nil) :: Expression '[] '[] 'Ungrouped '[] ('NotNull Complex)
388-- >>> let i = row (0 `As` #real :* 1 `As` #imaginary :* Nil) :: Expression '[] '[] 'Ungrouped '[] ('NotNull Complex)
384−-- >>> renderExpression i
389+-- >>> printSQL i
385−-- "ROW(0, 1)"
390+-- ROW(0, 1)
387 :: SListI (Nulls fields)
392 :: SListI (Nulls fields)
388 => NP (Aliased (Expression schema relations grouping params)) (Nulls fields)
393 => NP (Aliased (Expression schema relations grouping params)) (Nulls fields)
@@ -407,8 +412,9 @@ instance Monoid
407 mempty = array []
412 mempty = array []
408 mappend = (<>)
413 mappend = (<>)
410−-- | >>> renderExpression @'[] @_ @_ @'[_] $ greatest currentTimestamp [param @1]
415+-- | >>> let expr = greatest currentTimestamp [param @1] :: Expression sch rels grp '[ 'NotNull 'PGtimestamptz] ('NotNull 'PGtimestamptz)
411−-- "GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))"
417+-- GREATEST(CURRENT_TIMESTAMP, ($1 :: timestamp with time zone))
413 :: Expression schema relations grouping params (nullty)
419 :: Expression schema relations grouping params (nullty)
414 -- ^ needs at least 1 argument
420 -- ^ needs at least 1 argument
@@ -418,8 +424,8 @@ greatest
418greatest x xs = UnsafeExpression $ "GREATEST("
424greatest x xs = UnsafeExpression $ "GREATEST("
419 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
425 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
421−-- | >>> renderExpression $ least currentTimestamp [null_]
427+-- | >>> printSQL $ least currentTimestamp [null_]
422−-- "LEAST(CURRENT_TIMESTAMP, NULL)"
428+-- LEAST(CURRENT_TIMESTAMP, NULL)
424 :: Expression schema relations grouping params (nullty)
430 :: Expression schema relations grouping params (nullty)
425 -- ^ needs at least 1 argument
431 -- ^ needs at least 1 argument
@@ -429,8 +435,8 @@ least
429least x xs = UnsafeExpression $ "LEAST("
435least x xs = UnsafeExpression $ "LEAST("
430 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
436 <> commaSeparated (renderExpression <$> (x:xs)) <> ")"
432−-- | >>> renderExpression $ unsafeBinaryOp "OR" true false
438+-- | >>> printSQL $ unsafeBinaryOp "OR" true false
433−-- "(TRUE OR FALSE)"
439+-- (TRUE OR FALSE)
434unsafeBinaryOp
440unsafeBinaryOp
435 :: ByteString
441 :: ByteString
436 -- ^ operator
442 -- ^ operator
@@ -440,8 +446,8 @@ unsafeBinaryOp
440unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
446unsafeBinaryOp op x y = UnsafeExpression $ parenthesized $
441 renderExpression x <+> op <+> renderExpression y
447 renderExpression x <+> op <+> renderExpression y
443−-- | >>> renderExpression $ unsafeUnaryOp "NOT" true
449+-- | >>> printSQL $ unsafeUnaryOp "NOT" true
444−-- "(NOT TRUE)"
450+-- (NOT TRUE)
445unsafeUnaryOp
451unsafeUnaryOp
446 :: ByteString
452 :: ByteString
447 -- ^ operator
453 -- ^ operator
@@ -450,8 +456,8 @@ unsafeUnaryOp
450unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
456unsafeUnaryOp op x = UnsafeExpression $ parenthesized $
451 op <+> renderExpression x
457 op <+> renderExpression x
453−-- | >>> renderExpression $ unsafeFunction "f" true
459+-- | >>> printSQL $ unsafeFunction "f" true
454−-- "f(TRUE)"
460+-- f(TRUE)
455unsafeFunction
461unsafeFunction
456 :: ByteString
462 :: ByteString
457 -- ^ function
463 -- ^ function
@@ -503,9 +509,9 @@ instance (PGNum ty, PGFloating ty) => Floating
504-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
510-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
505-- expression = atan2_ pi 2
511-- expression = atan2_ pi 2
506−-- in renderExpression expression
512+-- in printSQL expression
508−-- "atan2(pi(), 2)"
514+-- atan2(pi(), 2)
510 :: PGFloating float
516 :: PGFloating float
511 => Expression schema relations grouping params (nullity float)
517 => Expression schema relations grouping params (nullity float)
@@ -520,8 +526,8 @@ atan2_ y x = UnsafeExpression $
520-- represents a run-time type conversion. The cast will succeed only if a
526-- represents a run-time type conversion. The cast will succeed only if a
521-- suitable type conversion operation has been defined.
527-- suitable type conversion operation has been defined.
523−-- | >>> renderExpression $ true & cast int4
529+-- | >>> printSQL $ true & cast int4
524−-- "(TRUE :: int4)"
530+-- (TRUE :: int4)
526 :: TypeExpression schema ty1
532 :: TypeExpression schema ty1
527 -- ^ type to cast as
533 -- ^ type to cast as
@@ -537,9 +543,9 @@ cast ty x = UnsafeExpression $ parenthesized $
538-- expression :: Expression schema relations grouping params (nullity 'PGint2)
544-- expression :: Expression schema relations grouping params (nullity 'PGint2)
539-- expression = 5 `quot_` 2
545-- expression = 5 `quot_` 2
540−-- in renderExpression expression
546+-- in printSQL expression
542−-- "(5 / 2)"
548+-- (5 / 2)
544 :: PGIntegral int
550 :: PGIntegral int
545 => Expression schema relations grouping params (nullity int)
551 => Expression schema relations grouping params (nullity int)
@@ -555,9 +561,9 @@ quot_ = unsafeBinaryOp "/"
556-- expression :: Expression schema relations grouping params (nullity 'PGint2)
562-- expression :: Expression schema relations grouping params (nullity 'PGint2)
557-- expression = 5 `rem_` 2
563-- expression = 5 `rem_` 2
558−-- in renderExpression expression
564+-- in printSQL expression
560−-- "(5 % 2)"
566+-- (5 % 2)
562 :: PGIntegral int
568 :: PGIntegral int
563 => Expression schema relations grouping params (nullity int)
569 => Expression schema relations grouping params (nullity int)
@@ -571,9 +577,9 @@ rem_ = unsafeBinaryOp "%"
572-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
578-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
573-- expression = trunc pi
579-- expression = trunc pi
574−-- in renderExpression expression
580+-- in printSQL expression
576−-- "trunc(pi())"
582+-- trunc(pi())
578 :: PGFloating frac
584 :: PGFloating frac
579 => Expression schema relations grouping params (nullity frac)
585 => Expression schema relations grouping params (nullity frac)
@@ -585,9 +591,9 @@ trunc = unsafeFunction "trunc"
586-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
592-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
587-- expression = round_ pi
593-- expression = round_ pi
588−-- in renderExpression expression
594+-- in printSQL expression
590−-- "round(pi())"
596+-- round(pi())
592 :: PGFloating frac
598 :: PGFloating frac
593 => Expression schema relations grouping params (nullity frac)
599 => Expression schema relations grouping params (nullity frac)
@@ -599,9 +605,9 @@ round_ = unsafeFunction "round"
600-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
606-- expression :: Expression schema relations grouping params (nullity 'PGfloat4)
601-- expression = ceiling_ pi
607-- expression = ceiling_ pi
602−-- in renderExpression expression
608+-- in printSQL expression
604−-- "ceiling(pi())"
610+-- ceiling(pi())
606 :: PGFloating frac
612 :: PGFloating frac
607 => Expression schema relations grouping params (nullity frac)
613 => Expression schema relations grouping params (nullity frac)
@@ -616,33 +622,33 @@ ceiling_ = unsafeFunction "ceiling"
616type Condition schema relations grouping params =
622type Condition schema relations grouping params =
617 Expression schema relations grouping params ('NotNull 'PGbool)
623 Expression schema relations grouping params ('NotNull 'PGbool)
619−-- | >>> renderExpression true
625+-- | >>> printSQL true
621true :: Condition schema relations grouping params
627true :: Condition schema relations grouping params
622true = UnsafeExpression "TRUE"
628true = UnsafeExpression "TRUE"
624−-- | >>> renderExpression false
630+-- | >>> printSQL false
625−-- "FALSE"
631+-- FALSE
626false :: Condition schema relations grouping params
632false :: Condition schema relations grouping params
627false = UnsafeExpression "FALSE"
633false = UnsafeExpression "FALSE"
629−-- | >>> renderExpression $ not_ true
635+-- | >>> printSQL $ not_ true
630−-- "(NOT TRUE)"
636+-- (NOT TRUE)
632 :: Condition schema relations grouping params
638 :: Condition schema relations grouping params
633 -> Condition schema relations grouping params
639 -> Condition schema relations grouping params
634not_ = unsafeUnaryOp "NOT"
640not_ = unsafeUnaryOp "NOT"
636−-- | >>> renderExpression $ true .&& false
642+-- | >>> printSQL $ true .&& false
637−-- "(TRUE AND FALSE)"
643+-- (TRUE AND FALSE)
639 :: Condition schema relations grouping params
645 :: Condition schema relations grouping params
640 -> Condition schema relations grouping params
646 -> Condition schema relations grouping params
641 -> Condition schema relations grouping params
647 -> Condition schema relations grouping params
642(.&&) = unsafeBinaryOp "AND"
648(.&&) = unsafeBinaryOp "AND"
644−-- | >>> renderExpression $ true .|| false
650+-- | >>> printSQL $ true .|| false
645−-- "(TRUE OR FALSE)"
651+-- (TRUE OR FALSE)
647 :: Condition schema relations grouping params
653 :: Condition schema relations grouping params
648 -> Condition schema relations grouping params
654 -> Condition schema relations grouping params
@@ -653,9 +659,9 @@ not_ = unsafeUnaryOp "NOT"
654-- expression :: Expression schema relations grouping params (nullity 'PGint2)
660-- expression :: Expression schema relations grouping params (nullity 'PGint2)
655-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
661-- expression = caseWhenThenElse [(true, 1), (false, 2)] 3
656−-- in renderExpression expression
662+-- in printSQL expression
658−-- "CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END"
664+-- CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
659caseWhenThenElse
665caseWhenThenElse
660 :: [ ( Condition schema relations grouping params
666 :: [ ( Condition schema relations grouping params
661 , Expression schema relations grouping params (ty)
667 , Expression schema relations grouping params (ty)
@@ -681,9 +687,9 @@ caseWhenThenElse whenThens else_ = UnsafeExpression $ mconcat
682-- expression :: Expression schema relations grouping params (nullity 'PGint2)
688-- expression :: Expression schema relations grouping params (nullity 'PGint2)
683-- expression = ifThenElse true 1 0
689-- expression = ifThenElse true 1 0
684−-- in renderExpression expression
690+-- in printSQL expression
686−-- "CASE WHEN TRUE THEN 1 ELSE 0 END"
692+-- CASE WHEN TRUE THEN 1 ELSE 0 END
687ifThenElse
693ifThenElse
688 :: Condition schema relations grouping params
694 :: Condition schema relations grouping params
689 -> Expression schema relations grouping params (ty) -- ^ then
695 -> Expression schema relations grouping params (ty) -- ^ then
@@ -694,8 +700,8 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
694-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
700-- | Comparison operations like `.==`, `./=`, `.>`, `.>=`, `.<` and `.<=`
695-- will produce @NULL@s if one of their arguments is @NULL@.
701-- will produce @NULL@s if one of their arguments is @NULL@.
697−-- >>> renderExpression $ notNull true .== null_
703+-- >>> printSQL $ notNull true .== null_
698−-- "(TRUE = NULL)"
704+-- (TRUE = NULL)
700 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
706 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
701 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
707 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
@@ -703,8 +709,8 @@ ifThenElse if_ then_ else_ = caseWhenThenElse [(if_,then_)] else_
703(.==) = unsafeBinaryOp "="
709(.==) = unsafeBinaryOp "="
704infix 4 .==
710infix 4 .==
706−-- | >>> renderExpression $ notNull true ./= null_
712+-- | >>> printSQL $ notNull true ./= null_
707−-- "(TRUE <> NULL)"
713+-- (TRUE <> NULL)
709 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
715 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
710 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
716 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
@@ -712,8 +718,8 @@ infix 4 .==
712(./=) = unsafeBinaryOp "<>"
718(./=) = unsafeBinaryOp "<>"
713infix 4 ./=
719infix 4 ./=
715−-- | >>> renderExpression $ notNull true .>= null_
721+-- | >>> printSQL $ notNull true .>= null_
716−-- "(TRUE >= NULL)"
722+-- (TRUE >= NULL)
718 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
724 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
719 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
725 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
@@ -721,8 +727,8 @@ infix 4 ./=
721(.>=) = unsafeBinaryOp ">="
727(.>=) = unsafeBinaryOp ">="
722infix 4 .>=
728infix 4 .>=
724−-- | >>> renderExpression $ notNull true .< null_
730+-- | >>> printSQL $ notNull true .< null_
725−-- "(TRUE < NULL)"
731+-- (TRUE < NULL)
727 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
733 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
728 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
734 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
@@ -730,8 +736,8 @@ infix 4 .>=
730(.<) = unsafeBinaryOp "<"
736(.<) = unsafeBinaryOp "<"
731infix 4 .<
737infix 4 .<
733−-- | >>> renderExpression $ notNull true .<= null_
739+-- | >>> printSQL $ notNull true .<= null_
734−-- "(TRUE <= NULL)"
740+-- (TRUE <= NULL)
736 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
742 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
737 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
743 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
@@ -739,8 +745,8 @@ infix 4 .<
739(.<=) = unsafeBinaryOp "<="
745(.<=) = unsafeBinaryOp "<="
740infix 4 .<=
746infix 4 .<=
742−-- | >>> renderExpression $ notNull true .> null_
748+-- | >>> printSQL $ notNull true .> null_
743−-- "(TRUE > NULL)"
749+-- (TRUE > NULL)
745 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
751 :: Expression schema relations grouping params (nullity ty) -- ^ lhs
746 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
752 -> Expression schema relations grouping params (nullity ty) -- ^ rhs
@@ -748,32 +754,32 @@ infix 4 .<=
748(.>) = unsafeBinaryOp ">"
754(.>) = unsafeBinaryOp ">"
749infix 4 .>
755infix 4 .>
751−-- | >>> renderExpression currentDate
757+-- | >>> printSQL currentDate
752−-- "CURRENT_DATE"
758+-- CURRENT_DATE
753currentDate
759currentDate
754 :: Expression schema relations grouping params (nullity 'PGdate)
760 :: Expression schema relations grouping params (nullity 'PGdate)
755currentDate = UnsafeExpression "CURRENT_DATE"
761currentDate = UnsafeExpression "CURRENT_DATE"
757−-- | >>> renderExpression currentTime
763+-- | >>> printSQL currentTime
758−-- "CURRENT_TIME"
764+-- CURRENT_TIME
759currentTime
765currentTime
760 :: Expression schema relations grouping params (nullity 'PGtimetz)
766 :: Expression schema relations grouping params (nullity 'PGtimetz)
761currentTime = UnsafeExpression "CURRENT_TIME"
767currentTime = UnsafeExpression "CURRENT_TIME"
763−-- | >>> renderExpression currentTimestamp
769+-- | >>> printSQL currentTimestamp
764−-- "CURRENT_TIMESTAMP"
770+-- CURRENT_TIMESTAMP
765currentTimestamp
771currentTimestamp
766 :: Expression schema relations grouping params (nullity 'PGtimestamptz)
772 :: Expression schema relations grouping params (nullity 'PGtimestamptz)
767currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
773currentTimestamp = UnsafeExpression "CURRENT_TIMESTAMP"
769−-- | >>> renderExpression localTime
775+-- | >>> printSQL localTime
770−-- "LOCALTIME"
776+-- LOCALTIME
772 :: Expression schema relations grouping params (nullity 'PGtime)
778 :: Expression schema relations grouping params (nullity 'PGtime)
773localTime = UnsafeExpression "LOCALTIME"
779localTime = UnsafeExpression "LOCALTIME"
775−-- | >>> renderExpression localTimestamp
781+-- | >>> printSQL localTimestamp
776−-- "LOCALTIMESTAMP"
782+-- LOCALTIMESTAMP
777localTimestamp
783localTimestamp
778 :: Expression schema relations grouping params (nullity 'PGtimestamp)
784 :: Expression schema relations grouping params (nullity 'PGtimestamp)
779localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
785localTimestamp = UnsafeExpression "LOCALTIMESTAMP"
@@ -807,24 +813,24 @@ instance Monoid
807 mempty = fromString ""
813 mempty = fromString ""
808 mappend = (<>)
814 mappend = (<>)
810−-- | >>> renderExpression $ lower "ARRRGGG"
816+-- | >>> printSQL $ lower "ARRRGGG"
811−-- "lower(E'ARRRGGG')"
817+-- lower(E'ARRRGGG')
813 :: Expression schema relations grouping params (nullity 'PGtext)
819 :: Expression schema relations grouping params (nullity 'PGtext)
814 -- ^ string to lower case
820 -- ^ string to lower case
815 -> Expression schema relations grouping params (nullity 'PGtext)
821 -> Expression schema relations grouping params (nullity 'PGtext)
816lower = unsafeFunction "lower"
822lower = unsafeFunction "lower"
818−-- | >>> renderExpression $ upper "eeee"
824+-- | >>> printSQL $ upper "eeee"
819−-- "upper(E'eeee')"
825+-- upper(E'eeee')
821 :: Expression schema relations grouping params (nullity 'PGtext)
827 :: Expression schema relations grouping params (nullity 'PGtext)
822 -- ^ string to upper case
828 -- ^ string to upper case
823 -> Expression schema relations grouping params (nullity 'PGtext)
829 -> Expression schema relations grouping params (nullity 'PGtext)
824upper = unsafeFunction "upper"
830upper = unsafeFunction "upper"
826−-- | >>> renderExpression $ charLength "four"
832+-- | >>> printSQL $ charLength "four"
827−-- "char_length(E'four')"
833+-- char_length(E'four')
828charLength
834charLength
829 :: Expression schema relations grouping params (nullity 'PGtext)
835 :: Expression schema relations grouping params (nullity 'PGtext)
830 -- ^ string to measure
836 -- ^ string to measure
@@ -838,8 +844,8 @@ charLength = unsafeFunction "char_length"
838-- in pattern stands for (matches) any single character; a percent sign (%)
844-- in pattern stands for (matches) any single character; a percent sign (%)
839-- matches any sequence of zero or more characters.
845-- matches any sequence of zero or more characters.
841−-- >>> renderExpression $ "abc" `like` "a%"
847+-- >>> printSQL $ "abc" `like` "a%"
842−-- "(E'abc' LIKE E'a%')"
848+-- (E'abc' LIKE E'a%')
844 :: Expression schema relations grouping params (nullity 'PGtext)
850 :: Expression schema relations grouping params (nullity 'PGtext)
845 -- ^ string
851 -- ^ string
@@ -872,9 +878,9 @@ unsafeAggregateDistinct fun x = UnsafeExpression $ mconcat
873-- expression :: Expression schema '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Grouped bys) params ('Null 'PGnumeric)
879-- expression :: Expression schema '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Grouped bys) params ('Null 'PGnumeric)
874-- expression = sum_ #col
880-- expression = sum_ #col
875−-- in renderExpression expression
881+-- in printSQL expression
877−-- "sum(\"col\")"
883+-- sum("col")
879 :: PGNum ty
885 :: PGNum ty
880 => Expression schema relations 'Ungrouped params (nullity ty)
886 => Expression schema relations 'Ungrouped params (nullity ty)
@@ -886,9 +892,9 @@ sum_ = unsafeAggregate "sum"
887-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGnumeric]] ('Grouped bys) params (nullity 'PGnumeric)
893-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGnumeric]] ('Grouped bys) params (nullity 'PGnumeric)
888-- expression = sumDistinct #col
894-- expression = sumDistinct #col
889−-- in renderExpression expression
895+-- in printSQL expression
891−-- "sum(DISTINCT \"col\")"
897+-- sum(DISTINCT "col")
892sumDistinct
898sumDistinct
893 :: PGNum ty
899 :: PGNum ty
894 => Expression schema relations 'Ungrouped params (nullity ty)
900 => Expression schema relations 'Ungrouped params (nullity ty)
@@ -917,9 +923,9 @@ instance PGAvg 'PGinterval 'PGinterval
918-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
924-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
919-- expression = bitAnd #col
925-- expression = bitAnd #col
920−-- in renderExpression expression
926+-- in printSQL expression
922−-- "bit_and(\"col\")"
928+-- bit_and("col")
924 :: PGIntegral int
930 :: PGIntegral int
925 => Expression schema relations 'Ungrouped params (nullity int)
931 => Expression schema relations 'Ungrouped params (nullity int)
@@ -931,9 +937,9 @@ bitAnd = unsafeAggregate "bit_and"
932-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
938-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
933-- expression = bitOr #col
939-- expression = bitOr #col
934−-- in renderExpression expression
940+-- in printSQL expression
936−-- "bit_or(\"col\")"
942+-- bit_or("col")
938 :: PGIntegral int
944 :: PGIntegral int
939 => Expression schema relations 'Ungrouped params (nullity int)
945 => Expression schema relations 'Ungrouped params (nullity int)
@@ -945,9 +951,9 @@ bitOr = unsafeAggregate "bit_or"
946-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
952-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
947-- expression = bitAndDistinct #col
953-- expression = bitAndDistinct #col
948−-- in renderExpression expression
954+-- in printSQL expression
950−-- "bit_and(DISTINCT \"col\")"
956+-- bit_and(DISTINCT "col")
951bitAndDistinct
957bitAndDistinct
952 :: PGIntegral int
958 :: PGIntegral int
953 => Expression schema relations 'Ungrouped params (nullity int)
959 => Expression schema relations 'Ungrouped params (nullity int)
@@ -959,9 +965,9 @@ bitAndDistinct = unsafeAggregateDistinct "bit_and"
960-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
966-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGint4]] (Grouped bys) params (nullity 'PGint4)
961-- expression = bitOrDistinct #col
967-- expression = bitOrDistinct #col
962−-- in renderExpression expression
968+-- in printSQL expression
964−-- "bit_or(DISTINCT \"col\")"
970+-- bit_or(DISTINCT "col")
965bitOrDistinct
971bitOrDistinct
966 :: PGIntegral int
972 :: PGIntegral int
967 => Expression schema relations 'Ungrouped params (nullity int)
973 => Expression schema relations 'Ungrouped params (nullity int)
@@ -973,9 +979,9 @@ bitOrDistinct = unsafeAggregateDistinct "bit_or"
974-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
980-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
975-- expression = boolAnd #col
981-- expression = boolAnd #col
976−-- in renderExpression expression
982+-- in printSQL expression
978−-- "bool_and(\"col\")"
984+-- bool_and("col")
980 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
986 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
981 -- ^ what to aggregate
987 -- ^ what to aggregate
@@ -986,9 +992,9 @@ boolAnd = unsafeAggregate "bool_and"
987-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
993-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
988-- expression = boolOr #col
994-- expression = boolOr #col
989−-- in renderExpression expression
995+-- in printSQL expression
991−-- "bool_or(\"col\")"
997+-- bool_or("col")
993 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
999 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
994 -- ^ what to aggregate
1000 -- ^ what to aggregate
@@ -999,9 +1005,9 @@ boolOr = unsafeAggregate "bool_or"
1000-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1006-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1001-- expression = boolAndDistinct #col
1007-- expression = boolAndDistinct #col
1002−-- in renderExpression expression
1008+-- in printSQL expression
1004−-- "bool_and(DISTINCT \"col\")"
1010+-- bool_and(DISTINCT "col")
1005boolAndDistinct
1011boolAndDistinct
1006 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1012 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1007 -- ^ what to aggregate
1013 -- ^ what to aggregate
@@ -1012,9 +1018,9 @@ boolAndDistinct = unsafeAggregateDistinct "bool_and"
1013-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1019-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1014-- expression = boolOrDistinct #col
1020-- expression = boolOrDistinct #col
1015−-- in renderExpression expression
1021+-- in printSQL expression
1017−-- "bool_or(DISTINCT \"col\")"
1023+-- bool_or(DISTINCT "col")
1018boolOrDistinct
1024boolOrDistinct
1019 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1025 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1020 -- ^ what to aggregate
1026 -- ^ what to aggregate
@@ -1023,8 +1029,8 @@ boolOrDistinct = unsafeAggregateDistinct "bool_or"
1024-- | A special aggregation that does not require an input
1030-- | A special aggregation that does not require an input
1026−-- >>> renderExpression countStar
1032+-- >>> printSQL countStar
1027−-- "count(*)"
1033+-- count(*)
1028countStar
1034countStar
1029 :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1035 :: Expression schema relations ('Grouped bys) params ('NotNull 'PGint8)
1030countStar = UnsafeExpression $ "count(*)"
1036countStar = UnsafeExpression $ "count(*)"
@@ -1033,9 +1039,9 @@ countStar = UnsafeExpression $ "count(*)"
1034-- expression :: Expression schema '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1040-- expression :: Expression schema '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1035-- expression = count #col
1041-- expression = count #col
1036−-- in renderExpression expression
1042+-- in printSQL expression
1038−-- "count(\"col\")"
1044+-- count("col")
1040 :: Expression schema relations 'Ungrouped params ty
1046 :: Expression schema relations 'Ungrouped params ty
1041 -- ^ what to count
1047 -- ^ what to count
@@ -1046,9 +1052,9 @@ count = unsafeAggregate "count"
1047-- expression :: Expression schema '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1053-- expression :: Expression schema '[tab ::: '["col" ::: nullity ty]] (Grouped bys) params ('NotNull 'PGint8)
1048-- expression = countDistinct #col
1054-- expression = countDistinct #col
1049−-- in renderExpression expression
1055+-- in printSQL expression
1051−-- "count(DISTINCT \"col\")"
1057+-- count(DISTINCT "col")
1052countDistinct
1058countDistinct
1053 :: Expression schema relations 'Ungrouped params ty
1059 :: Expression schema relations 'Ungrouped params ty
1054 -- ^ what to count
1060 -- ^ what to count
@@ -1061,9 +1067,9 @@ countDistinct = unsafeAggregateDistinct "count"
1062-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1068-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1063-- expression = every #col
1069-- expression = every #col
1064−-- in renderExpression expression
1070+-- in printSQL expression
1066−-- "every(\"col\")"
1072+-- every("col")
1068 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1074 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1069 -- ^ what to aggregate
1075 -- ^ what to aggregate
@@ -1076,9 +1082,9 @@ every = unsafeAggregate "every"
1077-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1083-- expression :: Expression schema '[tab ::: '["col" ::: nullity 'PGbool]] (Grouped bys) params (nullity 'PGbool)
1078-- expression = everyDistinct #col
1084-- expression = everyDistinct #col
1079−-- in renderExpression expression
1085+-- in printSQL expression
1081−-- "every(DISTINCT \"col\")"
1087+-- every(DISTINCT "col")
1082everyDistinct
1088everyDistinct
1083 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1089 :: Expression schema relations 'Ungrouped params (nullity 'PGbool)
1084 -- ^ what to aggregate
1090 -- ^ what to aggregate