mergeful-persistent 0.1.0.0 → 0.3.0.1
raw patch · 9 files changed
+59/−26 lines, 9 filesdep +genvalidity-sydtestdep +sydtestdep −genvalidity-hspecdep −hspec
Dependencies added: genvalidity-sydtest, sydtest
Dependencies removed: genvalidity-hspec, hspec
Files
- CHANGELOG.md +7/−1
- mergeful-persistent.cabal +9/−7
- src/Data/Mergeful/Persistent.hs +17/−0
- test/Data/Mergeful/Persistent/SingleClientSpec.hs +8/−7
- test/Data/Mergeful/Persistent/TwoClientsSpec.hs +9/−8
- test/Spec.hs +1/−1
- test/TestUtils.hs +2/−2
- test/TestUtils/ClientDB.hs +3/−0
- test/TestUtils/ServerDB.hs +3/−0
CHANGELOG.md view
@@ -1,8 +1,14 @@ # Changelog +## [0.3.0.1] - 2023-10-09++### Added++* Compatibility with `GHC >= 9.8`+ ## [0.1.0.0] - 2021-11-21 -### Changed+### Added * Compatibility with `genvalidity >=1.0.0.0`
mergeful-persistent.cabal view
@@ -1,19 +1,19 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack ----- hash: 5657a1667a82a170333369c773c8638a88b0180dcfb0e4bc3ca27ae41b17d8c7+-- hash: f1825b7760a748576b346fb51ec1d6d60f8dfd75f7e9f5362292519ff902e735 name: mergeful-persistent-version: 0.1.0.0+version: 0.3.0.1 synopsis: Support for using mergeful from persistent-based databases homepage: https://github.com/NorfairKing/mergeful#readme bug-reports: https://github.com/NorfairKing/mergeful/issues author: Tom Sydney Kerckhove-maintainer: syd.kerckhove@gmail.com-copyright: Copyright: (c) 2021 Tom Sydney Kerckhove+maintainer: syd@cs-syd.eu+copyright: Copyright: (c) 2021-2023 Tom Sydney Kerckhove license: MIT license-file: LICENSE build-type: Simple@@ -54,15 +54,16 @@ hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-tool-depends:+ sydtest-discover:sydtest-discover build-depends: QuickCheck , base >=4.11 && <5 , containers , genvalidity >=1.0- , genvalidity-hspec , genvalidity-mergeful , genvalidity-persistent- , hspec+ , genvalidity-sydtest , mergeful , mergeful-persistent , monad-logger@@ -72,6 +73,7 @@ , persistent , persistent-sqlite , persistent-template+ , sydtest , text , validity , validity-persistent
src/Data/Mergeful/Persistent.hs view
@@ -1,10 +1,16 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-}+-- Because newer versions of persistent do not required a+-- ToBackendKey SlBackend constraint in some places.+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-} module Data.Mergeful.Persistent ( -- * Client side@@ -128,6 +134,7 @@ PersistField sid, PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => -- | The server id field@@ -177,6 +184,7 @@ PersistField sid, PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => -- | The server id field@@ -275,6 +283,7 @@ forall record sid a m. ( PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => (a -> record) ->@@ -359,6 +368,7 @@ ( PersistEntity record, PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => -- | The server time field@@ -395,6 +405,7 @@ ( PersistEntity record, PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => -- | The server time field@@ -432,6 +443,7 @@ PersistField sid, PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => -- | The custom id field@@ -477,6 +489,7 @@ PersistField sid, PersistEntityBackend record ~ SqlBackend, ToBackendKey SqlBackend record,+ SafeToInsert record, MonadIO m ) => -- | The custom id field@@ -540,3 +553,7 @@ (Entity record -> (sid, Timed a)) -> SqlPersistT IO (ServerStore sid a) serverGetStoreQuery func = ServerStore . M.fromList . map func <$> selectList [] []++#if !MIN_VERSION_persistent(2,14,0)+type SafeToInsert a = a ~ a+#endif
test/Data/Mergeful/Persistent/SingleClientSpec.hs view
@@ -12,15 +12,14 @@ import qualified Data.Map as M import Data.Mergeful import Database.Persist.Sql-import Test.Hspec-import Test.Hspec.QuickCheck-import Test.Validity+import Test.Syd hiding (Timed (..), runTest)+import Test.Syd.Validity import TestUtils {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} spec :: Spec-spec = modifyMaxShrinks (const 0) $+spec = oneClientSpec $ do describe "sanity" $ do describe "setupClient & clientGetStore" $ do@@ -171,12 +170,14 @@ clientMergeSyncResponse strat = runClientDB . clientMergeSyncResponseThingQuery strat data TestEnv = TestEnv- { testEnvClientPool :: ConnectionPool,- testEnvServerPool :: ConnectionPool+ { testEnvClientPool :: !ConnectionPool,+ testEnvServerPool :: !ConnectionPool } oneClientSpec :: SpecWith TestEnv -> Spec-oneClientSpec = around withTestEnv+oneClientSpec =+ modifyMaxSuccess (`div` 10)+ . around withTestEnv withTestEnv :: (TestEnv -> IO a) -> IO a withTestEnv func =
test/Data/Mergeful/Persistent/TwoClientsSpec.hs view
@@ -12,15 +12,14 @@ import Data.Mergeful import qualified Data.Set as S import Database.Persist.Sql-import Test.Hspec-import Test.Hspec.QuickCheck-import Test.Validity+import Test.Syd hiding (Timed (..), runTest)+import Test.Syd.Validity import TestUtils {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} spec :: Spec-spec = modifyMaxShrinks (const 0) $+spec = twoClientsSpec $ do describe "sanity" $ do describe "setupClient & clientGetStore" $ do@@ -505,13 +504,15 @@ deriving (Show, Eq) data TestEnv = TestEnv- { testEnvServerPool :: ConnectionPool,- testEnvClient1Pool :: ConnectionPool,- testEnvClient2Pool :: ConnectionPool+ { testEnvServerPool :: !ConnectionPool,+ testEnvClient1Pool :: !ConnectionPool,+ testEnvClient2Pool :: !ConnectionPool } twoClientsSpec :: SpecWith TestEnv -> Spec-twoClientsSpec = around withTestEnv+twoClientsSpec =+ modifyMaxSuccess (`div` 10)+ . around withTestEnv withTestEnv :: (TestEnv -> IO a) -> IO a withTestEnv func =
test/Spec.hs view
@@ -1,1 +1,1 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}+{-# OPTIONS_GHC -F -pgmF sydtest-discover #-}
test/TestUtils.hs view
@@ -27,12 +27,12 @@ withServerPool func = runNoLoggingT $ withSqlitePool ":memory:" 1 $ \serverPool -> do- flip runSqlPool serverPool $ void $ runMigrationSilent migrateServer+ flip runSqlPool serverPool $ void $ runMigrationQuiet migrateServer liftIO $ func serverPool withClientPool :: (ConnectionPool -> IO a) -> IO a withClientPool func = runNoLoggingT $ withSqlitePool ":memory:" 1 $ \clientPool -> do- flip runSqlPool clientPool $ void $ runMigrationSilent migrateClient+ flip runSqlPool clientPool $ void $ runMigrationQuiet migrateClient liftIO $ func clientPool
test/TestUtils/ClientDB.hs view
@@ -1,5 +1,7 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -8,6 +10,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module TestUtils.ClientDB where
test/TestUtils/ServerDB.hs view
@@ -1,5 +1,7 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -9,6 +11,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module TestUtils.ServerDB where