persistent 2.0.8 → 2.1
raw patch · 7 files changed
+33/−31 lines, 7 files
Files
- Database/Persist/Class/PersistEntity.hs +1/−1
- Database/Persist/Sql.hs +2/−2
- Database/Persist/Sql/Orphan/PersistQuery.hs +15/−15
- Database/Persist/Sql/Orphan/PersistStore.hs +4/−4
- Database/Persist/Sql/Orphan/PersistUnique.hs +1/−1
- Database/Persist/Sql/Types.hs +9/−7
- persistent.cabal +1/−1
Database/Persist/Class/PersistEntity.hs view
@@ -149,7 +149,7 @@ -- your query returns two entities (i.e. @(Entity backend a, -- Entity backend b)@), then you must you use @SELECT ??, ?? -- WHERE ...@, and so on.-data Entity record =+data Entity record = PersistEntity record => Entity { entityKey :: Key record , entityVal :: record }
Database/Persist/Sql.hs view
@@ -37,7 +37,7 @@ -- | Commit the current transaction and begin a new one. -- -- Since 1.2.0-transactionSave :: MonadIO m => ReaderT Connection m ()+transactionSave :: MonadIO m => ReaderT SqlBackend m () transactionSave = do conn <- ask let getter = getStmtConn conn@@ -46,7 +46,7 @@ -- | Roll back the current transaction and begin a new one. -- -- Since 1.2.0-transactionUndo :: MonadIO m => ReaderT Connection m ()+transactionUndo :: MonadIO m => ReaderT SqlBackend m () transactionUndo = do conn <- ask let getter = getStmtConn conn
Database/Persist/Sql/Orphan/PersistQuery.hs view
@@ -26,7 +26,7 @@ import Data.List (transpose, inits, find) -- orphaned instance for convenience of modularity-instance PersistQuery Connection where+instance PersistQuery SqlBackend where count filts = do conn <- ask let wher = if null filts@@ -168,9 +168,9 @@ -- | Same as 'deleteWhere', but returns the number of rows affected. -- -- Since 1.1.5-deleteWhereCount :: (PersistEntity val, MonadIO m, PersistEntityBackend val ~ Connection)+deleteWhereCount :: (PersistEntity val, MonadIO m, PersistEntityBackend val ~ SqlBackend) => [Filter val]- -> ReaderT Connection m Int64+ -> ReaderT SqlBackend m Int64 deleteWhereCount filts = do conn <- ask let t = entityDef $ dummyFromFilts filts@@ -187,10 +187,10 @@ -- | Same as 'updateWhere', but returns the number of rows affected. -- -- Since 1.1.5-updateWhereCount :: (PersistEntity val, MonadIO m, Connection ~ PersistEntityBackend val)+updateWhereCount :: (PersistEntity val, MonadIO m, SqlBackend ~ PersistEntityBackend val) => [Filter val] -> [Update val]- -> ReaderT Connection m Int64+ -> ReaderT SqlBackend m Int64 updateWhereCount _ [] = return 0 updateWhereCount filts upds = do conn <- ask@@ -221,7 +221,7 @@ updateField (Update f _ _) = fieldName f updateField _ = error "BackendUpdate not implemented" -fieldName :: forall record typ. (PersistEntity record, PersistEntityBackend record ~ Connection) => EntityField record typ -> DBName+fieldName :: forall record typ. (PersistEntity record, PersistEntityBackend record ~ SqlBackend) => EntityField record typ -> DBName fieldName f = fieldDB $ persistFieldDef f isIdField :: forall record typ. (PersistEntity record) => EntityField record typ -> Bool@@ -230,16 +230,16 @@ dummyFromFilts :: [Filter v] -> Maybe v dummyFromFilts _ = Nothing -getFiltsValues :: forall val. (PersistEntity val, PersistEntityBackend val ~ Connection)- => Connection -> [Filter val] -> [PersistValue]+getFiltsValues :: forall val. (PersistEntity val, PersistEntityBackend val ~ SqlBackend)+ => SqlBackend -> [Filter val] -> [PersistValue] getFiltsValues conn = snd . filterClauseHelper False False conn OrNullNo data OrNull = OrNullYes | OrNullNo -filterClauseHelper :: (PersistEntity val, PersistEntityBackend val ~ Connection)+filterClauseHelper :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend) => Bool -- ^ include table name? -> Bool -- ^ include WHERE?- -> Connection+ -> SqlBackend -> OrNull -> [Filter val] -> (Text, [PersistValue])@@ -391,16 +391,16 @@ updatePersistValue (Update _ v _) = toPersistValue v updatePersistValue _ = error "BackendUpdate not implemented" -filterClause :: (PersistEntity val, PersistEntityBackend val ~ Connection)+filterClause :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend) => Bool -- ^ include table name?- -> Connection+ -> SqlBackend -> [Filter val] -> Text filterClause b c = fst . filterClauseHelper b True c OrNullNo -orderClause :: (PersistEntity val, PersistEntityBackend val ~ Connection)+orderClause :: (PersistEntity val, PersistEntityBackend val ~ SqlBackend) => Bool -- ^ include the table name- -> Connection+ -> SqlBackend -> SelectOpt val -> Text orderClause includeTable conn o =@@ -414,7 +414,7 @@ tn = connEscapeName conn $ entityDB $ entityDef $ dummyFromOrder o - name :: (PersistEntityBackend record ~ Connection, PersistEntity record)+ name :: (PersistEntityBackend record ~ SqlBackend, PersistEntity record) => EntityField record typ -> Text name x = (if includeTable
Database/Persist/Sql/Orphan/PersistStore.hs view
@@ -36,7 +36,7 @@ => Text -> [PersistValue] -> C.Sink [PersistValue] IO a- -> ReaderT Connection m a+ -> ReaderT SqlBackend m a withRawQuery sql vals sink = do srcRes <- rawQueryRes sql vals liftIO $ with srcRes (C.$$ sink)@@ -47,8 +47,8 @@ fromSqlKey :: ToBackendKey SqlBackend record => Key record -> Int64 fromSqlKey = unSqlBackendKey . toBackendKey -instance PersistStore Connection where- newtype BackendKey Connection = SqlBackendKey { unSqlBackendKey :: Int64 }+instance PersistStore SqlBackend where+ newtype BackendKey SqlBackend = SqlBackendKey { unSqlBackendKey :: Int64 } deriving (Show, Read, Eq, Ord, Num, Integral, PersistField, PersistFieldSql, PathPiece, Real, Enum, Bounded, A.ToJSON, A.FromJSON) update _ [] = return ()@@ -232,7 +232,7 @@ => Text -> Key val -> val- -> ReaderT Connection m ()+ -> ReaderT SqlBackend m () insrepHelper command k val = do conn <- ask rawExecute (sql conn) vals
Database/Persist/Sql/Orphan/PersistUnique.hs view
@@ -11,7 +11,7 @@ import qualified Data.Conduit.List as CL import Control.Monad.Trans.Reader (ask) -instance PersistUnique Connection where+instance PersistUnique SqlBackend where deleteBy uniq = do conn <- ask let sql' = sql conn
Database/Persist/Sql/Types.hs view
@@ -35,7 +35,11 @@ | ISRInsertGet Text Text | ISRManyKeys Text [PersistValue] -data Connection = Connection+-- | Deprecated synonym for @SqlBackend@.+type Connection = SqlBackend+{-# DEPRECATED Connection "Please use SqlBackend instead" #-}++data SqlBackend = SqlBackend { connPrepare :: Text -> IO Statement -- | table name, column names, id name, either 1 or 2 statements to run , connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult@@ -56,7 +60,7 @@ , connLogFunc :: LogFunc } deriving Typeable-instance HasPersistBackend Connection Connection where+instance HasPersistBackend SqlBackend SqlBackend where persistBackend = id type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()@@ -86,9 +90,7 @@ deriving (Typeable, Show) instance Exception PersistentSqlException -type SqlBackend = Connection -- FIXME--type SqlPersistT = ReaderT Connection -- FIXME rename connection+type SqlPersistT = ReaderT SqlBackend type SqlPersist = SqlPersistT {-# DEPRECATED SqlPersist "Please use SqlPersistT instead" #-}@@ -100,9 +102,9 @@ -- Bool indicates if the Sql is safe type CautiousMigration = [(Bool, Sql)] -type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT Connection IO)) ()+type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT SqlBackend IO)) () -type ConnectionPool = Pool Connection+type ConnectionPool = Pool SqlBackend -- $rawSql --
persistent.cabal view
@@ -1,5 +1,5 @@ name: persistent-version: 2.0.8+version: 2.1 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>