persistent-2.9.0: Type-safe, multi-backend data serialization.

Safe Haskell | None
Language | Haskell98

Database.Persist.Sql

Contents

- Internal

Synopsis

- newtype Single a = Single {
  - unSingle :: a
  }
- type ConnectionPool = Pool SqlBackend
- type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT SqlBackend IO)) ()
- type CautiousMigration = [(Bool, Sql)]
- type Sql = Text
- type SqlPersistM = SqlPersistT (NoLoggingT (ResourceT IO))
- type SqlPersist = SqlPersistT
- type SqlPersistT = ReaderT SqlBackend
- data PersistentSqlException
  - = StatementAlreadyFinalized Text
  - | Couldn'tGetSQLConnection
- data Column = Column {
  - cName :: !DBName
  - cNull :: !Bool
  - cSqlType :: !SqlType
  - cDefault :: !(Maybe Text)
  - cDefaultConstraintName :: !(Maybe DBName)
  - cMaxLen :: !(Maybe Integer)
  - cReference :: !(Maybe (DBName, DBName))
  }
- type Connection = SqlBackend
- data SqlBackend = SqlBackend {
  - connPrepare :: Text -> IO Statement
  - connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult
  - connInsertManySql :: Maybe (EntityDef -> [[PersistValue]] -> InsertSqlResult)
  - connUpsertSql :: Maybe (EntityDef -> Text -> Text)
  - connPutManySql :: Maybe (EntityDef -> Int -> Text)
  - connStmtMap :: IORef (Map Text Statement)
  - connClose :: IO ()
  - connMigrateSql :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [(Bool, Text)])
  - connBegin :: (Text -> IO Statement) -> Maybe IsolationLevel -> IO ()
  - connCommit :: (Text -> IO Statement) -> IO ()
  - connRollback :: (Text -> IO Statement) -> IO ()
  - connEscapeName :: DBName -> Text
  - connNoLimit :: Text
  - connRDBMS :: Text
  - connLimitOffset :: (Int, Int) -> Bool -> Text -> Text
  - connLogFunc :: LogFunc
  - connMaxParams :: Maybe Int
  - connRepsertManySql :: Maybe (EntityDef -> Int -> Text)
  }
- data SqlReadBackend
- data SqlWriteBackend
- data Statement = Statement {
  - stmtFinalize :: IO ()
  - stmtReset :: IO ()
  - stmtExecute :: [PersistValue] -> IO Int64
  - stmtQuery :: forall m. MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())
  }
- type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- data InsertSqlResult
  - = ISRSingle Text
  - | ISRInsertGet Text Text
  - | ISRManyKeys Text [PersistValue]
- readToUnknown :: Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a
- readToWrite :: Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a
- writeToUnknown :: Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a
- type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend)
- type SqlBackendCanWrite backend = (SqlBackendCanRead backend, PersistQueryWrite backend, PersistStoreWrite backend, PersistUniqueWrite backend)
- type SqlReadT m a = forall backend. SqlBackendCanRead backend => ReaderT backend m a
- type SqlWriteT m a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a
- type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend)
- class RawSql a where
- class PersistField a => PersistFieldSql a where
- runSqlPool :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> Pool backend -> m a
- runSqlPoolWithIsolation :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> Pool backend -> IsolationLevel -> m a
- runSqlConn :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> backend -> m a
- runSqlConnWithIsolation :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> backend -> IsolationLevel -> m a
- runSqlPersistM :: IsSqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> backend -> IO a
- runSqlPersistMPool :: IsSqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> IO a
- liftSqlPersistMPool :: (MonadIO m, IsSqlBackend backend) => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> m a
- withSqlPool :: (MonadLogger m, MonadUnliftIO m, IsSqlBackend backend) => (LogFunc -> IO backend) -> Int -> (Pool backend -> m a) -> m a
- createSqlPool :: (MonadLogger m, MonadUnliftIO m, IsSqlBackend backend) => (LogFunc -> IO backend) -> Int -> m (Pool backend)
- askLogFunc :: forall m. (MonadUnliftIO m, MonadLogger m) => m LogFunc
- withSqlConn :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => (LogFunc -> IO backend) -> (backend -> m a) -> m a
- close' :: IsSqlBackend backend => backend -> IO ()
- parseMigration :: MonadIO m => Migration -> ReaderT SqlBackend m (Either [Text] CautiousMigration)
- parseMigration' :: MonadIO m => Migration -> ReaderT SqlBackend m CautiousMigration
- printMigration :: MonadIO m => Migration -> ReaderT SqlBackend m ()
- showMigration :: MonadIO m => Migration -> ReaderT SqlBackend m [Text]
- getMigration :: MonadIO m => Migration -> ReaderT SqlBackend m [Sql]
- runMigration :: MonadIO m => Migration -> ReaderT SqlBackend m ()
- runMigrationSilent :: (MonadUnliftIO m, MonadIO m) => Migration -> ReaderT SqlBackend m [Text]
- runMigrationUnsafe :: MonadIO m => Migration -> ReaderT SqlBackend m ()
- migrate :: [EntityDef] -> EntityDef -> Migration
- module Database.Persist
- withRawQuery :: MonadIO m => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> ReaderT SqlBackend m a
- data family BackendKey backend
- toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record
- fromSqlKey :: ToBackendKey SqlBackend record => Key record -> Int64
- getFieldName :: forall record typ m backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, IsSqlBackend backend, Monad m) => EntityField record typ -> ReaderT backend m Text
- getTableName :: forall record m backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, IsSqlBackend backend, Monad m) => record -> ReaderT backend m Text
- tableDBName :: PersistEntity record => record -> DBName
- fieldDBName :: forall record typ. PersistEntity record => EntityField record typ -> DBName
- rawQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend) => Text -> [PersistValue] -> ConduitM () [PersistValue] m ()
- rawQueryRes :: (MonadIO m1, MonadIO m2, IsSqlBackend env) => Text -> [PersistValue] -> ReaderT env m1 (Acquire (ConduitM () [PersistValue] m2 ()))
- rawExecute :: (MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m ()
- rawExecuteCount :: (MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m Int64
- rawSql :: (RawSql a, MonadIO m) => Text -> [PersistValue] -> ReaderT SqlBackend m [a]
- deleteWhereCount :: (PersistEntity val, MonadIO m, PersistEntityBackend val ~ SqlBackend, IsSqlBackend backend) => [Filter val] -> ReaderT backend m Int64
- updateWhereCount :: (PersistEntity val, MonadIO m, SqlBackend ~ PersistEntityBackend val, IsSqlBackend backend) => [Filter val] -> [Update val] -> ReaderT backend m Int64
- transactionSave :: MonadIO m => ReaderT SqlBackend m ()
- transactionSaveWithIsolation :: MonadIO m => IsolationLevel -> ReaderT SqlBackend m ()
- transactionUndo :: MonadIO m => ReaderT SqlBackend m ()
- transactionUndoWithIsolation :: MonadIO m => IsolationLevel -> ReaderT SqlBackend m ()
- data IsolationLevel
  - = ReadUncommitted
  - | ReadCommitted
  - | RepeatableRead
  - | Serializable
- getStmtConn :: SqlBackend -> Text -> IO Statement
- mkColumns :: [EntityDef] -> EntityDef -> ([Column], [UniqueDef], [ForeignDef])
- defaultAttribute :: [Attr] -> Maybe Text
- decorateSQLWithLimitOffset :: Text -> (Int, Int) -> Bool -> Text -> Text

# Documentation

newtype Single a #

A single column (see `rawSql`). Any `PersistField` may be used here, including `PersistValue` (which does not do any processing).

Constructors

Single |
Fields unSingle :: a

Instances

Eq a => Eq (Single a) # |
Instance details Defined in Database.Persist.Sql.Types Methods (==) :: Single a -> Single a -> Bool # (/=) :: Single a -> Single a -> Bool #
Ord a => Ord (Single a) # |
Instance details Defined in Database.Persist.Sql.Types Methods compare :: Single a -> Single a -> Ordering # (<) :: Single a -> Single a -> Bool # (<=) :: Single a -> Single a -> Bool # (>) :: Single a -> Single a -> Bool # (>=) :: Single a -> Single a -> Bool # max :: Single a -> Single a -> Single a # min :: Single a -> Single a -> Single a #
Read a => Read (Single a) # |
Instance details Defined in Database.Persist.Sql.Types Methods readsPrec :: Int -> ReadS (Single a) # readList :: ReadS [Single a] # readPrec :: ReadPrec (Single a) # readListPrec :: ReadPrec [Single a] #
Show a => Show (Single a) # |
Instance details Defined in Database.Persist.Sql.Types Methods showsPrec :: Int -> Single a -> ShowS # show :: Single a -> String # showList :: [Single a] -> ShowS #
PersistField a => RawSql (Single a) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> Single a -> (Int, [Text]) # rawSqlColCountReason :: Single a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Single a) #

type ConnectionPool = Pool SqlBackend #

type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT SqlBackend IO)) () #

type CautiousMigration = [(Bool, Sql)] #

type Sql = Text #

type SqlPersistM = SqlPersistT (NoLoggingT (ResourceT IO)) #

type SqlPersist = SqlPersistT #

Deprecated: Please use SqlPersistT instead

type SqlPersistT = ReaderT SqlBackend #

data PersistentSqlException #

Constructors

StatementAlreadyFinalized Text |
Couldn'tGetSQLConnection |

Instances

Show PersistentSqlException # |
Instance details Defined in Database.Persist.Sql.Types Methods showsPrec :: Int -> PersistentSqlException -> ShowS # show :: PersistentSqlException -> String # showList :: [PersistentSqlException] -> ShowS #
Exception PersistentSqlException # |
Instance details Defined in Database.Persist.Sql.Types Methods toException :: PersistentSqlException -> SomeException # fromException :: SomeException -> Maybe PersistentSqlException # displayException :: PersistentSqlException -> String #

data Column #

Constructors

Column |
Fields cName :: !DBName cNull :: !Bool cSqlType :: !SqlType cDefault :: !(Maybe Text) cDefaultConstraintName :: !(Maybe DBName) cMaxLen :: !(Maybe Integer) cReference :: !(Maybe (DBName, DBName))

Instances

Eq Column # |
Instance details Defined in Database.Persist.Sql.Types Methods (==) :: Column -> Column -> Bool # (/=) :: Column -> Column -> Bool #
Ord Column # |
Instance details Defined in Database.Persist.Sql.Types Methods compare :: Column -> Column -> Ordering # (<) :: Column -> Column -> Bool # (<=) :: Column -> Column -> Bool # (>) :: Column -> Column -> Bool # (>=) :: Column -> Column -> Bool # max :: Column -> Column -> Column # min :: Column -> Column -> Column #
Show Column # |
Instance details Defined in Database.Persist.Sql.Types Methods showsPrec :: Int -> Column -> ShowS # show :: Column -> String # showList :: [Column] -> ShowS #

type Connection = SqlBackend #

Deprecated: Please use SqlBackend instead

Deprecated synonym for `SqlBackend`.

data SqlBackend #

Constructors

SqlBackend |
Fields connPrepare :: Text -> IO Statement connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult table name, column names, id name, either 1 or 2 statements to run connInsertManySql :: Maybe (EntityDef -> [[PersistValue]] -> InsertSqlResult) SQL for inserting many rows and returning their primary keys, for backends that support this functioanlity. If `Nothing`, rows will be inserted one-at-a-time using `connInsertSql`. connUpsertSql :: Maybe (EntityDef -> Text -> Text) Some databases support performing UPSERT _and_ RETURN entity in a single call. This field when set will be used to generate the UPSERT+RETURN sql given * an entity definition * updates to be run on unique key(s) collision When left as `Nothing`, we find the unique key from entity def before * trying to fetch an entity by said key * perform an update when result found, else issue an insert * return new entity from db Since: persistent-2.6 connPutManySql :: Maybe (EntityDef -> Int -> Text) Some databases support performing bulk UPSERT, specifically "insert or replace many records" in a single call. This field when set, given * an entity definition * number of records to be inserted should produce a PUT MANY sql with placeholders for records When left as `Nothing`, we default to using `defaultPutMany`. Since: persistent-2.8.1 connStmtMap :: IORef (Map Text Statement) connClose :: IO () connMigrateSql :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [(Bool, Text)]) connBegin :: (Text -> IO Statement) -> Maybe IsolationLevel -> IO () connCommit :: (Text -> IO Statement) -> IO () connRollback :: (Text -> IO Statement) -> IO () connEscapeName :: DBName -> Text connNoLimit :: Text connRDBMS :: Text connLimitOffset :: (Int, Int) -> Bool -> Text -> Text connLogFunc :: LogFunc connMaxParams :: Maybe Int Some databases (probably only Sqlite) have a limit on how many question-mark parameters may be used in a statement Since: persistent-2.6.1 connRepsertManySql :: Maybe (EntityDef -> Int -> Text) Some databases support performing bulk an atomic+bulk INSERT where constraint conflicting entities can replace existing entities. This field when set, given * an entity definition * number of records to be inserted should produce a INSERT sql with placeholders for primary+record fields When left as `Nothing`, we default to using `defaultRepsertMany`. Since: persistent-2.9.0

Instances

PersistStoreWrite SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods insert :: (MonadIO m, PersistRecordBackend record SqlBackend) => record -> ReaderT SqlBackend m (Key record) # insert_ :: (MonadIO m, PersistRecordBackend record SqlBackend) => record -> ReaderT SqlBackend m () # insertMany :: (MonadIO m, PersistRecordBackend record SqlBackend) => [record] -> ReaderT SqlBackend m [Key record] # insertMany_ :: (MonadIO m, PersistRecordBackend record SqlBackend) => [record] -> ReaderT SqlBackend m () # insertEntityMany :: (MonadIO m, PersistRecordBackend record SqlBackend) => [Entity record] -> ReaderT SqlBackend m () # insertKey :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> record -> ReaderT SqlBackend m () # repsert :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> record -> ReaderT SqlBackend m () # repsertMany :: (MonadIO m, PersistRecordBackend record SqlBackend) => [(Key record, record)] -> ReaderT SqlBackend m () # replace :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> record -> ReaderT SqlBackend m () # delete :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> ReaderT SqlBackend m () # update :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> [Update record] -> ReaderT SqlBackend m () # updateGet :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> [Update record] -> ReaderT SqlBackend m record #
PersistStoreRead SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods get :: (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> ReaderT SqlBackend m (Maybe record) # getMany :: (MonadIO m, PersistRecordBackend record SqlBackend) => [Key record] -> ReaderT SqlBackend m (Map (Key record) record) #
PersistCore SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Associated Types data BackendKey SqlBackend :: * #
IsPersistBackend SqlBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlBackend -> SqlBackend #
HasPersistBackend SqlBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlBackend :: * # Methods persistBackend :: SqlBackend -> BaseBackend SqlBackend #
PersistUniqueWrite SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistUnique Methods deleteBy :: (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m () # insertUnique :: (MonadIO m, PersistRecordBackend record SqlBackend) => record -> ReaderT SqlBackend m (Maybe (Key record)) # upsert :: (MonadIO m, PersistRecordBackend record SqlBackend) => record -> [Update record] -> ReaderT SqlBackend m (Entity record) # upsertBy :: (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> record -> [Update record] -> ReaderT SqlBackend m (Entity record) # putMany :: (MonadIO m, PersistRecordBackend record SqlBackend) => [record] -> ReaderT SqlBackend m () #
PersistUniqueRead SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistUnique Methods getBy :: (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m (Maybe (Entity record)) #
PersistQueryWrite SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistQuery Methods updateWhere :: (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> [Update record] -> ReaderT SqlBackend m () # deleteWhere :: (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> ReaderT SqlBackend m () #
PersistQueryRead SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistQuery Methods selectSourceRes :: (PersistRecordBackend record SqlBackend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT SqlBackend m1 (Acquire (ConduitM () (Entity record) m2 ())) # selectFirst :: (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlBackend m (Maybe (Entity record)) # selectKeysRes :: (MonadIO m1, MonadIO m2, PersistRecordBackend record SqlBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlBackend m1 (Acquire (ConduitM () (Key record) m2 ())) # count :: (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> ReaderT SqlBackend m Int #
BackendCompatible SqlBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlWriteBackend -> SqlBackend #
BackendCompatible SqlBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlReadBackend -> SqlBackend #
BackendCompatible SqlBackend SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlBackend -> SqlBackend #
Bounded (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlBackend # maxBound :: BackendKey SqlBackend #
Enum (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods succ :: BackendKey SqlBackend -> BackendKey SqlBackend # pred :: BackendKey SqlBackend -> BackendKey SqlBackend # toEnum :: Int -> BackendKey SqlBackend # fromEnum :: BackendKey SqlBackend -> Int # enumFrom :: BackendKey SqlBackend -> [BackendKey SqlBackend] # enumFromThen :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] # enumFromTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] # enumFromThenTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] #
Eq (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (/=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #
Integral (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods quot :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # rem :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # div :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # mod :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # quotRem :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) # divMod :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) # toInteger :: BackendKey SqlBackend -> Integer #
Num (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (+) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # (-) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # (*) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # negate :: BackendKey SqlBackend -> BackendKey SqlBackend # abs :: BackendKey SqlBackend -> BackendKey SqlBackend # signum :: BackendKey SqlBackend -> BackendKey SqlBackend # fromInteger :: Integer -> BackendKey SqlBackend #
Ord (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods compare :: BackendKey SqlBackend -> BackendKey SqlBackend -> Ordering # (<) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (<=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (>) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (>=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # max :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # min :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #
Read (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlBackend) # readList :: ReadS [BackendKey SqlBackend] # readPrec :: ReadPrec (BackendKey SqlBackend) # readListPrec :: ReadPrec [BackendKey SqlBackend] #
Real (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlBackend -> Rational #
Show (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlBackend -> ShowS # show :: BackendKey SqlBackend -> String # showList :: [BackendKey SqlBackend] -> ShowS #
ToJSON (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlBackend -> Value # toEncoding :: BackendKey SqlBackend -> Encoding # toJSONList :: [BackendKey SqlBackend] -> Value # toEncodingList :: [BackendKey SqlBackend] -> Encoding #
FromJSON (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlBackend) # parseJSONList :: Value -> Parser [BackendKey SqlBackend] #
ToHttpApiData (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlBackend -> Text # toEncodedUrlPiece :: BackendKey SqlBackend -> Builder # toHeader :: BackendKey SqlBackend -> ByteString # toQueryParam :: BackendKey SqlBackend -> Text #
FromHttpApiData (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlBackend) #
PathPiece (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlBackend) # toPathPiece :: BackendKey SqlBackend -> Text #
PersistField (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlBackend) #
PersistFieldSql (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlBackend) -> SqlType #
data BackendKey SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore data BackendKey SqlBackend = SqlBackendKey { unSqlBackendKey :: Int64 }
type BaseBackend SqlBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlBackend = SqlBackend

data SqlReadBackend #

An SQL backend which can only handle read queries

Instances

PersistStoreRead SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods get :: (MonadIO m, PersistRecordBackend record SqlReadBackend) => Key record -> ReaderT SqlReadBackend m (Maybe record) # getMany :: (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Key record] -> ReaderT SqlReadBackend m (Map (Key record) record) #
PersistCore SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Associated Types data BackendKey SqlReadBackend :: * #
IsPersistBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend #
HasPersistBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlReadBackend :: * # Methods persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend #
PersistUniqueRead SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistUnique Methods getBy :: (MonadIO m, PersistRecordBackend record SqlReadBackend) => Unique record -> ReaderT SqlReadBackend m (Maybe (Entity record)) #
PersistQueryRead SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistQuery Methods selectSourceRes :: (PersistRecordBackend record SqlReadBackend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT SqlReadBackend m1 (Acquire (ConduitM () (Entity record) m2 ())) # selectFirst :: (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlReadBackend m (Maybe (Entity record)) # selectKeysRes :: (MonadIO m1, MonadIO m2, PersistRecordBackend record SqlReadBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlReadBackend m1 (Acquire (ConduitM () (Key record) m2 ())) # count :: (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Filter record] -> ReaderT SqlReadBackend m Int #
BackendCompatible SqlBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlReadBackend -> SqlBackend #
Bounded (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlReadBackend # maxBound :: BackendKey SqlReadBackend #
Enum (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods succ :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # pred :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # toEnum :: Int -> BackendKey SqlReadBackend # fromEnum :: BackendKey SqlReadBackend -> Int # enumFrom :: BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] # enumFromThen :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] # enumFromTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] # enumFromThenTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] #
Eq (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (/=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #
Integral (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods quot :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # rem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # div :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # mod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # quotRem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) # divMod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) # toInteger :: BackendKey SqlReadBackend -> Integer #
Num (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (+) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # (-) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # (*) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # negate :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # abs :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # signum :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # fromInteger :: Integer -> BackendKey SqlReadBackend #
Ord (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods compare :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Ordering # (<) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (<=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (>) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (>=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # max :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # min :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #
Read (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlReadBackend) # readList :: ReadS [BackendKey SqlReadBackend] # readPrec :: ReadPrec (BackendKey SqlReadBackend) # readListPrec :: ReadPrec [BackendKey SqlReadBackend] #
Real (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlReadBackend -> Rational #
Show (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlReadBackend -> ShowS # show :: BackendKey SqlReadBackend -> String # showList :: [BackendKey SqlReadBackend] -> ShowS #
ToJSON (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlReadBackend -> Value # toEncoding :: BackendKey SqlReadBackend -> Encoding # toJSONList :: [BackendKey SqlReadBackend] -> Value # toEncodingList :: [BackendKey SqlReadBackend] -> Encoding #
FromJSON (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlReadBackend) # parseJSONList :: Value -> Parser [BackendKey SqlReadBackend] #
ToHttpApiData (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlReadBackend -> Text # toEncodedUrlPiece :: BackendKey SqlReadBackend -> Builder # toHeader :: BackendKey SqlReadBackend -> ByteString # toQueryParam :: BackendKey SqlReadBackend -> Text #
FromHttpApiData (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlReadBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlReadBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlReadBackend) #
PathPiece (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlReadBackend) # toPathPiece :: BackendKey SqlReadBackend -> Text #
PersistField (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlReadBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlReadBackend) #
PersistFieldSql (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlReadBackend) -> SqlType #
data BackendKey SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore data BackendKey SqlReadBackend = SqlReadBackendKey { unSqlReadBackendKey :: Int64 }
type BaseBackend SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend

data SqlWriteBackend #

An SQL backend which can handle read or write queries

Instances

PersistStoreWrite SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods insert :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => record -> ReaderT SqlWriteBackend m (Key record) # insert_ :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => record -> ReaderT SqlWriteBackend m () # insertMany :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [record] -> ReaderT SqlWriteBackend m [Key record] # insertMany_ :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [record] -> ReaderT SqlWriteBackend m () # insertEntityMany :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Entity record] -> ReaderT SqlWriteBackend m () # insertKey :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> record -> ReaderT SqlWriteBackend m () # repsert :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> record -> ReaderT SqlWriteBackend m () # repsertMany :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [(Key record, record)] -> ReaderT SqlWriteBackend m () # replace :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> record -> ReaderT SqlWriteBackend m () # delete :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> ReaderT SqlWriteBackend m () # update :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> [Update record] -> ReaderT SqlWriteBackend m () # updateGet :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> [Update record] -> ReaderT SqlWriteBackend m record #
PersistStoreRead SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods get :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> ReaderT SqlWriteBackend m (Maybe record) # getMany :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Key record] -> ReaderT SqlWriteBackend m (Map (Key record) record) #
PersistCore SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Associated Types data BackendKey SqlWriteBackend :: * #
IsPersistBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend #
HasPersistBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlWriteBackend :: * # Methods persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend #
PersistUniqueWrite SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistUnique Methods deleteBy :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Unique record -> ReaderT SqlWriteBackend m () # insertUnique :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => record -> ReaderT SqlWriteBackend m (Maybe (Key record)) # upsert :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => record -> [Update record] -> ReaderT SqlWriteBackend m (Entity record) # upsertBy :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Unique record -> record -> [Update record] -> ReaderT SqlWriteBackend m (Entity record) # putMany :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [record] -> ReaderT SqlWriteBackend m () #
PersistUniqueRead SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistUnique Methods getBy :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Unique record -> ReaderT SqlWriteBackend m (Maybe (Entity record)) #
PersistQueryWrite SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistQuery Methods updateWhere :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> [Update record] -> ReaderT SqlWriteBackend m () # deleteWhere :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> ReaderT SqlWriteBackend m () #
PersistQueryRead SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistQuery Methods selectSourceRes :: (PersistRecordBackend record SqlWriteBackend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT SqlWriteBackend m1 (Acquire (ConduitM () (Entity record) m2 ())) # selectFirst :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlWriteBackend m (Maybe (Entity record)) # selectKeysRes :: (MonadIO m1, MonadIO m2, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlWriteBackend m1 (Acquire (ConduitM () (Key record) m2 ())) # count :: (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> ReaderT SqlWriteBackend m Int #
BackendCompatible SqlBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlWriteBackend -> SqlBackend #
Bounded (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlWriteBackend # maxBound :: BackendKey SqlWriteBackend #
Enum (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods succ :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # pred :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # toEnum :: Int -> BackendKey SqlWriteBackend # fromEnum :: BackendKey SqlWriteBackend -> Int # enumFrom :: BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] # enumFromThen :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] # enumFromTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] # enumFromThenTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] #
Eq (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (/=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #
Integral (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods quot :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # rem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # div :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # mod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # quotRem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) # divMod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) # toInteger :: BackendKey SqlWriteBackend -> Integer #
Num (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (+) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # (-) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # (*) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # negate :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # abs :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # signum :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # fromInteger :: Integer -> BackendKey SqlWriteBackend #
Ord (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods compare :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Ordering # (<) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (<=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (>) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (>=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # max :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # min :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #
Read (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlWriteBackend) # readList :: ReadS [BackendKey SqlWriteBackend] # readPrec :: ReadPrec (BackendKey SqlWriteBackend) # readListPrec :: ReadPrec [BackendKey SqlWriteBackend] #
Real (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlWriteBackend -> Rational #
Show (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlWriteBackend -> ShowS # show :: BackendKey SqlWriteBackend -> String # showList :: [BackendKey SqlWriteBackend] -> ShowS #
ToJSON (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlWriteBackend -> Value # toEncoding :: BackendKey SqlWriteBackend -> Encoding # toJSONList :: [BackendKey SqlWriteBackend] -> Value # toEncodingList :: [BackendKey SqlWriteBackend] -> Encoding #
FromJSON (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlWriteBackend) # parseJSONList :: Value -> Parser [BackendKey SqlWriteBackend] #
ToHttpApiData (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlWriteBackend -> Text # toEncodedUrlPiece :: BackendKey SqlWriteBackend -> Builder # toHeader :: BackendKey SqlWriteBackend -> ByteString # toQueryParam :: BackendKey SqlWriteBackend -> Text #
FromHttpApiData (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlWriteBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlWriteBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlWriteBackend) #
PathPiece (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlWriteBackend) # toPathPiece :: BackendKey SqlWriteBackend -> Text #
PersistField (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlWriteBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlWriteBackend) #
PersistFieldSql (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlWriteBackend) -> SqlType #
data BackendKey SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore data BackendKey SqlWriteBackend = SqlWriteBackendKey { unSqlWriteBackendKey :: Int64 }
type BaseBackend SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend

data Statement #

Constructors

Statement |
Fields stmtFinalize :: IO () stmtReset :: IO () stmtExecute :: [PersistValue] -> IO Int64 stmtQuery :: forall m. MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())

type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO () #

data InsertSqlResult #

Constructors

ISRSingle Text |
ISRInsertGet Text Text |
ISRManyKeys Text [PersistValue] |

readToUnknown :: Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a #

Useful for running a read query against a backend with unknown capabilities.

readToWrite :: Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a #

Useful for running a read query against a backend with read and write capabilities.

writeToUnknown :: Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a #

Useful for running a write query against an untagged backend with unknown capabilities.

type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend) #

A constraint synonym which witnesses that a backend is SQL and can run read queries.

type SqlBackendCanWrite backend = (SqlBackendCanRead backend, PersistQueryWrite backend, PersistStoreWrite backend, PersistUniqueWrite backend) #

A constraint synonym which witnesses that a backend is SQL and can run read and write queries.

type SqlReadT m a = forall backend. SqlBackendCanRead backend => ReaderT backend m a #

Like `SqlPersistT` but compatible with any SQL backend which can handle read queries.

type SqlWriteT m a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a #

Like `SqlPersistT` but compatible with any SQL backend which can handle read and write queries.

type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend) #

A backend which is a wrapper around `SqlBackend`.

class RawSql a where #

Class for data types that may be retrived from a `rawSql` query.

Minimal complete definition

rawSqlCols, rawSqlColCountReason, rawSqlProcessRow

Methods

rawSqlCols :: (DBName -> Text) -> a -> (Int, [Text]) #

Number of columns that this data type needs and the list of substitutions for `SELECT` placeholders `??`.

rawSqlColCountReason :: a -> String #

A string telling the user why the column count is what it is.

rawSqlProcessRow :: [PersistValue] -> Either Text a #

Transform a row of the result into the data type.

Instances

RawSql a => RawSql (Maybe a) # | Since: persistent-1.0.1
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> Maybe a -> (Int, [Text]) # rawSqlColCountReason :: Maybe a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Maybe a) #
(PersistEntity record, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (Entity record) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> Entity record -> (Int, [Text]) # rawSqlColCountReason :: Entity record -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Entity record) #
(PersistEntity a, PersistEntityBackend a ~ backend, IsPersistBackend backend) => RawSql (Key a) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> Key a -> (Int, [Text]) # rawSqlColCountReason :: Key a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Key a) #
PersistField a => RawSql (Single a) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> Single a -> (Int, [Text]) # rawSqlColCountReason :: Single a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Single a) #
(RawSql a, RawSql b) => RawSql (a, b) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b) -> (Int, [Text]) # rawSqlColCountReason :: (a, b) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b) #
(RawSql a, RawSql b, RawSql c) => RawSql (a, b, c) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b, c) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c) #
(RawSql a, RawSql b, RawSql c, RawSql d) => RawSql (a, b, c, d) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b, c, d) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d) #
(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e) => RawSql (a, b, c, d, e) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b, c, d, e) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e) #
(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f) => RawSql (a, b, c, d, e, f) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b, c, d, e, f) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f) #
(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g) => RawSql (a, b, c, d, e, f, g) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b, c, d, e, f, g) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g) #
(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h) => RawSql (a, b, c, d, e, f, g, h) # |
Instance details Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (DBName -> Text) -> (a, b, c, d, e, f, g, h) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h) #

class PersistField a => PersistFieldSql a where #

Tells Persistent what database column type should be used to store a Haskell type.

#### Examples

Expand

##### Simple Boolean Alternative

    data Switch = On | Off
      deriving (Show, Eq)

    instance PersistField Switch where
      toPersistValue s = case s of
        On -> PersistBool True
        Off -> PersistBool False
      fromPersistValue (PersistBool b) = if b then Right On else Right Off
      fromPersistValue x = Left $ "File.hs: When trying to deserialize a Switch: expected PersistBool, received: " <> T.pack (show x)

    instance PersistFieldSql Switch where
      sqlType _ = SqlBool

##### Non-Standard Database Types

If your database supports non-standard types, such as Postgres' `uuid`, you can use `SqlOther` to use them:

    import qualified Data.UUID as UUID
    instance PersistField UUID where
      toPersistValue = PersistDbSpecific . toASCIIBytes
      fromPersistValue (PersistDbSpecific uuid) =
        case fromASCIIBytes uuid of
          Nothing -> Left $ "Model/CustomTypes.hs: Failed to deserialize a UUID; received: " <> T.pack (show uuid)
          Just uuid' -> Right uuid'
      fromPersistValue x = Left $ "File.hs: When trying to deserialize a UUID: expected PersistDbSpecific, received: "-- >  <> T.pack (show x)

    instance PersistFieldSql UUID where
      sqlType _ = SqlOther "uuid"

##### User Created Database Types

Similarly, some databases support creating custom types, e.g. Postgres' DOMAIN and ENUM features. You can use `SqlOther` to specify a custom type:

    CREATE DOMAIN ssn AS text
          CHECK ( value ~ '^[0-9]{9}$');

    instance PersistFieldSQL SSN where
      sqlType _ = SqlOther "ssn"

    CREATE TYPE rainbow_color AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet');

    instance PersistFieldSQL RainbowColor where
      sqlType _ = SqlOther "rainbow_color"

Minimal complete definition

sqlType

Methods

sqlType :: Proxy a -> SqlType #

Instances

PersistFieldSql Bool # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Bool -> SqlType #
PersistFieldSql Double # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Double -> SqlType #
PersistFieldSql Int # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Int -> SqlType #
PersistFieldSql Int8 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Int8 -> SqlType #
PersistFieldSql Int16 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Int16 -> SqlType #
PersistFieldSql Int32 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Int32 -> SqlType #
PersistFieldSql Int64 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Int64 -> SqlType #
PersistFieldSql Natural # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Natural -> SqlType #
PersistFieldSql Rational # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Rational -> SqlType #
PersistFieldSql Word # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Word -> SqlType #
PersistFieldSql Word8 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Word8 -> SqlType #
PersistFieldSql Word16 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Word16 -> SqlType #
PersistFieldSql Word32 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Word32 -> SqlType #
PersistFieldSql Word64 # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Word64 -> SqlType #
PersistFieldSql ByteString # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy ByteString -> SqlType #
PersistFieldSql Text # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Text -> SqlType #
PersistFieldSql UTCTime # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy UTCTime -> SqlType #
PersistFieldSql Text # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Text -> SqlType #
PersistFieldSql Html # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Html -> SqlType #
PersistFieldSql TimeOfDay # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy TimeOfDay -> SqlType #
PersistFieldSql Day # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Day -> SqlType #
PersistFieldSql PersistValue # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy PersistValue -> SqlType #
PersistFieldSql Checkmark # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy Checkmark -> SqlType #
PersistFieldSql [Char] # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy [Char] -> SqlType #
PersistFieldSql a => PersistFieldSql [a] # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy [a] -> SqlType #
HasResolution a => PersistFieldSql (Fixed a) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (Fixed a) -> SqlType #
PersistFieldSql v => PersistFieldSql (IntMap v) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (IntMap v) -> SqlType #
(Ord a, PersistFieldSql a) => PersistFieldSql (Set a) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (Set a) -> SqlType #
PersistFieldSql a => PersistFieldSql (Vector a) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (Vector a) -> SqlType #
(PersistField record, PersistEntity record) => PersistFieldSql (Entity record) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (Entity record) -> SqlType #
PersistFieldSql (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlWriteBackend) -> SqlType #
PersistFieldSql (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlReadBackend) -> SqlType #
PersistFieldSql (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlBackend) -> SqlType #
(PersistFieldSql a, PersistFieldSql b) => PersistFieldSql (a, b) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (a, b) -> SqlType #
PersistFieldSql v => PersistFieldSql (Map Text v) # |
Instance details Defined in Database.Persist.Sql.Class Methods sqlType :: Proxy (Map Text v) -> SqlType #

runSqlPool :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> Pool backend -> m a #

Get a connection from the pool, run the given action, and then return the connection to the pool.

Note: This function previously timed out after 2 seconds, but this behavior was buggy and caused more problems than it solved. Since version 2.1.2, it performs no timeout checks.

runSqlPoolWithIsolation :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> Pool backend -> IsolationLevel -> m a #

Like `runSqlPool`, but supports specifying an isolation level.

Since: persistent-2.9.0

runSqlConn :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> backend -> m a #

runSqlConnWithIsolation :: (MonadUnliftIO m, IsSqlBackend backend) => ReaderT backend m a -> backend -> IsolationLevel -> m a #

Like `runSqlConn`, but supports specifying an isolation level.

Since: persistent-2.9.0

runSqlPersistM :: IsSqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> backend -> IO a #

runSqlPersistMPool :: IsSqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> IO a #

liftSqlPersistMPool :: (MonadIO m, IsSqlBackend backend) => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> m a #

withSqlPool #

Arguments

:: (MonadLogger m, MonadUnliftIO m, IsSqlBackend backend) |
=> (LogFunc -> IO backend) | create a new connection
-> Int | connection count
-> (Pool backend -> m a) |
-> m a |

createSqlPool :: (MonadLogger m, MonadUnliftIO m, IsSqlBackend backend) => (LogFunc -> IO backend) -> Int -> m (Pool backend) #

askLogFunc :: forall m. (MonadUnliftIO m, MonadLogger m) => m LogFunc #

withSqlConn :: (MonadUnliftIO m, MonadLogger m, IsSqlBackend backend) => (LogFunc -> IO backend) -> (backend -> m a) -> m a #

close' :: IsSqlBackend backend => backend -> IO () #

parseMigration :: MonadIO m => Migration -> ReaderT SqlBackend m (Either [Text] CautiousMigration) #

Given a `Migration`, this parses it and returns either a list of errors associated with the migration or a list of migrations to do.

parseMigration' :: MonadIO m => Migration -> ReaderT SqlBackend m CautiousMigration #

Like `parseMigration`, but instead of returning the value in an `Either` value, it calls `error` on the error values.

printMigration :: MonadIO m => Migration -> ReaderT SqlBackend m () #

Prints a migration.

showMigration :: MonadIO m => Migration -> ReaderT SqlBackend m [Text] #

Convert a `Migration` to a list of `Text` values corresponding to their `Sql` statements.

getMigration :: MonadIO m => Migration -> ReaderT SqlBackend m [Sql] #

Return all of the `Sql` values associated with the given migration. Calls `error` if there's a parse error on any migration.

runMigration :: MonadIO m => Migration -> ReaderT SqlBackend m () #

Runs a migration. If the migration fails to parse or if any of the migrations are unsafe, then this calls `error` to halt the program.

runMigrationSilent :: (MonadUnliftIO m, MonadIO m) => Migration -> ReaderT SqlBackend m [Text] #

Same as `runMigration`, but returns a list of the SQL commands executed instead of printing them to stderr.

runMigrationUnsafe :: MonadIO m => Migration -> ReaderT SqlBackend m () #

Like `runMigration`, but this will perform the unsafe database migrations instead of erroring out.

migrate :: [EntityDef] -> EntityDef -> Migration #

Given a list of old entity definitions and a new `EntityDef` in `val`, this creates a `Migration` to update the old list of definitions with the new one.

module Database.Persist

withRawQuery :: MonadIO m => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> ReaderT SqlBackend m a #

data family BackendKey backend #

Instances

Bounded (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlWriteBackend # maxBound :: BackendKey SqlWriteBackend #
Bounded (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlReadBackend # maxBound :: BackendKey SqlReadBackend #
Bounded (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlBackend # maxBound :: BackendKey SqlBackend #
Enum (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods succ :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # pred :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # toEnum :: Int -> BackendKey SqlWriteBackend # fromEnum :: BackendKey SqlWriteBackend -> Int # enumFrom :: BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] # enumFromThen :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] # enumFromTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] # enumFromThenTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] #
Enum (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods succ :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # pred :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # toEnum :: Int -> BackendKey SqlReadBackend # fromEnum :: BackendKey SqlReadBackend -> Int # enumFrom :: BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] # enumFromThen :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] # enumFromTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] # enumFromThenTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] #
Enum (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods succ :: BackendKey SqlBackend -> BackendKey SqlBackend # pred :: BackendKey SqlBackend -> BackendKey SqlBackend # toEnum :: Int -> BackendKey SqlBackend # fromEnum :: BackendKey SqlBackend -> Int # enumFrom :: BackendKey SqlBackend -> [BackendKey SqlBackend] # enumFromThen :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] # enumFromTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] # enumFromThenTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] #
Eq (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (/=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool #
Eq (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (/=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool #
Eq (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (/=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool #
Integral (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods quot :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # rem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # div :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # mod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # quotRem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) # divMod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) # toInteger :: BackendKey SqlWriteBackend -> Integer #
Integral (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods quot :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # rem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # div :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # mod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # quotRem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) # divMod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) # toInteger :: BackendKey SqlReadBackend -> Integer #
Integral (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods quot :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # rem :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # div :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # mod :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # quotRem :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) # divMod :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) # toInteger :: BackendKey SqlBackend -> Integer #
Num (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (+) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # (-) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # (*) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # negate :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # abs :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # signum :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # fromInteger :: Integer -> BackendKey SqlWriteBackend #
Num (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (+) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # (-) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # (*) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # negate :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # abs :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # signum :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend # fromInteger :: Integer -> BackendKey SqlReadBackend #
Num (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (+) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # (-) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # (*) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # negate :: BackendKey SqlBackend -> BackendKey SqlBackend # abs :: BackendKey SqlBackend -> BackendKey SqlBackend # signum :: BackendKey SqlBackend -> BackendKey SqlBackend # fromInteger :: Integer -> BackendKey SqlBackend #
Ord (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods compare :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Ordering # (<) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (<=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (>) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # (>=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool # max :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend # min :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend #
Ord (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods compare :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Ordering # (<) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (<=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (>) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # (>=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool # max :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend # min :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend #
Ord (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods compare :: BackendKey SqlBackend -> BackendKey SqlBackend -> Ordering # (<) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (<=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (>) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # (>=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool # max :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend # min :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend #
Read (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlWriteBackend) # readList :: ReadS [BackendKey SqlWriteBackend] # readPrec :: ReadPrec (BackendKey SqlWriteBackend) # readListPrec :: ReadPrec [BackendKey SqlWriteBackend] #
Read (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlReadBackend) # readList :: ReadS [BackendKey SqlReadBackend] # readPrec :: ReadPrec (BackendKey SqlReadBackend) # readListPrec :: ReadPrec [BackendKey SqlReadBackend] #
Read (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlBackend) # readList :: ReadS [BackendKey SqlBackend] # readPrec :: ReadPrec (BackendKey SqlBackend) # readListPrec :: ReadPrec [BackendKey SqlBackend] #
Real (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlWriteBackend -> Rational #
Real (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlReadBackend -> Rational #
Real (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlBackend -> Rational #
Show (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlWriteBackend -> ShowS # show :: BackendKey SqlWriteBackend -> String # showList :: [BackendKey SqlWriteBackend] -> ShowS #
Show (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlReadBackend -> ShowS # show :: BackendKey SqlReadBackend -> String # showList :: [BackendKey SqlReadBackend] -> ShowS #
Show (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlBackend -> ShowS # show :: BackendKey SqlBackend -> String # showList :: [BackendKey SqlBackend] -> ShowS #
ToJSON (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlWriteBackend -> Value # toEncoding :: BackendKey SqlWriteBackend -> Encoding # toJSONList :: [BackendKey SqlWriteBackend] -> Value # toEncodingList :: [BackendKey SqlWriteBackend] -> Encoding #
ToJSON (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlReadBackend -> Value # toEncoding :: BackendKey SqlReadBackend -> Encoding # toJSONList :: [BackendKey SqlReadBackend] -> Value # toEncodingList :: [BackendKey SqlReadBackend] -> Encoding #
ToJSON (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlBackend -> Value # toEncoding :: BackendKey SqlBackend -> Encoding # toJSONList :: [BackendKey SqlBackend] -> Value # toEncodingList :: [BackendKey SqlBackend] -> Encoding #
FromJSON (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlWriteBackend) # parseJSONList :: Value -> Parser [BackendKey SqlWriteBackend] #
FromJSON (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlReadBackend) # parseJSONList :: Value -> Parser [BackendKey SqlReadBackend] #
FromJSON (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlBackend) # parseJSONList :: Value -> Parser [BackendKey SqlBackend] #
ToHttpApiData (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlWriteBackend -> Text # toEncodedUrlPiece :: BackendKey SqlWriteBackend -> Builder # toHeader :: BackendKey SqlWriteBackend -> ByteString # toQueryParam :: BackendKey SqlWriteBackend -> Text #
ToHttpApiData (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlReadBackend -> Text # toEncodedUrlPiece :: BackendKey SqlReadBackend -> Builder # toHeader :: BackendKey SqlReadBackend -> ByteString # toQueryParam :: BackendKey SqlReadBackend -> Text #
ToHttpApiData (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlBackend -> Text # toEncodedUrlPiece :: BackendKey SqlBackend -> Builder # toHeader :: BackendKey SqlBackend -> ByteString # toQueryParam :: BackendKey SqlBackend -> Text #
FromHttpApiData (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlWriteBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlWriteBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlWriteBackend) #
FromHttpApiData (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlReadBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlReadBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlReadBackend) #
FromHttpApiData (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlBackend) # parseHeader :: ByteString -> Either Text (BackendKey SqlBackend) # parseQueryParam :: Text -> Either Text (BackendKey SqlBackend) #
PathPiece (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlWriteBackend) # toPathPiece :: BackendKey SqlWriteBackend -> Text #
PathPiece (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlReadBackend) # toPathPiece :: BackendKey SqlReadBackend -> Text #
PathPiece (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlBackend) # toPathPiece :: BackendKey SqlBackend -> Text #
PersistField (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlWriteBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlWriteBackend) #
PersistField (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlReadBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlReadBackend) #
PersistField (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlBackend -> PersistValue # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlBackend) #
PersistFieldSql (BackendKey SqlWriteBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlWriteBackend) -> SqlType #
PersistFieldSql (BackendKey SqlReadBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlReadBackend) -> SqlType #
PersistFieldSql (BackendKey SqlBackend) # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlBackend) -> SqlType #
data BackendKey SqlWriteBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore data BackendKey SqlWriteBackend = SqlWriteBackendKey { unSqlWriteBackendKey :: Int64 }
data BackendKey SqlReadBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore data BackendKey SqlReadBackend = SqlReadBackendKey { unSqlReadBackendKey :: Int64 }
data BackendKey SqlBackend # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore data BackendKey SqlBackend = SqlBackendKey { unSqlBackendKey :: Int64 }

toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record #

fromSqlKey :: ToBackendKey SqlBackend record => Key record -> Int64 #

getFieldName :: forall record typ m backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, IsSqlBackend backend, Monad m) => EntityField record typ -> ReaderT backend m Text #

get the SQL string for the field that an EntityField represents Useful for raw SQL queries

Your backend may provide a more convenient fieldName function which does not operate in a Monad

getTableName :: forall record m backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, IsSqlBackend backend, Monad m) => record -> ReaderT backend m Text #

get the SQL string for the table that a PeristEntity represents Useful for raw SQL queries

Your backend may provide a more convenient tableName function which does not operate in a Monad

tableDBName :: PersistEntity record => record -> DBName #

useful for a backend to implement tableName by adding escaping

fieldDBName :: forall record typ. PersistEntity record => EntityField record typ -> DBName #

useful for a backend to implement fieldName by adding escaping

rawQuery :: (MonadResource m, MonadReader env m, HasPersistBackend env, BaseBackend env ~ SqlBackend) => Text -> [PersistValue] -> ConduitM () [PersistValue] m () #

rawQueryRes :: (MonadIO m1, MonadIO m2, IsSqlBackend env) => Text -> [PersistValue] -> ReaderT env m1 (Acquire (ConduitM () [PersistValue] m2 ())) #

rawExecute #

Arguments

:: (MonadIO m, BackendCompatible SqlBackend backend) |
=> Text | SQL statement, possibly with placeholders.
-> [PersistValue] | Values to fill the placeholders.
-> ReaderT backend m () |

Execute a raw SQL statement

rawExecuteCount #

Arguments

:: (MonadIO m, BackendCompatible SqlBackend backend) |
=> Text | SQL statement, possibly with placeholders.
-> [PersistValue] | Values to fill the placeholders.
-> ReaderT backend m Int64 |

Execute a raw SQL statement and return the number of rows it has modified.

rawSql #

Arguments

:: (RawSql a, MonadIO m) |
=> Text | SQL statement, possibly with placeholders.
-> [PersistValue] | Values to fill the placeholders.
-> ReaderT SqlBackend m [a] |

Execute a raw SQL statement and return its results as a list.

If you're using `Entity` `s` (which is quite likely), then you must use entity selection placeholders (double question mark, `??`). These `??` placeholders are then replaced for the names of the columns that we need for your entities. You'll receive an error if you don't use the placeholders. Please see the `Entity` `s` documentation for more details.

You may put value placeholders (question marks, `?`) in your SQL query. These placeholders are then replaced by the values you pass on the second parameter, already correctly escaped. You may want to use `toPersistValue` to help you constructing the placeholder values.

Since you're giving a raw SQL statement, you don't get any guarantees regarding safety. If `rawSql` is not able to parse the results of your query back, then an exception is raised. However, most common problems are mitigated by using the entity selection placeholder `??`, and you shouldn't see any error at all if you're not using `Single`.

Some example of `rawSql` based on this schema:

    share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
    Person
        name String
        age Int Maybe
        deriving Show
    BlogPost
        title String
        authorId PersonId
        deriving Show
    |]

Examples based on the above schema:

    getPerson :: MonadIO m => ReaderT SqlBackend m [Entity Person]
    getPerson = rawSql "select ?? from person where name=?" [PersistText "john"]

    getAge :: MonadIO m => ReaderT SqlBackend m [Single Int]
    getAge = rawSql "select person.age from person where name=?" [PersistText "john"]

    getAgeName :: MonadIO m => ReaderT SqlBackend m [(Single Int, Single Text)]
    getAgeName = rawSql "select person.age, person.name from person where name=?" [PersistText "john"]

    getPersonBlog :: MonadIO m => ReaderT SqlBackend m [(Entity Person, Entity BlogPost)]
    getPersonBlog = rawSql "select ??,?? from person,blog_post where person.id = blog_post.author_id" []

Minimal working program for PostgreSQL backend based on the above concepts:

    {-# LANGUAGE EmptyDataDecls             #-}
    {-# LANGUAGE FlexibleContexts           #-}
    {-# LANGUAGE GADTs                      #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE MultiParamTypeClasses      #-}
    {-# LANGUAGE OverloadedStrings          #-}
    {-# LANGUAGE QuasiQuotes                #-}
    {-# LANGUAGE TemplateHaskell            #-}
    {-# LANGUAGE TypeFamilies               #-}

    import           Control.Monad.IO.Class  (liftIO)
    import           Control.Monad.Logger    (runStderrLoggingT)
    import           Database.Persist
    import           Control.Monad.Reader
    import           Data.Text
    import           Database.Persist.Sql
    import           Database.Persist.Postgresql
    import           Database.Persist.TH

    share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
    Person
        name String
        age Int Maybe
        deriving Show
    |]

    conn = "host=localhost dbname=new_db user=postgres password=postgres port=5432"

    getPerson :: MonadIO m => ReaderT SqlBackend m [Entity Person]
    getPerson = rawSql "select ?? from person where name=?" [PersistText "sibi"]

    liftSqlPersistMPool y x = liftIO (runSqlPersistMPool y x)

    main :: IO ()
    main = runStderrLoggingT $ withPostgresqlPool conn 10 $ liftSqlPersistMPool $ do
             runMigration migrateAll
             xs <- getPerson
             liftIO (print xs)

deleteWhereCount :: (PersistEntity val, MonadIO m, PersistEntityBackend val ~ SqlBackend, IsSqlBackend backend) => [Filter val] -> ReaderT backend m Int64 #

Same as `deleteWhere`, but returns the number of rows affected.

Since: persistent-1.1.5

updateWhereCount :: (PersistEntity val, MonadIO m, SqlBackend ~ PersistEntityBackend val, IsSqlBackend backend) => [Filter val] -> [Update val] -> ReaderT backend m Int64 #

Same as `updateWhere`, but returns the number of rows affected.

Since: persistent-1.1.5

transactionSave :: MonadIO m => ReaderT SqlBackend m () #

Commit the current transaction and begin a new one.

Since: persistent-1.2.0

transactionSaveWithIsolation :: MonadIO m => IsolationLevel -> ReaderT SqlBackend m () #

Commit the current transaction and begin a new one with the specified isolation level.

Since: persistent-2.9.0

transactionUndo :: MonadIO m => ReaderT SqlBackend m () #

Roll back the current transaction and begin a new one.

Since: persistent-1.2.0

transactionUndoWithIsolation :: MonadIO m => IsolationLevel -> ReaderT SqlBackend m () #

Roll back the current transaction and begin a new one with the specified isolation level.

Since: persistent-2.9.0

data IsolationLevel #

Please refer to the documentation for the database in question for a full overview of the semantics of the varying isloation levels

Constructors

ReadUncommitted |
ReadCommitted |
RepeatableRead |
Serializable |

Instances

Bounded IsolationLevel # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods minBound :: IsolationLevel # maxBound :: IsolationLevel #
Enum IsolationLevel # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods succ :: IsolationLevel -> IsolationLevel # pred :: IsolationLevel -> IsolationLevel # toEnum :: Int -> IsolationLevel # fromEnum :: IsolationLevel -> Int # enumFrom :: IsolationLevel -> [IsolationLevel] # enumFromThen :: IsolationLevel -> IsolationLevel -> [IsolationLevel] # enumFromTo :: IsolationLevel -> IsolationLevel -> [IsolationLevel] # enumFromThenTo :: IsolationLevel -> IsolationLevel -> IsolationLevel -> [IsolationLevel] #
Eq IsolationLevel # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods (==) :: IsolationLevel -> IsolationLevel -> Bool # (/=) :: IsolationLevel -> IsolationLevel -> Bool #
Ord IsolationLevel # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods compare :: IsolationLevel -> IsolationLevel -> Ordering # (<) :: IsolationLevel -> IsolationLevel -> Bool # (<=) :: IsolationLevel -> IsolationLevel -> Bool # (>) :: IsolationLevel -> IsolationLevel -> Bool # (>=) :: IsolationLevel -> IsolationLevel -> Bool # max :: IsolationLevel -> IsolationLevel -> IsolationLevel # min :: IsolationLevel -> IsolationLevel -> IsolationLevel #
Show IsolationLevel # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods showsPrec :: Int -> IsolationLevel -> ShowS # show :: IsolationLevel -> String # showList :: [IsolationLevel] -> ShowS #

getStmtConn :: SqlBackend -> Text -> IO Statement #

# Internal

mkColumns :: [EntityDef] -> EntityDef -> ([Column], [UniqueDef], [ForeignDef]) #

Create the list of columns for the given entity.

defaultAttribute :: [Attr] -> Maybe Text #

decorateSQLWithLimitOffset :: Text -> (Int, Int) -> Bool -> Text -> Text #

Generates sql for limit and offset for postgres, sqlite and mysql.