on 29cdfdb help sign in
31 lines 740 B history raw
1{-# language MonoLocalBinds #-}
3module Rel8.Statement.Where
4 ( ppWhere
5 )
6where
8-- base
9import Prelude
11-- opaleye
12import qualified Opaleye.Internal.HaskellDB.Sql.Print as Opaleye
13import qualified Opaleye.Internal.Sql as Opaleye
15-- pretty
16import Text.PrettyPrint ( Doc, (<+>), text )
18-- rel8
19import Rel8.Expr ( Expr )
20import Rel8.Expr.Opaleye ( toPrimExpr )
21import Rel8.Schema.Name ( Selects )
22import Rel8.Schema.Table ( TableSchema )
23import Rel8.Table.Opaleye ( attributes )
26ppWhere :: Selects names exprs
27 => TableSchema names -> (exprs -> Expr Bool) -> Doc
28ppWhere schema where_ = text "WHERE" <+> ppExpr condition
29 where
30 ppExpr = Opaleye.ppSqlExpr . Opaleye.sqlExpr . toPrimExpr
31 condition = where_ (attributes schema)