@@ -80,6 +80,18 @@ module Squeal.PostgreSQL.Expression
86+ , notBetweenSymmetric
83 -- ** Time
95 -- ** Time
84 , currentDate
96 , currentDate
85 , currentTime
97 , currentTime
@@ -920,6 +932,128 @@ infix 4 .<=
920(.>) = unsafeBinaryOp ">"
932(.>) = unsafeBinaryOp ">"
921infix 4 .>
933infix 4 .>
936+>>> printSQL $ true `between` (null_, false)
937+TRUE BETWEEN NULL AND FALSE
940+ :: Expression outer grp commons schemas params from (nullity ty)
941+ -> ( Expression outer grp commons schemas params from (nullity ty)
942+ , Expression outer grp commons schemas params from (nullity ty) ) -- ^ bounds
943+ -> Condition outer grp commons schemas params from
944+between a (x,y) = UnsafeExpression $ renderSQL a <+> "BETWEEN"
945+ <+> renderSQL x <+> "AND" <+> renderSQL y
948+>>> printSQL $ true `notBetween` (null_, false)
949+TRUE NOT BETWEEN NULL AND FALSE
952+ :: Expression outer grp commons schemas params from (nullity ty)
953+ -> ( Expression outer grp commons schemas params from (nullity ty)
954+ , Expression outer grp commons schemas params from (nullity ty) ) -- ^ bounds
955+ -> Condition outer grp commons schemas params from
956+notBetween a (x,y) = UnsafeExpression $ renderSQL a <+> "NOT BETWEEN"
957+ <+> renderSQL x <+> "AND" <+> renderSQL y
959+{- | between, after sorting the comparison values
960+>>> printSQL $ true `betweenSymmetric` (null_, false)
961+TRUE BETWEEN SYMMETRIC NULL AND FALSE
964+ :: Expression outer grp commons schemas params from (nullity ty)
965+ -> ( Expression outer grp commons schemas params from (nullity ty)
966+ , Expression outer grp commons schemas params from (nullity ty) ) -- ^ bounds
967+ -> Condition outer grp commons schemas params from
968+betweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
969+ <+> "BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
971+{- | not between, after sorting the comparison values
972+>>> printSQL $ true `notBetweenSymmetric` (null_, false)
973+TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE
976+ :: Expression outer grp commons schemas params from (nullity ty)
977+ -> ( Expression outer grp commons schemas params from (nullity ty)
978+ , Expression outer grp commons schemas params from (nullity ty) ) -- ^ bounds
979+ -> Condition outer grp commons schemas params from
980+notBetweenSymmetric a (x,y) = UnsafeExpression $ renderSQL a
981+ <+> "NOT BETWEEN SYMMETRIC" <+> renderSQL x <+> "AND" <+> renderSQL y
983+{- | not equal, treating null like an ordinary value
984+>>> printSQL $ true `isDistinctFrom` null_
985+(TRUE IS DISTINCT FROM NULL)
988+ :: Expression outer grp commons schemas params from (nullity ty)
989+ -> Expression outer grp commons schemas params from (nullity ty)
990+ -> Condition outer grp commons schemas params from
991+isDistinctFrom = unsafeBinaryOp "IS DISTINCT FROM"
993+{- | equal, treating null like an ordinary value
994+>>> printSQL $ true `isNotDistinctFrom` null_
995+(TRUE IS NOT DISTINCT FROM NULL)
998+ :: Expression outer grp commons schemas params from (nullity ty)
999+ -> Expression outer grp commons schemas params from (nullity ty)
1000+ -> Condition outer grp commons schemas params from
1001+isNotDistinctFrom = unsafeBinaryOp "IS NOT DISTINCT FROM"
1004+>>> printSQL $ true & isTrue
1008+ :: Expression outer grp commons schemas params from (nullity 'PGbool)
1009+ -> Condition outer grp commons schemas params from
1010+isTrue b = UnsafeExpression $ renderSQL b <+> "IS TRUE"
1012+{- | is false or unknown
1013+>>> printSQL $ true & isNotTrue
1017+ :: Expression outer grp commons schemas params from (nullity 'PGbool)
1018+ -> Condition outer grp commons schemas params from
1019+isNotTrue b = UnsafeExpression $ renderSQL b <+> "IS NOT TRUE"
1022+>>> printSQL $ true & isFalse
1026+ :: Expression outer grp commons schemas params from (nullity 'PGbool)
1027+ -> Condition outer grp commons schemas params from
1028+isFalse b = UnsafeExpression $ renderSQL b <+> "IS FALSE"
1030+{- | is true or unknown
1031+>>> printSQL $ true & isNotFalse
1035+ :: Expression outer grp commons schemas params from (nullity 'PGbool)
1036+ -> Condition outer grp commons schemas params from
1037+isNotFalse b = UnsafeExpression $ renderSQL b <+> "IS NOT FALSE"
1040+>>> printSQL $ true & isUnknown
1044+ :: Expression outer grp commons schemas params from (nullity 'PGbool)
1045+ -> Condition outer grp commons schemas params from
1046+isUnknown b = UnsafeExpression $ renderSQL b <+> "IS UNKNOWN"
1048+{- | is true or false
1049+>>> printSQL $ true & isNotUnknown
1053+ :: Expression outer grp commons schemas params from (nullity 'PGbool)
1054+ -> Condition outer grp commons schemas params from
1055+isNotUnknown b = UnsafeExpression $ renderSQL b <+> "IS NOT UNKNOWN"
923-- | >>> printSQL currentDate
1057-- | >>> printSQL currentDate
924-- CURRENT_DATE
1058-- CURRENT_DATE
925currentDate
1059currentDate
@@ -2424,3 +2558,7 @@ instance TimeOp 'PGtime 'PGinterval
2424instance TimeOp 'PGtimetz 'PGinterval
2558instance TimeOp 'PGtimetz 'PGinterval
2425instance TimeOp 'PGinterval 'PGinterval
2559instance TimeOp 'PGinterval 'PGinterval
2426instance TimeOp 'PGdate 'PGint4
2560instance TimeOp 'PGdate 'PGint4