resourcet 1.1
This commit is contained in:
parent
7f6ae061da
commit
d47a1a00e3
@ -72,7 +72,7 @@ library
|
|||||||
|
|
||||||
, monad-logger
|
, monad-logger
|
||||||
, conduit
|
, conduit
|
||||||
, resourcet
|
, resourcet >= 1.1
|
||||||
hs-source-dirs: src/
|
hs-source-dirs: src/
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
|
|||||||
@ -64,6 +64,8 @@ import qualified Data.Text as T
|
|||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
import qualified Data.Text.Lazy.Builder as TLB
|
import qualified Data.Text.Lazy.Builder as TLB
|
||||||
import qualified Data.Text.Lazy.Builder.Int as TLBI
|
import qualified Data.Text.Lazy.Builder.Int as TLBI
|
||||||
|
import Data.Acquire (with, allocateAcquire, Acquire)
|
||||||
|
import Control.Monad.Trans.Resource (MonadResource)
|
||||||
|
|
||||||
import Database.Esqueleto.Internal.Language
|
import Database.Esqueleto.Internal.Language
|
||||||
|
|
||||||
@ -523,7 +525,7 @@ rawSelectSource :: ( SqlSelect a r
|
|||||||
, MonadIO m2 )
|
, MonadIO m2 )
|
||||||
=> Mode
|
=> Mode
|
||||||
-> SqlQuery a
|
-> SqlQuery a
|
||||||
-> SqlPersistT m1 (Res.Resource (C.Source m2 r))
|
-> SqlPersistT m1 (Acquire (C.Source m2 r))
|
||||||
rawSelectSource mode query =
|
rawSelectSource mode query =
|
||||||
do
|
do
|
||||||
conn <- R.ask
|
conn <- R.ask
|
||||||
@ -549,13 +551,13 @@ rawSelectSource mode query =
|
|||||||
-- | Execute an @esqueleto@ @SELECT@ query inside @persistent@'s
|
-- | Execute an @esqueleto@ @SELECT@ query inside @persistent@'s
|
||||||
-- 'SqlPersistT' monad and return a 'C.Source' of rows.
|
-- 'SqlPersistT' monad and return a 'C.Source' of rows.
|
||||||
selectSource :: ( SqlSelect a r
|
selectSource :: ( SqlSelect a r
|
||||||
, C.MonadResource m )
|
, MonadResource m )
|
||||||
=> SqlQuery a
|
=> SqlQuery a
|
||||||
-> C.Source (SqlPersistT m) r
|
-> C.Source (SqlPersistT m) r
|
||||||
selectSource query = do
|
selectSource query = do
|
||||||
src <- lift $ do
|
src <- lift $ do
|
||||||
res <- rawSelectSource SELECT query
|
res <- rawSelectSource SELECT query
|
||||||
fmap snd $ Res.allocateResource res
|
fmap snd $ allocateAcquire res
|
||||||
src
|
src
|
||||||
|
|
||||||
|
|
||||||
@ -606,7 +608,7 @@ select :: ( SqlSelect a r
|
|||||||
select query = do
|
select query = do
|
||||||
res <- rawSelectSource SELECT query
|
res <- rawSelectSource SELECT query
|
||||||
conn <- R.ask
|
conn <- R.ask
|
||||||
liftIO $ Res.with res $ flip R.runReaderT conn . runSource
|
liftIO $ with res $ flip R.runReaderT conn . runSource
|
||||||
|
|
||||||
|
|
||||||
-- | Execute an @esqueleto@ @SELECT DISTINCT@ query inside
|
-- | Execute an @esqueleto@ @SELECT DISTINCT@ query inside
|
||||||
@ -614,13 +616,13 @@ select query = do
|
|||||||
-- rows.
|
-- rows.
|
||||||
selectDistinctSource
|
selectDistinctSource
|
||||||
:: ( SqlSelect a r
|
:: ( SqlSelect a r
|
||||||
, C.MonadResource m )
|
, MonadResource m )
|
||||||
=> SqlQuery a
|
=> SqlQuery a
|
||||||
-> C.Source (SqlPersistT m) r
|
-> C.Source (SqlPersistT m) r
|
||||||
selectDistinctSource query = do
|
selectDistinctSource query = do
|
||||||
src <- lift $ do
|
src <- lift $ do
|
||||||
res <- rawSelectSource SELECT_DISTINCT query
|
res <- rawSelectSource SELECT_DISTINCT query
|
||||||
fmap snd $ Res.allocateResource res
|
fmap snd $ allocateAcquire res
|
||||||
src
|
src
|
||||||
|
|
||||||
|
|
||||||
@ -632,7 +634,7 @@ selectDistinct :: ( SqlSelect a r
|
|||||||
selectDistinct query = do
|
selectDistinct query = do
|
||||||
res <- rawSelectSource SELECT_DISTINCT query
|
res <- rawSelectSource SELECT_DISTINCT query
|
||||||
conn <- R.ask
|
conn <- R.ask
|
||||||
liftIO $ Res.with res $ flip R.runReaderT conn . runSource
|
liftIO $ with res $ flip R.runReaderT conn . runSource
|
||||||
|
|
||||||
|
|
||||||
-- | (Internal) Run a 'C.Source' of rows.
|
-- | (Internal) Run a 'C.Source' of rows.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user