squeal-postgresql-0.5.2.0: Squeal PostgreSQL Library

Copyright(c) Eitan Chatav 2019
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Squeal.PostgreSQL.Expression.Logic

Description

Logical expressions and operators

Synopsis

Documentation

type Condition outer commons grp schemas params from = Expression outer commons grp schemas params from (Null PGbool) Source #

A Condition is an Expression, which can evaluate to true, false or null_. This is because SQL uses a three valued logic.

true :: Expr (null PGbool) Source #

>>> printSQL true
TRUE

false :: Expr (null PGbool) Source #

>>> printSQL false
FALSE

not_ :: null PGbool :--> null PGbool Source #

>>> printSQL $ not_ true
(NOT TRUE)

(.&&) :: Operator (null PGbool) (null PGbool) (null PGbool) infixr 3 Source #

>>> printSQL $ true .&& false
(TRUE AND FALSE)

(.||) :: Operator (null PGbool) (null PGbool) (null PGbool) infixr 2 Source #

>>> printSQL $ true .|| false
(TRUE OR FALSE)

caseWhenThenElse Source #

Arguments

:: [(Condition outer commons grp schemas params from, Expression outer commons grp schemas params from ty)]

whens and thens

-> Expression outer commons grp schemas params from ty

else

-> Expression outer commons grp schemas params from ty 
>>> :{
let
  expression :: Expression outer commons grp schemas params from (null 'PGint2)
  expression = caseWhenThenElse [(true, 1), (false, 2)] 3
in printSQL expression
:}
CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END

ifThenElse Source #

Arguments

:: Condition outer commons grp schemas params from 
-> Expression outer commons grp schemas params from ty

then

-> Expression outer commons grp schemas params from ty

else

-> Expression outer commons grp schemas params from ty 
>>> :{
let
  expression :: Expression outer commons grp schemas params from (null 'PGint2)
  expression = ifThenElse true 1 0
in printSQL expression
:}
CASE WHEN TRUE THEN 1 ELSE 0 END