packages feed

persistent-sql-lifted 0.4.2.0 → 0.4.3.0

raw patch · 10 files changed

+217/−188 lines, 10 files

Files

CHANGELOG.md view
@@ -1,4 +1,8 @@-## [_Unreleased_](https://github.com/freckle/persistent-sql-lifted/compare/persistent-sql-lifted-v0.4.2.0...main)+## [_Unreleased_](https://github.com/freckle/persistent-sql-lifted/compare/persistent-sql-lifted-v0.4.3.0...main)++## [v0.4.3.0](https://github.com/freckle/persistent-sql-lifted/compare/persistent-sql-lifted-v0.4.2.0...persistent-sql-lifted-v0.4.3.0)++Add `updateGetEntity`  ## [v0.4.2.0](https://github.com/freckle/persistent-sql-lifted/compare/persistent-sql-lifted-v0.4.1.0...persistent-sql-lifted-v0.4.2.0) 
library/Database/Persist/Sql/Lifted.hs view
@@ -63,6 +63,7 @@   , updateCount   , update'   , updateGet+  , updateGetEntity   , updateWhere   , updateWhereCount @@ -114,22 +115,39 @@ #if MIN_VERSION_base(4,17,0) import Data.Type.Equality (type (~)) #endif+import Data.Functor ((<$>)) import Database.Persist (Key, PersistEntity (PersistEntityBackend), Update) import Database.Persist.Sql.Lifted.Core import Database.Persist.Sql.Lifted.Esqueleto import Database.Persist.Sql.Lifted.Persistent hiding (delete, update) import Database.Persist.Sql.Lifted.Persistent qualified as Persistent+import Database.Persist.Types (Entity (..)) import GHC.Stack (HasCallStack)  -- | Update individual fields on a specific record update'   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> [Update a]   -> m () update' = Persistent.update++-- | Update individual fields on a specific record, and retrieve the updated 'Entity' from the database+--+-- This function will throw an exception if the given key is not found in the database.+updateGetEntity+  :: forall a m+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend+     )+  => Key a+  -> [Update a]+  -> m (Entity a)+updateGetEntity k us = Entity k <$> updateGet k us
library/Database/Persist/Sql/Lifted/Esqueleto.hs view
@@ -38,13 +38,13 @@ import GHC.Stack (HasCallStack)  -- | Execute an Esqueleto DELETE query-delete :: forall m. (MonadSqlBackend m, HasCallStack) => SqlQuery () -> m ()+delete :: forall m. (HasCallStack, MonadSqlBackend m) => SqlQuery () -> m () delete q = liftSql $ E.delete q  -- | Execute an Esqueleto DELETE query deleteCount   :: forall m-   . (MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m)   => SqlQuery ()   -> m Int64   -- ^ The number of rows affected@@ -55,10 +55,10 @@ -- Does nothing if record does not exist. deleteKey   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> m ()@@ -67,9 +67,9 @@ -- | Insert a 'E.PersistField' for every selected value insertSelect   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a      )   => SqlQuery (SqlExpr (Insertion a))   -> m ()@@ -78,9 +78,9 @@ -- | Insert a 'PersistField' for every selected value, returning the count insertSelectCount   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a      )   => SqlQuery (SqlExpr (Insertion a))   -> m Int64@@ -91,9 +91,9 @@ --   that would be supplied to the database for @?@ placeholders renderQueryDelete   :: forall a r m-   . ( SqlSelect a r+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , SqlSelect a r      )   => SqlQuery a   -- ^ SQL query to render@@ -104,9 +104,9 @@ --   that would be supplied to the database for @?@ placeholders renderQueryInsertInto   :: forall a r m-   . ( SqlSelect a r+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , SqlSelect a r      )   => SqlQuery a   -- ^ SQL query to render@@ -117,9 +117,9 @@ --   that would be supplied to the database for @?@ placeholders renderQuerySelect   :: forall a r m-   . ( SqlSelect a r+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , SqlSelect a r      )   => SqlQuery a   -- ^ SQL query to render@@ -130,9 +130,9 @@ --   that would be supplied to the database for @?@ placeholders renderQueryToText   :: forall a r m-   . ( SqlSelect a r+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , SqlSelect a r      )   => Mode   -- ^ Whether to render as an SELECT, DELETE, etc.@@ -149,9 +149,9 @@ --   that would be supplied to the database for @?@ placeholders renderQueryUpdate   :: forall a r m-   . ( SqlSelect a r+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , SqlSelect a r      )   => SqlQuery a   -- ^ SQL query to render@@ -161,7 +161,7 @@ -- | Execute an Esqueleto SELECT query select   :: forall a r m-   . (SqlSelect a r, MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m, SqlSelect a r)   => SqlQuery a   -> m [r]   -- ^ A list of rows@@ -170,7 +170,7 @@ -- | Execute an Esqueleto SELECT query, getting only the first row selectOne   :: forall a r m-   . (SqlSelect a r, MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m, SqlSelect a r)   => SqlQuery a   -> m (Maybe r)   -- ^ The first row, or 'Nothing' if no rows are selected@@ -179,10 +179,10 @@ -- | Execute an Esqueleto UPDATE query update   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => (SqlExpr (Entity a) -> SqlQuery ())   -> m ()@@ -191,10 +191,10 @@ -- | Execute an Esqueleto UPDATE query, returning the count updateCount   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => (SqlExpr (Entity a) -> SqlQuery ())   -> m Int64
library/Database/Persist/Sql/Lifted/Expression/ArrayAggregate/PostgreSQL.hs view
@@ -56,7 +56,8 @@ -- Also replaces the 'Maybe' result with an empty list, because really that's -- what you always want. arrayAggById-  :: (PersistEntity val, PersistField [typ], PersistField typ)+  :: forall val typ+   . (PersistEntity val, PersistField [typ], PersistField typ)   => SqlExpr (Entity val)   -> EntityField val typ   -> SqlExpr (Value [typ])@@ -66,7 +67,8 @@ -- -- If you're using '(?.)' instead of '(^.)', use this instead of 'arrayAggById'. arrayAggByIdMaybe-  :: (PersistEntity val, PersistField typ)+  :: forall val typ+   . (PersistEntity val, PersistField typ)   => SqlExpr (Maybe (Entity val))   -> EntityField val typ   -> SqlExpr (Value [typ])@@ -77,14 +79,16 @@ -- -- If you're using '(?.)' instead of '(^.)', use this instead of 'arrayAggBy'. arrayAggByMaybe-  :: (PersistField a, PersistField b)+  :: forall a b+   . (PersistField a, PersistField b)   => SqlExpr (Value (Maybe a))   -> SqlExpr (Value b)   -> SqlExpr (Value [a]) arrayAggByMaybe a = arrayRemoveNull . arrayAggBy a  arrayAggBy-  :: (PersistField [a], PersistField a, PersistField b)+  :: forall a b+   . (PersistField [a], PersistField a, PersistField b)   => SqlExpr (Value a)   -> SqlExpr (Value b)   -> SqlExpr (Value [a])
library/Database/Persist/Sql/Lifted/MonadSqlBackend.hs view
@@ -21,5 +21,6 @@   getSqlBackendM = asks getSqlBackend  -- | Generalize from 'SqlPersistT' to 'MonadSqlBackend'-liftSql :: (MonadSqlBackend m, HasCallStack) => ReaderT SqlBackend m a -> m a+liftSql+  :: forall m a. (HasCallStack, MonadSqlBackend m) => ReaderT SqlBackend m a -> m a liftSql (ReaderT f) = checkpointCallStack $ getSqlBackendM >>= f
library/Database/Persist/Sql/Lifted/MonadSqlTx.hs view
@@ -12,4 +12,4 @@ --   provide one, e.g. from a connection pool. class (MonadSqlBackend db, MonadUnliftIO m) => MonadSqlTx db m | m -> db where   -- | Runs the action in a SQL transaction-  runSqlTx :: HasCallStack => db a -> m a+  runSqlTx :: forall a. HasCallStack => db a -> m a
library/Database/Persist/Sql/Lifted/Persistent.hs view
@@ -88,10 +88,10 @@ --   and existing entities in the database checkUnique   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => a   -> m (Maybe (Unique a))@@ -104,10 +104,10 @@ -- This is useful for updating because it ignores conflicts when the particular entity already exists. checkUniqueUpdateable   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Entity a   -> m (Maybe (Unique a))@@ -118,10 +118,10 @@ -- | The total number of records fulfilling the given criteria count   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -133,10 +133,10 @@ -- Does nothing if record does not exist. delete   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> m ()@@ -147,10 +147,10 @@ -- Does nothing if no record matches. deleteBy   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Unique a   -> m ()@@ -159,10 +159,10 @@ -- | Delete all records matching the given criteria deleteWhere   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -172,10 +172,10 @@ -- | Delete all records matching the given criteria deleteWhereCount   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -186,10 +186,10 @@ -- | Check if there is at least one record fulfilling the given criteria exists   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -199,10 +199,10 @@ -- | Check if a record with this unique key exists existsBy   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Unique a   -> m Bool@@ -211,10 +211,10 @@ -- | Get a record by identifier, if available get   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> m (Maybe a)@@ -223,10 +223,10 @@ -- | Get a record by unique key, if available, returning both the identifier and the record getBy   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Unique a   -> m (Maybe (Entity a))@@ -237,10 +237,10 @@ -- This function makes the most sense on entities with a single 'Unique' constructor. getByValue   :: forall a m-   . ( PersistEntityBackend a ~ SqlBackend-     , AtLeastOneUniqueKey a-     , MonadSqlBackend m+   . ( AtLeastOneUniqueKey a      , HasCallStack+     , MonadSqlBackend m+     , PersistEntityBackend a ~ SqlBackend      )   => a   -> m (Maybe (Entity a))@@ -250,10 +250,10 @@ -- | Get a record by identifier, if available getEntity   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> m (Maybe (Entity a))@@ -262,10 +262,10 @@ -- | Get the SQL string for the field that an 'EntityField' represents getFieldName   :: forall a t m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => EntityField a t   -> m Text@@ -276,10 +276,10 @@ -- Unsafe unless your database is enforcing that the foreign key is valid. getJust   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> m a@@ -290,10 +290,10 @@ -- Unsafe unless your database is enforcing that the foreign key is valid. getJustEntity   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> m (Entity a)@@ -302,10 +302,10 @@ -- | Get many records by their respective identifiers, if available getMany   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Key a]   -> m (Map (Key a) a)@@ -313,17 +313,17 @@  -- | Get the SQL string for the table that a 'PersistEntity' represents getTableName-  :: forall a m. (PersistEntity a, MonadSqlBackend m, HasCallStack) => a -> m Text+  :: forall a m. (HasCallStack, MonadSqlBackend m, PersistEntity a) => a -> m Text getTableName x = liftSql $ P.getTableName x  -- | Create a new record in the database insert   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m (Key a)@@ -333,11 +333,11 @@ -- | Create a new record in the database insert_   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m ()@@ -346,11 +346,11 @@ -- | Insert a value, checking for conflicts with any unique constraints insertBy   :: forall a m-   . ( PersistEntityBackend a ~ SqlBackend-     , AtLeastOneUniqueKey a-     , SafeToInsert a-     , MonadSqlBackend m+   . ( AtLeastOneUniqueKey a      , HasCallStack+     , MonadSqlBackend m+     , PersistEntityBackend a ~ SqlBackend+     , SafeToInsert a      )   => a   -> m (Either (Entity a) (Key a))@@ -361,11 +361,11 @@ -- | Create a new record in the database, returning an auto-increment ID and the inserted record insertEntity   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m (Entity a)@@ -374,10 +374,10 @@ -- | Create multiple records in the database, with specified keys insertEntityMany   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Entity a]   -> m ()@@ -386,10 +386,10 @@ -- | Create a new record in the database using the given key insertKey   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> a@@ -399,11 +399,11 @@ -- | Create multiple records in the database and return their 'Key's insertMany   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => [a]   -> m [Key a]@@ -412,11 +412,11 @@ -- | Create multiple records in the database insertMany_   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => [a]   -> m ()@@ -425,11 +425,11 @@ -- | Create a new record in the database insertRecord   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m a@@ -439,11 +439,11 @@ -- | Create a new record in the database insertUnique   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m (Maybe (Key a))@@ -454,11 +454,11 @@ -- | Create a new record in the database insertUnique_   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m (Maybe ())@@ -469,11 +469,11 @@ -- | Create a new record in the database insertUniqueEntity   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => a   -> m (Maybe (Entity a))@@ -484,10 +484,10 @@ -- | Return the single unique key for a record onlyUnique   :: forall a m-   . ( PersistEntityBackend a ~ SqlBackend-     , OnlyOneUniqueKey a+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , OnlyOneUniqueKey a+     , PersistEntityBackend a ~ SqlBackend      )   => a   -> m (Unique a)@@ -499,11 +499,11 @@ -- * Replace existing records (matching any unique constraint). putMany   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => [a]   -- ^ A list of the records you want to insert or replace.@@ -513,7 +513,7 @@ -- | Execute a raw SQL statement rawExecute   :: forall m-   . (MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m)   => Text   -- ^ SQL statement, possibly with placeholders   -> [PersistValue]@@ -524,7 +524,7 @@ -- | Execute a raw SQL statement rawExecuteCount   :: forall m-   . (MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m)   => Text   -- ^ SQL statement, possibly with placeholders   -> [PersistValue]@@ -535,7 +535,7 @@  rawSql   :: forall a m-   . (RawSql a, MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m, RawSql a)   => Text   -- ^ SQL statement, possibly with placeholders   -> [PersistValue]@@ -548,10 +548,10 @@ -- The result is undefined if such record does not exist. replace   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> a@@ -563,11 +563,11 @@ -- First query the unique fields to make sure the replacement maintains uniqueness constraints. replaceUnique   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend-     , Eq (Unique a)-     , MonadSqlBackend m+   . ( Eq (Unique a)      , HasCallStack+     , MonadSqlBackend m+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> a@@ -581,10 +581,10 @@ -- If a record with the given key does not exist then a new record will be inserted. repsert   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> a@@ -596,10 +596,10 @@ -- For each item, if a record with the given key does not exist then a new record will be inserted. repsertMany   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [(Key a, a)]   -> m ()@@ -608,10 +608,10 @@ -- | Get just the first record for the criteria selectFirst   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -622,10 +622,10 @@ -- | Get the 'Key's of all records matching the given criteria selectKeysList   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -635,10 +635,10 @@  selectList   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -648,26 +648,26 @@ selectList fs os = liftSql $ P.selectList fs os  -- | Commit the current transaction and begin a new one-transactionSave :: forall m. (MonadSqlBackend m, HasCallStack) => m ()+transactionSave :: forall m. (HasCallStack, MonadSqlBackend m) => m () transactionSave = liftSql P.transactionSave  -- | Commit the current transaction and begin a new one transactionSaveWithIsolation   :: forall m-   . (MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m)   => IsolationLevel   -- ^ Isolation level   -> m () transactionSaveWithIsolation il = liftSql $ transactionSaveWithIsolation il  -- | Roll back the current transaction and begin a new one-transactionUndo :: forall m. (MonadSqlBackend m, HasCallStack) => m ()+transactionUndo :: forall m. (HasCallStack, MonadSqlBackend m) => m () transactionUndo = liftSql transactionUndo  -- | Roll back the current transaction and begin a new one transactionUndoWithIsolation   :: forall m-   . (MonadSqlBackend m, HasCallStack)+   . (HasCallStack, MonadSqlBackend m)   => IsolationLevel   -- ^ Isolation level   -> m ()@@ -676,10 +676,10 @@ -- | Update individual fields on a specific record update   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> [Update a]@@ -691,10 +691,10 @@ -- This function will throw an exception if the given key is not found in the database. updateGet   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => Key a   -> [Update a]@@ -704,10 +704,10 @@ -- | Update individual fields on any record matching the given criteria updateWhere   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -718,10 +718,10 @@ -- | Update individual fields on any record matching the given criteria updateWhereCount   :: forall a m-   . ( PersistEntity a-     , PersistEntityBackend a ~ SqlBackend+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , PersistEntity a+     , PersistEntityBackend a ~ SqlBackend      )   => [Filter a]   -- ^ If you provide multiple values in the list, the conditions are ANDed together.@@ -737,11 +737,11 @@ --   existing record with the parameters which is passed on as list to the function. upsert   :: forall a m-   . ( PersistEntityBackend a ~ SqlBackend-     , SafeToInsert a-     , OnlyOneUniqueKey a+   . ( HasCallStack      , MonadSqlBackend m-     , HasCallStack+     , OnlyOneUniqueKey a+     , PersistEntityBackend a ~ SqlBackend+     , SafeToInsert a      )   => a   -- ^ New record to insert@@ -757,11 +757,11 @@ -- * Update the existing record that matches the given uniqueness constraint. upsertBy   :: forall a m-   . ( PersistEntity a+   . ( HasCallStack+     , MonadSqlBackend m+     , PersistEntity a      , PersistEntityBackend a ~ SqlBackend      , SafeToInsert a-     , MonadSqlBackend m-     , HasCallStack      )   => Unique a   -- ^ Uniqueness constraint to find by
library/Database/Persist/Sql/Lifted/Savepoint.hs view
@@ -2,6 +2,8 @@   ( rollbackWhen   ) where +import Prelude ((-))+ import Control.Applicative (pure) import Control.Monad (replicateM) import Control.Monad.IO.Class (MonadIO)@@ -18,34 +20,34 @@ import Database.Persist.Sql.Lifted.Persistent (rawExecute) import GHC.Stack (HasCallStack) import System.Random (randomRIO)-import Prelude ((-))  --  | Create a new transaction @SAVEPOINT@, returning its name-newSavepoint :: (HasCallStack, MonadSqlBackend m) => m Text+newSavepoint :: forall m. (HasCallStack, MonadSqlBackend m) => m Text newSavepoint = do   r <- replicateM 8 randomCharacter   let savepoint = "savepoint_" <> T.pack r   rawExecute ("SAVEPOINT " <> savepoint) []   pure savepoint -randomCharacter :: MonadIO m => m Char+randomCharacter :: forall m. MonadIO m => m Char randomCharacter = (characterSet V.!) <$> randomRIO (0, V.length characterSet - 1)  characterSet :: Vector Char characterSet = V.fromList $ ['a' .. 'z'] <> ['1' .. '9']  --  | Release a @SAVEPOINT@-releaseSavepoint :: (HasCallStack, MonadSqlBackend m) => Text -> m ()+releaseSavepoint :: forall m. (HasCallStack, MonadSqlBackend m) => Text -> m () releaseSavepoint name = rawExecute ("RELEASE SAVEPOINT " <> name) []  --  | Rollback to a @SAVEPOINT@ rollbackToSavepoint-  :: (HasCallStack, MonadSqlBackend m) => Text -> m ()+  :: forall m. (HasCallStack, MonadSqlBackend m) => Text -> m () rollbackToSavepoint name = rawExecute ("ROLLBACK TO SAVEPOINT " <> name) []  -- | Runs a SQL action with SAVEPOINT, rolling back when specified rollbackWhen-  :: (HasCallStack, MonadSqlBackend m)+  :: forall m a+   . (HasCallStack, MonadSqlBackend m)   => (a -> Bool)   -- ^ When to ROLLBACK based on the result of the action   -> m a
package.yaml view
@@ -1,5 +1,5 @@ name: persistent-sql-lifted-version: 0.4.2.0+version: 0.4.3.0  maintainer: Freckle Education category: Database
persistent-sql-lifted.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.18 name:               persistent-sql-lifted-version:            0.4.2.0+version:            0.4.3.0 license:            MIT license-file:       LICENSE maintainer:         Freckle Education