packages feed

persistent 2.9.1 → 2.9.2

raw patch · 6 files changed

+57/−7 lines, 6 files

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for persistent +## 2.9.2++* Add documentation for the `Migration` type and some helpers. [#860](https://github.com/yesodweb/persistent/pull/860)+ ## 2.9.1  * Fix [#847](https://github.com/yesodweb/persistent/issues/847): SQL error with `putMany` on Sqlite when Entity has no unique index.
Database/Persist/Class/PersistField.hs view
@@ -190,8 +190,8 @@     fromPersistValue x = Left $ fromPersistValueError "Int32" "integer" x  instance PersistField Int64 where-    toPersistValue = PersistInt64 . fromIntegral-    fromPersistValue (PersistInt64 i)  = Right $ fromIntegral i+    toPersistValue = PersistInt64+    fromPersistValue (PersistInt64 i)  = Right i     fromPersistValue (PersistDouble i) = Right (truncate i :: Int64) -- oracle     fromPersistValue (PersistByteString bs) = case readInt bs of  -- oracle                                                Just (i,"") -> Right $ fromIntegral i
Database/Persist/Sql/Migration.hs view
@@ -10,6 +10,11 @@   , runMigrationSilent   , runMigrationUnsafe   , migrate+  -- * Utilities for constructing migrations+  , reportErrors+  , reportError+  , addMigrations+  , addMigration   ) where  @@ -140,4 +145,37 @@ migrate allDefs val = do     conn <- lift $ lift ask     res <- liftIO $ connMigrateSql conn allDefs (getStmtConn conn) val-    either tell (lift . tell) res+    either reportErrors addMigrations res++-- | Report a single error in a 'Migration'.+--+-- @since 2.9.2+reportError :: Text -> Migration+reportError = tell . pure++-- | Report multiple errors in a 'Migration'.+--+-- @since 2.9.2+reportErrors :: [Text] -> Migration+reportErrors = tell++-- | Add a migration to the migration plan.+--+-- @since 2.9.2+addMigration+    :: Bool+    -- ^ Is the migration safe to run? (eg a non-destructive and idempotent+    -- update on the schema)+    -> Sql+    -- ^ A 'Text' value representing the command to run on the database.+    -> Migration+addMigration isSafe sql = lift (tell [(isSafe, sql)])++-- | Add a 'CautiousMigration' (aka a @[('Bool', 'Text')]@) to the+-- migration plan.+--+-- @since 2.9.2+addMigrations+    :: CautiousMigration+    -> Migration+addMigrations = lift . tell
Database/Persist/Sql/Orphan/PersistStore.hs view
@@ -26,7 +26,7 @@ import Database.Persist.Sql.Util (     dbIdColumns, keyAndEntityColumnNames, parseEntityValues, entityColumnNames   , updatePersistValue, mkUpdateText, commaSeparated)-import           Data.Conduit (ConduitM, (=$=), (.|), runConduit)+import           Data.Conduit (ConduitM, (.|), runConduit) import qualified Data.Conduit.List as CL import qualified Data.Text as T import Data.Text (Text, unpack)@@ -335,7 +335,7 @@                     Left s -> liftIO $ throwIO $ PersistMarshalError s                     Right row -> return row         withRawQuery sql (Foldable.foldMap keyToValues ks) $ do-            es <- CL.mapM parse =$= CL.consume+            es <- CL.mapM parse .| CL.consume             return $ Map.fromList $ fmap (\e -> (entityKey e, entityVal e)) es  instance PersistStoreRead SqlReadBackend where
Database/Persist/Sql/Types.hs view
@@ -60,6 +60,14 @@ -- Bool indicates if the Sql is safe type CautiousMigration = [(Bool, Sql)] +-- | A 'Migration' is a four level monad stack consisting of:+--+-- * @'WriterT' ['Text']@ representing a log of errors in the migrations.+-- * @'WriterT' 'CautiousMigration'@ representing a list of migrations to+--   run, along with whether or not they are safe.+-- * @'ReaderT' 'SqlBackend'@, aka the 'SqlPersistT' transformer for+--   database interop.+-- * @'IO'@ for arbitrary IO. type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT SqlBackend IO)) ()  type ConnectionPool = Pool SqlBackend
persistent.cabal view
@@ -1,5 +1,5 @@ name:            persistent-version:         2.9.1+version:         2.9.2 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -22,7 +22,7 @@     if flag(nooverlap)         cpp-options: -DNO_OVERLAP -    build-depends:   base                     >= 4.7       && < 5+    build-depends:   base                     >= 4.8       && < 5                    , bytestring               >= 0.9                    , transformers             >= 0.2.1                    , time                     >= 1.1.4