@@ -46,13 +46,11 @@ import Data.Char (isAlphaNum)
4646import Data.Int (Int64 )
4747import Data.List (lookup )
4848import Data.List.NonEmpty (NonEmpty (.. ), toList )
49- import Data.Pool (Pool )
5049import Data.Text (Text )
5150import Data.Text.Encoding (decodeUtf8 )
5251import GHC.Exts (IsString )
5352
5453import qualified Data.ByteString.Char8 as BS
55- import qualified Data.Pool as Pool
5654import qualified Database.PostgreSQL.Simple as PG
5755import qualified Database.PostgreSQL.Simple.ToField as PG
5856import qualified Database.PostgreSQL.Simple.Types as PG
@@ -171,27 +169,27 @@ n =? a = NamedParam n $ PG.toField a
171169and expects a list of rows in return.
172170
173171@
174- queryNamed dbPool [sql|
172+ queryNamed dbConnection [sql|
175173 SELECT id FROM table
176174 WHERE foo = ?foo
177175|] [ "foo" '=?' "bar" ]
178176@
179177-}
180178queryNamed
181179 :: (MonadIO m , WithError m , PG. FromRow res )
182- => Pool PG. Connection -- ^ Database connection pool
180+ => PG. Connection -- ^ Database connection
183181 -> PG. Query -- ^ Query with named parameters inside
184182 -> [NamedParam ] -- ^ The list of named parameters to be used in the query
185183 -> m [res ] -- ^ Resulting rows
186- queryNamed pool qNamed params =
184+ queryNamed conn qNamed params =
187185 withNamedArgs qNamed params >>= \ (q, actions) ->
188- liftIO $ Pool. withResource pool ( \ conn -> PG. query conn q (toList actions) )
186+ liftIO $ PG. query conn q (toList actions)
189187
190188{- | Modifies the database with a given query and named parameters
191189and expects a number of the rows affected.
192190
193191@
194- executeNamed dbPool [sql|
192+ executeNamed dbConnection [sql|
195193 UPDATE table
196194 SET foo = 'bar'
197195 WHERE id = ?id
@@ -200,13 +198,13 @@ executeNamed dbPool [sql|
200198-}
201199executeNamed
202200 :: (MonadIO m , WithError m )
203- => Pool PG. Connection -- ^ Database connection pool
201+ => PG. Connection -- ^ Database connection
204202 -> PG. Query -- ^ Query with named parameters inside
205203 -> [NamedParam ] -- ^ The list of named parameters to be used in the query
206204 -> m Int64 -- ^ Number of the rows affected by the given query
207- executeNamed pool qNamed params =
205+ executeNamed conn qNamed params =
208206 withNamedArgs qNamed params >>= \ (q, actions) ->
209- liftIO $ Pool. withResource pool ( \ conn -> PG. execute conn q (toList actions) )
207+ liftIO $ PG. execute conn q (toList actions)
210208
211209-- | Helper to use named parameters.
212210withNamedArgs
0 commit comments