Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "More BackendCompatible generalizations (#723)" #759

Merged
merged 1 commit into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions persistent-mysql/Database/Persist/MySQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Control.Monad.Logger (MonadLogger, runNoLoggingT)
import Control.Monad.IO.Class (MonadIO (..))
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Except (runExceptT)
import Control.Monad.Trans.Reader (runReaderT, ReaderT)
import Control.Monad.Trans.Reader (runReaderT, ReaderT, withReaderT)
import Control.Monad.Trans.Writer (runWriterT)
import Data.Either (partitionEithers)
import Data.Monoid ((<>))
Expand Down Expand Up @@ -1182,7 +1182,8 @@ insertManyOnDuplicateKeyUpdate
-> ReaderT backend m ()
insertManyOnDuplicateKeyUpdate [] _ _ = return ()
insertManyOnDuplicateKeyUpdate records fieldValues updates =
uncurry rawExecute
withReaderT projectBackend
. uncurry rawExecute
$ mkBulkInsertQuery records fieldValues updates

-- | This creates the query for 'bulkInsertOnDuplicateKeyUpdate'. If you
Expand Down
2 changes: 1 addition & 1 deletion persistent-mysql/persistent-mysql.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent-mysql
version: 2.6.2.2
version: 2.6.2.1
license: MIT
license-file: LICENSE
author: Felipe Lessa <felipe.lessa@gmail.com>, Michael Snoyman
Expand Down
7 changes: 5 additions & 2 deletions persistent/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
## 2.7.2.1
## 2.7.3

* Reverts [#723](https://github.com/yesodweb/persistent/pull/723), which generalized functions using the `BackendCompatible` class. These changes were an accidental breaking change.
* Recommend the `PersistDbSpecific` docs if someone gets an error about converting from `PersistDbSpecific`

## 2.7.2
## 2.7.2 [DEPRECATED ON HACKAGE]

* Many of the functions have been generalized using the `BackendCompatible` class. [#723](https://github.com/yesodweb/persistent/pull/723)
* This change was an accidental breaking change and was reverted in 2.7.3.
* These change will be released in a future version of Persistent with a major version bump.
* Add raw sql quasi quoters [#717](https://github.com/yesodweb/persistent/pull/717)

## 2.7.1
Expand Down
1 change: 0 additions & 1 deletion persistent/Database/Persist/Sql/Migration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Control.Monad.Trans.Control (liftBaseOp_)
import Database.Persist.Sql.Types
import Database.Persist.Sql.Raw
import Database.Persist.Types
import Database.Persist.Sql.Orphan.PersistStore()

allSql :: CautiousMigration -> [Sql]
allSql = map snd
Expand Down
12 changes: 6 additions & 6 deletions persistent/Database/Persist/Sql/Raw.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ rawQueryRes sql vals = do
stmtQuery stmt vals

-- | Execute a raw SQL statement
rawExecute :: (MonadIO m, BackendCompatible SqlBackend backend)
rawExecute :: MonadIO m
=> Text -- ^ SQL statement, possibly with placeholders.
-> [PersistValue] -- ^ Values to fill the placeholders.
-> ReaderT backend m ()
-> ReaderT SqlBackend m ()
rawExecute x y = liftM (const ()) $ rawExecuteCount x y

-- | Execute a raw SQL statement and return the number of
-- rows it has modified.
rawExecuteCount :: (MonadIO m, BackendCompatible SqlBackend backend)
rawExecuteCount :: (MonadIO m, IsSqlBackend backend)
=> Text -- ^ SQL statement, possibly with placeholders.
-> [PersistValue] -- ^ Values to fill the placeholders.
-> ReaderT backend m Int64
rawExecuteCount sql vals = do
conn <- projectBackend `liftM` ask
conn <- persistBackend `liftM` ask
runLoggingT (logDebugNS (pack "SQL") $ T.append sql $ pack $ "; " ++ show vals)
(connLogFunc conn)
stmt <- getStmt sql
Expand All @@ -69,10 +69,10 @@ rawExecuteCount sql vals = do
return res

getStmt
:: (MonadIO m, BackendCompatible SqlBackend backend)
:: (MonadIO m, IsSqlBackend backend)
=> Text -> ReaderT backend m Statement
getStmt sql = do
conn <- projectBackend `liftM` ask
conn <- persistBackend `liftM` ask
liftIO $ getStmtConn conn sql

getStmtConn :: SqlBackend -> Text -> IO Statement
Expand Down
4 changes: 1 addition & 3 deletions persistent/Database/Persist/Sql/Types/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
Expand Down Expand Up @@ -40,7 +39,6 @@ import Database.Persist.Class
, PersistQueryRead, PersistQueryWrite
, PersistStoreRead, PersistStoreWrite
, PersistUniqueRead, PersistUniqueWrite
, BackendCompatible(..)
)
import Database.Persist.Class.PersistStore (IsPersistBackend (..))
import Database.Persist.Types
Expand Down Expand Up @@ -132,7 +130,7 @@ readToUnknown ma = do

-- | A constraint synonym which witnesses that a backend is SQL and can run read queries.
type SqlBackendCanRead backend =
( BackendCompatible SqlBackend backend
( IsSqlBackend backend
, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend
)
-- | A constraint synonym which witnesses that a backend is SQL and can run read and write queries.
Expand Down
2 changes: 1 addition & 1 deletion persistent/persistent.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent
version: 2.7.2.1
version: 2.7.3
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand Down