From 8a9a78bd4cc99d12c73e291971e5990cdae8921d Mon Sep 17 00:00:00 2001 From: Eric Easley Date: Sun, 10 Apr 2016 13:04:48 -0700 Subject: [PATCH] Generalize `defaultGetDBRunner` --- stack.yaml | 2 +- yesod-persistent/Yesod/Persist/Core.hs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stack.yaml b/stack.yaml index 5224ddd8..c99d451b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ packages: - ./yesod-websockets - location: git: https://github.com/pseudonom/persistent.git - commit: 0edba747e49c816e94c235bced16978cb729b175 + commit: 1b7b70ed5d36adaffaf4cf9927fefcf16fec8969 subdirs: - persistent diff --git a/yesod-persistent/Yesod/Persist/Core.hs b/yesod-persistent/Yesod/Persist/Core.hs index d54485d5..abc77b53 100644 --- a/yesod-persistent/Yesod/Persist/Core.hs +++ b/yesod-persistent/Yesod/Persist/Core.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} @@ -80,12 +81,12 @@ newtype DBRunner site = DBRunner -- | Helper for implementing 'getDBRunner'. -- -- Since 1.2.0 -defaultGetDBRunner :: YesodPersistBackend site ~ SQL.SqlBackend - => (site -> Pool SQL.SqlBackend) +defaultGetDBRunner :: (SQL.IsSqlBackend backend, YesodPersistBackend site ~ backend) + => (site -> Pool backend) -> HandlerT site IO (DBRunner site, HandlerT site IO ()) defaultGetDBRunner getPool = do pool <- fmap getPool getYesod - let withPrep conn f = f conn (SQL.connPrepare conn) + let withPrep conn f = f (persistBackend conn) (SQL.connPrepare $ persistBackend conn) (relKey, (conn, local)) <- allocate (do (conn, local) <- takeResource pool