squeal-postgresql-0.9.1.3: Squeal PostgreSQL Library
Copyright(c) Eitan Chatav 2019
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Squeal.PostgreSQL.Expression.Comparison

Description

comparison functions and operators

Synopsis

Comparison Operators

(.==) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 Source #

Comparison operations like .==, ./=, .>, .>=, .< and .<= will produce NULLs if one of their arguments is NULL.

>>> printSQL $ true .== null_
(TRUE = NULL)

(./=) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 Source #

>>> printSQL $ true ./= null_
(TRUE <> NULL)

(.>=) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 Source #

>>> printSQL $ true .>= null_
(TRUE >= NULL)

(.<) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 Source #

>>> printSQL $ true .< null_
(TRUE < NULL)

(.<=) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 Source #

>>> printSQL $ true .<= null_
(TRUE <= NULL)

(.>) :: Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 Source #

>>> printSQL $ true .> null_
(TRUE > NULL)

Comparison Functions

greatest :: FunctionVar ty ty ty Source #

>>> let expr = greatest [param @1] currentTimestamp
>>> printSQL expr
GREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)

least :: FunctionVar ty ty ty Source #

>>> printSQL $ least [null_] currentTimestamp
LEAST(NULL, CURRENT_TIMESTAMP)

Between

type BetweenExpr Source #

Arguments

 = 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)

bounds

-> Condition grp lat with db params from 

A RankNType for comparison expressions like between.

between :: BetweenExpr Source #

>>> printSQL $ true `between` (null_, false)
TRUE BETWEEN NULL AND FALSE

notBetween :: BetweenExpr Source #

>>> printSQL $ true `notBetween` (null_, false)
TRUE NOT BETWEEN NULL AND FALSE

betweenSymmetric :: BetweenExpr Source #

between, after sorting the comparison values

>>> printSQL $ true `betweenSymmetric` (null_, false)
TRUE BETWEEN SYMMETRIC NULL AND FALSE

notBetweenSymmetric :: BetweenExpr Source #

not between, after sorting the comparison values

>>> printSQL $ true `notBetweenSymmetric` (null_, false)
TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE

Null Comparison

isDistinctFrom :: Operator (null0 ty) (null1 ty) (null 'PGbool) Source #

not equal, treating null like an ordinary value

>>> printSQL $ true `isDistinctFrom` null_
(TRUE IS DISTINCT FROM NULL)

isNotDistinctFrom :: Operator (null0 ty) (null1 ty) (null 'PGbool) Source #

equal, treating null like an ordinary value

>>> printSQL $ true `isNotDistinctFrom` null_
(TRUE IS NOT DISTINCT FROM NULL)

isTrue :: null0 'PGbool --> null1 'PGbool Source #

is true

>>> printSQL $ true & isTrue
(TRUE IS TRUE)

isNotTrue :: null0 'PGbool --> null1 'PGbool Source #

is false or unknown

>>> printSQL $ true & isNotTrue
(TRUE IS NOT TRUE)

isFalse :: null0 'PGbool --> null1 'PGbool Source #

is false

>>> printSQL $ true & isFalse
(TRUE IS FALSE)

isNotFalse :: null0 'PGbool --> null1 'PGbool Source #

is true or unknown

>>> printSQL $ true & isNotFalse
(TRUE IS NOT FALSE)

isUnknown :: null0 'PGbool --> null1 'PGbool Source #

is unknown

>>> printSQL $ true & isUnknown
(TRUE IS UNKNOWN)

isNotUnknown :: null0 'PGbool --> null1 'PGbool Source #

is true or false

>>> printSQL $ true & isNotUnknown
(TRUE IS NOT UNKNOWN)