module Database.Relational.Query.Expr (
Expr,
valueExpr,
just, fromJust,
exprAnd
) where
import Prelude hiding (and, or)
import Database.Relational.Query.Expr.Unsafe (Expr(Expr), unsafeStringSql)
import Database.Relational.Query.Pure (ShowConstantTermsSQL, showConstantTermsSQL')
import Database.Relational.Query.Internal.SQL (rowStringSQL)
import qualified Language.SQL.Keyword as SQL
valueExpr :: ShowConstantTermsSQL ft => ft -> Expr p ft
valueExpr = Expr . rowStringSQL . showConstantTermsSQL'
unsafeCastExpr :: Expr p a -> Expr p b
unsafeCastExpr = Expr . unsafeStringSql
just :: Expr p ft -> Expr p (Maybe ft)
just = unsafeCastExpr
fromJust :: Expr p (Maybe ft) -> Expr p ft
fromJust = unsafeCastExpr
exprAnd :: Expr p Bool -> Expr p Bool -> Expr p Bool
exprAnd a b = Expr . SQL.paren $ SQL.and (unsafeStringSql a) (unsafeStringSql b)