@@ -7,14 +7,11 @@ module Rel8.Statement.View
10−import Control.Exception ( throwIO )
11import Prelude
10import Prelude
14−import Hasql.Connection ( Connection )
15import qualified Hasql.Decoders as Hasql
13import qualified Hasql.Decoders as Hasql
16import qualified Hasql.Encoders as Hasql
14import qualified Hasql.Encoders as Hasql
17−import qualified Hasql.Session as Hasql
18import qualified Hasql.Statement as Hasql
15import qualified Hasql.Statement as Hasql
@@ -36,12 +33,9 @@ import Data.Text.Encoding ( encodeUtf8 )
36-- statement that will save the given query as a view. This can be useful if
33-- statement that will save the given query as a view. This can be useful if
37-- you want to share Rel8 queries with other applications.
34-- you want to share Rel8 queries with other applications.
38createView :: Selects names exprs
35createView :: Selects names exprs
39− => Connection -> TableSchema names -> Query exprs -> IO ()
36+ => TableSchema names -> Query exprs -> Hasql.Statement () ()
40−createView connection schema query =
37+createView schema query = Hasql.Statement bytes params decode prepare
41− Hasql.run session connection >>= either throwIO pure
43− session = Hasql.statement () statement
44− statement = Hasql.Statement bytes params decode prepare
45 bytes = encodeUtf8 (Text.pack sql)
39 bytes = encodeUtf8 (Text.pack sql)
46 params = Hasql.noParams
40 params = Hasql.noParams
47 decode = Hasql.noResult
41 decode = Hasql.noResult