{-# LANGUAGE
OverloadedStrings
, RankNTypes
, TypeInType
, TypeOperators
#-}
module Squeal.PostgreSQL.Expression.Comparison
(
(.==)
, (./=)
, (.>=)
, (.<)
, (.<=)
, (.>)
, greatest
, least
, BetweenExpr
, between
, notBetween
, betweenSymmetric
, notBetweenSymmetric
, isDistinctFrom
, isNotDistinctFrom
, isTrue
, isNotTrue
, isFalse
, isNotFalse
, isUnknown
, isNotUnknown
) where
import Data.ByteString
import Squeal.PostgreSQL.Expression
import Squeal.PostgreSQL.Expression.Logic
import Squeal.PostgreSQL.Render
import Squeal.PostgreSQL.Type.Schema
(.==) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool)
.== :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(.==) = ByteString -> Operator (null0 ty) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"="
infix 4 .==
(./=) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool)
./= :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(./=) = ByteString -> Operator (null0 ty) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"<>"
infix 4 ./=
(.>=) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool)
.>= :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(.>=) = ByteString -> Operator (null0 ty) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
">="
infix 4 .>=
(.<) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool)
.< :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(.<) = ByteString -> Operator (null0 ty) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"<"
infix 4 .<
(.<=) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool)
.<= :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(.<=) = ByteString -> Operator (null0 ty) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"<="
infix 4 .<=
(.>) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool)
.> :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from ('Null 'PGbool)
(.>) = ByteString -> Operator (null0 ty) (null1 ty) ('Null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
">"
infix 4 .>
greatest :: FunctionVar ty ty ty
greatest :: [Expression grp lat with db params from ty]
-> Expression grp lat with db params from ty
-> Expression grp lat with db params from ty
greatest = ByteString -> FunctionVar ty ty ty
forall (x0 :: NullType) (x1 :: NullType) (y :: NullType).
ByteString -> FunctionVar x0 x1 y
unsafeFunctionVar ByteString
"GREATEST"
least :: FunctionVar ty ty ty
least :: [Expression grp lat with db params from ty]
-> Expression grp lat with db params from ty
-> Expression grp lat with db params from ty
least = ByteString -> FunctionVar ty ty ty
forall (x0 :: NullType) (x1 :: NullType) (y :: NullType).
ByteString -> FunctionVar x0 x1 y
unsafeFunctionVar ByteString
"LEAST"
type BetweenExpr
= forall grp lat with db params from ty
. Expression grp lat with db params from ty
-> ( Expression grp lat with db params from ty
, Expression grp lat with db params from ty )
-> Condition grp lat with db params from
unsafeBetweenExpr :: ByteString -> BetweenExpr
unsafeBetweenExpr :: ByteString -> BetweenExpr
unsafeBetweenExpr ByteString
fun Expression grp lat with db params from ty
a (Expression grp lat with db params from ty
x,Expression grp lat with db params from ty
y) = ByteString
-> Expression grp lat with db params from ('Null 'PGbool)
forall (grp :: Grouping) (lat :: FromType) (with :: FromType)
(db :: SchemasType) (params :: [NullType]) (from :: FromType)
(ty :: NullType).
ByteString -> Expression grp lat with db params from ty
UnsafeExpression (ByteString
-> Expression grp lat with db params from ('Null 'PGbool))
-> ByteString
-> Expression grp lat with db params from ('Null 'PGbool)
forall a b. (a -> b) -> a -> b
$
Expression grp lat with db params from ty -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL Expression grp lat with db params from ty
a ByteString -> ByteString -> ByteString
<+> ByteString
fun ByteString -> ByteString -> ByteString
<+> Expression grp lat with db params from ty -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL Expression grp lat with db params from ty
x ByteString -> ByteString -> ByteString
<+> ByteString
"AND" ByteString -> ByteString -> ByteString
<+> Expression grp lat with db params from ty -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL Expression grp lat with db params from ty
y
between :: BetweenExpr
between :: Expression grp lat with db params from ty
-> (Expression grp lat with db params from ty,
Expression grp lat with db params from ty)
-> Condition grp lat with db params from
between = ByteString -> BetweenExpr
unsafeBetweenExpr ByteString
"BETWEEN"
notBetween :: BetweenExpr
notBetween :: Expression grp lat with db params from ty
-> (Expression grp lat with db params from ty,
Expression grp lat with db params from ty)
-> Condition grp lat with db params from
notBetween = ByteString -> BetweenExpr
unsafeBetweenExpr ByteString
"NOT BETWEEN"
betweenSymmetric :: BetweenExpr
betweenSymmetric :: Expression grp lat with db params from ty
-> (Expression grp lat with db params from ty,
Expression grp lat with db params from ty)
-> Condition grp lat with db params from
betweenSymmetric = ByteString -> BetweenExpr
unsafeBetweenExpr ByteString
"BETWEEN SYMMETRIC"
notBetweenSymmetric :: BetweenExpr
notBetweenSymmetric :: Expression grp lat with db params from ty
-> (Expression grp lat with db params from ty,
Expression grp lat with db params from ty)
-> Condition grp lat with db params from
notBetweenSymmetric = ByteString -> BetweenExpr
unsafeBetweenExpr ByteString
"NOT BETWEEN SYMMETRIC"
isDistinctFrom :: Operator (null0 ty) (null1 ty) (null 'PGbool)
isDistinctFrom :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from (null 'PGbool)
isDistinctFrom = ByteString -> Operator (null0 ty) (null1 ty) (null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"IS DISTINCT FROM"
isNotDistinctFrom :: Operator (null0 ty) (null1 ty) (null 'PGbool)
isNotDistinctFrom :: Expression grp lat with db params from (null0 ty)
-> Expression grp lat with db params from (null1 ty)
-> Expression grp lat with db params from (null 'PGbool)
isNotDistinctFrom = ByteString -> Operator (null0 ty) (null1 ty) (null 'PGbool)
forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType).
ByteString -> Operator ty0 ty1 ty2
unsafeBinaryOp ByteString
"IS NOT DISTINCT FROM"
isTrue :: null0 'PGbool --> null1 'PGbool
isTrue :: Expression grp lat with db params from (null0 'PGbool)
-> Expression grp lat with db params from (null1 'PGbool)
isTrue = ByteString -> null0 'PGbool --> null1 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeRightOp ByteString
"IS TRUE"
isNotTrue :: null0 'PGbool --> null1 'PGbool
isNotTrue :: Expression grp lat with db params from (null0 'PGbool)
-> Expression grp lat with db params from (null1 'PGbool)
isNotTrue = ByteString -> null0 'PGbool --> null1 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeRightOp ByteString
"IS NOT TRUE"
isFalse :: null0 'PGbool --> null1 'PGbool
isFalse :: Expression grp lat with db params from (null0 'PGbool)
-> Expression grp lat with db params from (null1 'PGbool)
isFalse = ByteString -> null0 'PGbool --> null1 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeRightOp ByteString
"IS FALSE"
isNotFalse :: null0 'PGbool --> null1 'PGbool
isNotFalse :: Expression grp lat with db params from (null0 'PGbool)
-> Expression grp lat with db params from (null1 'PGbool)
isNotFalse = ByteString -> null0 'PGbool --> null1 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeRightOp ByteString
"IS NOT FALSE"
isUnknown :: null0 'PGbool --> null1 'PGbool
isUnknown :: Expression grp lat with db params from (null0 'PGbool)
-> Expression grp lat with db params from (null1 'PGbool)
isUnknown = ByteString -> null0 'PGbool --> null1 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeRightOp ByteString
"IS UNKNOWN"
isNotUnknown :: null0 'PGbool --> null1 'PGbool
isNotUnknown :: Expression grp lat with db params from (null0 'PGbool)
-> Expression grp lat with db params from (null1 'PGbool)
isNotUnknown = ByteString -> null0 'PGbool --> null1 'PGbool
forall (x :: NullType) (y :: NullType). ByteString -> x --> y
unsafeRightOp ByteString
"IS NOT UNKNOWN"