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

Safe Haskell | None
Language | Haskell2010

Database.Persist.Sql.Types.Internal

Description

Breaking changes to this module are not reflected in the major version number. Prefer to import from Database.Persist.Sql instead. If you neeed something from this module, please file an issue on GitHub.

Synopsis

- class HasPersistBackend backend where
  - type BaseBackend backend
  - persistBackend :: backend -> BaseBackend backend
- class HasPersistBackend backend => IsPersistBackend backend where
  - mkPersistBackend :: BaseBackend backend -> backend
- newtype SqlReadBackend = SqlReadBackend {
  - unSqlReadBackend :: SqlBackend
  }
- newtype SqlWriteBackend = SqlWriteBackend {
  - unSqlWriteBackend :: SqlBackend
  }
- readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a
- readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a
- writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a
- type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- data InsertSqlResult
  - = ISRSingle Text
  - | ISRInsertGet Text Text
  - | ISRManyKeys Text [PersistValue]
- data Statement = Statement {
  - stmtFinalize :: IO ()
  - stmtReset :: IO ()
  - stmtExecute :: [PersistValue] -> IO Int64
  - stmtQuery :: forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())
  }
- data IsolationLevel
  - = ReadUncommitted
  - | ReadCommitted
  - | RepeatableRead
  - | Serializable
- makeIsolationLevelStatement :: (Monoid s, IsString s) => IsolationLevel -> s
- data SqlBackend = SqlBackend {
  - connPrepare :: Text -> IO Statement
  - connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult
  - connInsertManySql :: Maybe (EntityDef -> [[PersistValue]] -> InsertSqlResult)
  - connUpsertSql :: Maybe (EntityDef -> NonEmpty (FieldNameHS, FieldNameDB) -> Text -> Text)
  - connPutManySql :: Maybe (EntityDef -> Int -> Text)
  - connStmtMap :: StatementCache
  - 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 ()
  - connEscapeFieldName :: FieldNameDB -> Text
  - connEscapeTableName :: EntityDef -> Text
  - connEscapeRawName :: Text -> Text
  - connNoLimit :: Text
  - connRDBMS :: Text
  - connLimitOffset :: (Int, Int) -> Text -> Text
  - connLogFunc :: LogFunc
  - connMaxParams :: Maybe Int
  - connRepsertManySql :: Maybe (EntityDef -> Int -> Text)
  - connVault :: Vault
  - connHooks :: SqlBackendHooks
  }
- 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 :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m a
- type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a
- type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend)
- newtype SqlBackendHooks = SqlBackendHooks {
  - hookGetStatement :: SqlBackend -> Text -> Statement -> IO Statement
  }

# Documentation

class HasPersistBackend backend where Source #

Class which allows the plucking of a `BaseBackend backend` from some larger type. For example, `instance HasPersistBackend (SqlReadBackend, Int) where type BaseBackend (SqlReadBackend, Int) = SqlBackend persistBackend = unSqlReadBackend . fst`

Associated Types

type BaseBackend backend Source #

Methods

persistBackend :: backend -> BaseBackend backend Source #

#### Instances

Instances details

HasPersistBackend SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlReadBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend

Methods

persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend Source #

HasPersistBackend SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlWriteBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend

Methods

persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend Source #

HasPersistBackend SqlBackend Source # |

Instance details

Defined in Database.Persist.SqlBackend.Internal

Associated Types

type BaseBackend SqlBackend |
Instance details Defined in Database.Persist.SqlBackend.Internal type BaseBackend SqlBackend = SqlBackend

Methods

persistBackend :: SqlBackend -> BaseBackend SqlBackend Source #

(BackendCompatible b s, HasPersistBackend b) => HasPersistBackend (Compatible b s) Source # |

Instance details

Defined in Database.Persist.Compatible.Types

Associated Types

type BaseBackend (Compatible b s) |
Instance details Defined in Database.Persist.Compatible.Types type BaseBackend (Compatible b s) = BaseBackend b

Methods

persistBackend :: Compatible b s -> BaseBackend (Compatible b s) Source #

class HasPersistBackend backend => IsPersistBackend backend where Source #

Class which witnesses that `backend` is essentially the same as `BaseBackend backend`. That is, they're isomorphic and `backend` is just some wrapper over `BaseBackend backend`.

Methods

mkPersistBackend :: BaseBackend backend -> backend Source #

This function is how we actually construct and tag a backend as having read or write capabilities. It should be used carefully and only when actually constructing a `backend`. Careless use allows us to accidentally run a write query against a read-only database.

#### Instances

Instances details

IsPersistBackend SqlReadBackend Source # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend Source #
IsPersistBackend SqlWriteBackend Source # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend Source #
IsPersistBackend SqlBackend Source # |
Instance details Defined in Database.Persist.SqlBackend.Internal Methods mkPersistBackend :: BaseBackend SqlBackend -> SqlBackend Source #

newtype SqlReadBackend Source #

An SQL backend which can only handle read queries

The constructor was exposed in 2.10.0.

Constructors

SqlReadBackend |

Fields

- unSqlReadBackend :: SqlBackend

#### Instances

Instances details

PersistQueryRead SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record SqlReadBackend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT SqlReadBackend m1 (Acquire (ConduitM () (Entity record) m2 ())) Source #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlReadBackend m (Maybe (Entity record)) Source #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record SqlReadBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlReadBackend m1 (Acquire (ConduitM () (Key record) m2 ())) Source #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Filter record] -> ReaderT SqlReadBackend m Int Source #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Filter record] -> ReaderT SqlReadBackend m Bool Source #

HasPersistBackend SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlReadBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend

Methods

persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend Source #

IsPersistBackend SqlReadBackend Source # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend Source #
PersistCore SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

newtype BackendKey SqlReadBackend |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlReadBackend = SqlReadBackendKey {

- unSqlReadBackendKey :: Int64

}

PersistStoreRead SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlReadBackend) => Key record -> ReaderT SqlReadBackend m (Maybe record) Source #

getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlReadBackend) => [Key record] -> ReaderT SqlReadBackend m (Map (Key record) record) Source #

PersistUniqueRead SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlReadBackend) => Unique record -> ReaderT SqlReadBackend m (Maybe (Entity record)) Source #

existsBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlReadBackend) => Unique record -> ReaderT SqlReadBackend m Bool Source #

BackendCompatible SqlBackend SqlReadBackend Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlReadBackend -> SqlBackend Source #
FromJSON (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlReadBackend) Source # parseJSONList :: Value -> Parser [BackendKey SqlReadBackend] Source # omittedField :: Maybe (BackendKey SqlReadBackend) Source #
ToJSON (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlReadBackend -> Value Source # toEncoding :: BackendKey SqlReadBackend -> Encoding Source # toJSONList :: [BackendKey SqlReadBackend] -> Value Source # toEncodingList :: [BackendKey SqlReadBackend] -> Encoding Source # omitField :: BackendKey SqlReadBackend -> Bool Source #
Bounded (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlReadBackend Source # maxBound :: BackendKey SqlReadBackend Source #
Enum (BackendKey SqlReadBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

succ :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

pred :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

toEnum :: Int -> BackendKey SqlReadBackend Source #

fromEnum :: BackendKey SqlReadBackend -> Int Source #

enumFrom :: BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] Source #

enumFromThen :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] Source #

enumFromTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] Source #

enumFromThenTo :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> [BackendKey SqlReadBackend] Source #

Generic (BackendKey SqlReadBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

type Rep (BackendKey SqlReadBackend) |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.17.1.0-EQFFjlejpWP10lX0h8hkWO" 'True) (C1 ('MetaCons "SqlReadBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

Methods

from :: BackendKey SqlReadBackend -> Rep (BackendKey SqlReadBackend) x Source #

to :: Rep (BackendKey SqlReadBackend) x -> BackendKey SqlReadBackend Source #

Num (BackendKey SqlReadBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

(+) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

(-) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

(*) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

negate :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

abs :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

signum :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

fromInteger :: Integer -> BackendKey SqlReadBackend Source #

Read (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlReadBackend) Source # readList :: ReadS [BackendKey SqlReadBackend] Source # readPrec :: ReadPrec (BackendKey SqlReadBackend) Source # readListPrec :: ReadPrec [BackendKey SqlReadBackend] Source #
Integral (BackendKey SqlReadBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

quot :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

rem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

div :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

mod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

quotRem :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) Source #

divMod :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> (BackendKey SqlReadBackend, BackendKey SqlReadBackend) Source #

toInteger :: BackendKey SqlReadBackend -> Integer Source #

Real (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlReadBackend -> Rational Source #
Show (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlReadBackend -> ShowS Source # show :: BackendKey SqlReadBackend -> String Source # showList :: [BackendKey SqlReadBackend] -> ShowS Source #
Eq (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool Source # (/=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool Source #
Ord (BackendKey SqlReadBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

compare :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Ordering Source #

(<) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool Source #

(<=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool Source #

(>) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool Source #

(>=) :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> Bool Source #

max :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

min :: BackendKey SqlReadBackend -> BackendKey SqlReadBackend -> BackendKey SqlReadBackend Source #

FromHttpApiData (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlReadBackend) Source # parseHeader :: ByteString -> Either Text (BackendKey SqlReadBackend) Source # parseQueryParam :: Text -> Either Text (BackendKey SqlReadBackend) Source #
ToHttpApiData (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlReadBackend -> Text Source # toEncodedUrlPiece :: BackendKey SqlReadBackend -> Builder Source # toHeader :: BackendKey SqlReadBackend -> ByteString Source # toQueryParam :: BackendKey SqlReadBackend -> Text Source # toEncodedQueryParam :: BackendKey SqlReadBackend -> Builder Source #
PathPiece (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlReadBackend) Source # toPathPiece :: BackendKey SqlReadBackend -> Text Source #
PersistField (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlReadBackend -> PersistValue Source # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlReadBackend) Source #
PersistFieldSql (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlReadBackend) -> SqlType Source #
newtype BackendKey SqlReadBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlReadBackend = SqlReadBackendKey {

- unSqlReadBackendKey :: Int64

}

type BaseBackend SqlReadBackend Source # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlReadBackend = SqlBackend
type Rep (BackendKey SqlReadBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.17.1.0-EQFFjlejpWP10lX0h8hkWO" 'True) (C1 ('MetaCons "SqlReadBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

newtype SqlWriteBackend Source #

An SQL backend which can handle read or write queries

The constructor was exposed in 2.10.0

Constructors

SqlWriteBackend |

Fields

- unSqlWriteBackend :: SqlBackend

#### Instances

Instances details

PersistQueryRead SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record SqlWriteBackend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT SqlWriteBackend m1 (Acquire (ConduitM () (Entity record) m2 ())) Source #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlWriteBackend m (Maybe (Entity record)) Source #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlWriteBackend m1 (Acquire (ConduitM () (Key record) m2 ())) Source #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> ReaderT SqlWriteBackend m Int Source #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> ReaderT SqlWriteBackend m Bool Source #

PersistQueryWrite SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> [Update record] -> ReaderT SqlWriteBackend m () Source #

deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Filter record] -> ReaderT SqlWriteBackend m () Source #

HasPersistBackend SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Types.Internal

Associated Types

type BaseBackend SqlWriteBackend |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend

Methods

persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend Source #

IsPersistBackend SqlWriteBackend Source # |
Instance details Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend Source #
PersistCore SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

newtype BackendKey SqlWriteBackend |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlWriteBackend = SqlWriteBackendKey {

- unSqlWriteBackendKey :: Int64

}

PersistStoreRead SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> ReaderT SqlWriteBackend m (Maybe record) Source #

getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Key record] -> ReaderT SqlWriteBackend m (Map (Key record) record) Source #

PersistStoreWrite SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => record -> ReaderT SqlWriteBackend m (Key record) Source #

insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => record -> ReaderT SqlWriteBackend m () Source #

insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => [record] -> ReaderT SqlWriteBackend m [Key record] Source #

insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => [record] -> ReaderT SqlWriteBackend m () Source #

insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [Entity record] -> ReaderT SqlWriteBackend m () Source #

insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> record -> ReaderT SqlWriteBackend m () Source #

repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> record -> ReaderT SqlWriteBackend m () Source #

repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => [(Key record, record)] -> ReaderT SqlWriteBackend m () Source #

replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> record -> ReaderT SqlWriteBackend m () Source #

delete :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> ReaderT SqlWriteBackend m () Source #

update :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> [Update record] -> ReaderT SqlWriteBackend m () Source #

updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Key record -> [Update record] -> ReaderT SqlWriteBackend m record Source #

PersistUniqueRead SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Unique record -> ReaderT SqlWriteBackend m (Maybe (Entity record)) Source #

existsBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Unique record -> ReaderT SqlWriteBackend m Bool Source #

PersistUniqueWrite SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend) => Unique record -> ReaderT SqlWriteBackend m () Source #

insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => record -> ReaderT SqlWriteBackend m (Maybe (Key record)) Source #

insertUnique_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => record -> ReaderT SqlWriteBackend m (Maybe ()) Source #

upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, OnlyOneUniqueKey record, SafeToInsert record) => record -> [Update record] -> ReaderT SqlWriteBackend m (Entity record) Source #

upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => Unique record -> record -> [Update record] -> ReaderT SqlWriteBackend m (Entity record) Source #

putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlWriteBackend, SafeToInsert record) => [record] -> ReaderT SqlWriteBackend m () Source #

BackendCompatible SqlBackend SqlWriteBackend Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlWriteBackend -> SqlBackend Source #
FromJSON (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlWriteBackend) Source # parseJSONList :: Value -> Parser [BackendKey SqlWriteBackend] Source # omittedField :: Maybe (BackendKey SqlWriteBackend) Source #
ToJSON (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlWriteBackend -> Value Source # toEncoding :: BackendKey SqlWriteBackend -> Encoding Source # toJSONList :: [BackendKey SqlWriteBackend] -> Value Source # toEncodingList :: [BackendKey SqlWriteBackend] -> Encoding Source # omitField :: BackendKey SqlWriteBackend -> Bool Source #
Bounded (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlWriteBackend Source # maxBound :: BackendKey SqlWriteBackend Source #
Enum (BackendKey SqlWriteBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

succ :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

pred :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

toEnum :: Int -> BackendKey SqlWriteBackend Source #

fromEnum :: BackendKey SqlWriteBackend -> Int Source #

enumFrom :: BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] Source #

enumFromThen :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] Source #

enumFromTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] Source #

enumFromThenTo :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> [BackendKey SqlWriteBackend] Source #

Generic (BackendKey SqlWriteBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

type Rep (BackendKey SqlWriteBackend) |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.17.1.0-EQFFjlejpWP10lX0h8hkWO" 'True) (C1 ('MetaCons "SqlWriteBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

Methods

from :: BackendKey SqlWriteBackend -> Rep (BackendKey SqlWriteBackend) x Source #

to :: Rep (BackendKey SqlWriteBackend) x -> BackendKey SqlWriteBackend Source #

Num (BackendKey SqlWriteBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

(+) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

(-) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

(*) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

negate :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

abs :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

signum :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

fromInteger :: Integer -> BackendKey SqlWriteBackend Source #

Read (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlWriteBackend) Source # readList :: ReadS [BackendKey SqlWriteBackend] Source # readPrec :: ReadPrec (BackendKey SqlWriteBackend) Source # readListPrec :: ReadPrec [BackendKey SqlWriteBackend] Source #
Integral (BackendKey SqlWriteBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

quot :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

rem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

div :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

mod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

quotRem :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) Source #

divMod :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> (BackendKey SqlWriteBackend, BackendKey SqlWriteBackend) Source #

toInteger :: BackendKey SqlWriteBackend -> Integer Source #

Real (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlWriteBackend -> Rational Source #
Show (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlWriteBackend -> ShowS Source # show :: BackendKey SqlWriteBackend -> String Source # showList :: [BackendKey SqlWriteBackend] -> ShowS Source #
Eq (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool Source # (/=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool Source #
Ord (BackendKey SqlWriteBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

compare :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Ordering Source #

(<) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool Source #

(<=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool Source #

(>) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool Source #

(>=) :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> Bool Source #

max :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

min :: BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend -> BackendKey SqlWriteBackend Source #

FromHttpApiData (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlWriteBackend) Source # parseHeader :: ByteString -> Either Text (BackendKey SqlWriteBackend) Source # parseQueryParam :: Text -> Either Text (BackendKey SqlWriteBackend) Source #
ToHttpApiData (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlWriteBackend -> Text Source # toEncodedUrlPiece :: BackendKey SqlWriteBackend -> Builder Source # toHeader :: BackendKey SqlWriteBackend -> ByteString Source # toQueryParam :: BackendKey SqlWriteBackend -> Text Source # toEncodedQueryParam :: BackendKey SqlWriteBackend -> Builder Source #
PathPiece (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlWriteBackend) Source # toPathPiece :: BackendKey SqlWriteBackend -> Text Source #
PersistField (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlWriteBackend -> PersistValue Source # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlWriteBackend) Source #
PersistFieldSql (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlWriteBackend) -> SqlType Source #
newtype BackendKey SqlWriteBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlWriteBackend = SqlWriteBackendKey {

- unSqlWriteBackendKey :: Int64

}

type BaseBackend SqlWriteBackend Source # |
Instance details Defined in Database.Persist.Sql.Types.Internal type BaseBackend SqlWriteBackend = SqlBackend
type Rep (BackendKey SqlWriteBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.17.1.0-EQFFjlejpWP10lX0h8hkWO" 'True) (C1 ('MetaCons "SqlWriteBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a Source #

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

readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a Source #

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

writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a Source #

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

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

data InsertSqlResult Source #

Constructors

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

data Statement Source #

A `Statement` is a representation of a database query that has been prepared and stored on the server side.

Constructors

Statement |

Fields

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

data IsolationLevel Source #

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

Constructors

ReadUncommitted |
ReadCommitted |
RepeatableRead |
Serializable |

#### Instances

Instances details

Bounded IsolationLevel Source # |
Instance details Defined in Database.Persist.SqlBackend.Internal.IsolationLevel Methods minBound :: IsolationLevel Source # maxBound :: IsolationLevel Source #
Enum IsolationLevel Source # |

Instance details

Defined in Database.Persist.SqlBackend.Internal.IsolationLevel

Methods

succ :: IsolationLevel -> IsolationLevel Source #

pred :: IsolationLevel -> IsolationLevel Source #

toEnum :: Int -> IsolationLevel Source #

fromEnum :: IsolationLevel -> Int Source #

enumFrom :: IsolationLevel -> [IsolationLevel] Source #

enumFromThen :: IsolationLevel -> IsolationLevel -> [IsolationLevel] Source #

enumFromTo :: IsolationLevel -> IsolationLevel -> [IsolationLevel] Source #

enumFromThenTo :: IsolationLevel -> IsolationLevel -> IsolationLevel -> [IsolationLevel] Source #

Show IsolationLevel Source # |
Instance details Defined in Database.Persist.SqlBackend.Internal.IsolationLevel Methods showsPrec :: Int -> IsolationLevel -> ShowS Source # show :: IsolationLevel -> String Source # showList :: [IsolationLevel] -> ShowS Source #
Eq IsolationLevel Source # |
Instance details Defined in Database.Persist.SqlBackend.Internal.IsolationLevel Methods (==) :: IsolationLevel -> IsolationLevel -> Bool Source # (/=) :: IsolationLevel -> IsolationLevel -> Bool Source #
Ord IsolationLevel Source # |

Instance details

Defined in Database.Persist.SqlBackend.Internal.IsolationLevel

Methods

compare :: IsolationLevel -> IsolationLevel -> Ordering Source #

(<) :: IsolationLevel -> IsolationLevel -> Bool Source #

(<=) :: IsolationLevel -> IsolationLevel -> Bool Source #

(>) :: IsolationLevel -> IsolationLevel -> Bool Source #

(>=) :: IsolationLevel -> IsolationLevel -> Bool Source #

max :: IsolationLevel -> IsolationLevel -> IsolationLevel Source #

min :: IsolationLevel -> IsolationLevel -> IsolationLevel Source #

makeIsolationLevelStatement :: (Monoid s, IsString s) => IsolationLevel -> s Source #

data SqlBackend Source #

A `SqlBackend` represents a handle or connection to a database. It contains functions and values that allow databases to have more optimized implementations, as well as references that benefit performance and sharing.

Instead of using the `SqlBackend` constructor directly, use the `mkSqlBackend` function.

A `SqlBackend` is *not* thread-safe. You should not assume that a `SqlBackend` can be shared among threads and run concurrent queries. This *will* result in problems. Instead, you should create a ``Pool` `SqlBackend``, known as a `ConnectionPool`, and pass that around in multi-threaded applications.

To run actions in the `persistent` library, you should use the `runSqlConn` function. If you're using a multithreaded application, use the `runSqlPool` function.

Constructors

SqlBackend |

Fields

- connPrepare :: Text -> IO Statement

  This function should prepare a `Statement` in the target database, which should allow for efficient query reuse.

- connInsertSql :: EntityDef -> [PersistValue] -> InsertSqlResult

  This function generates the SQL and values necessary for performing an insert against the database.

- connInsertManySql :: Maybe (EntityDef -> [[PersistValue]] -> InsertSqlResult)

  SQL for inserting many rows and returning their primary keys, for backends that support this functionality. If `Nothing`, rows will be inserted one-at-a-time using `connInsertSql`.

- connUpsertSql :: Maybe (EntityDef -> NonEmpty (FieldNameHS, FieldNameDB) -> 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: 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: 2.8.1

- connStmtMap :: StatementCache

  A reference to the cache of statements. `Statement`s are keyed by the `Text` queries that generated them.

- connClose :: IO ()

  Close the underlying connection.

- connMigrateSql :: [EntityDef] -> (Text -> IO Statement) -> EntityDef -> IO (Either [Text] [(Bool, Text)])

  This function returns the migrations required to include the `EntityDef` parameter in the `[`EntityDef`]` database. This might include creating a new table if the entity is not present, or altering an existing table if it is.

- connBegin :: (Text -> IO Statement) -> Maybe IsolationLevel -> IO ()

  A function to begin a transaction for the underlying database.

- connCommit :: (Text -> IO Statement) -> IO ()

  A function to commit a transaction to the underlying database.

- connRollback :: (Text -> IO Statement) -> IO ()

  A function to roll back a transaction on the underlying database.

- connEscapeFieldName :: FieldNameDB -> Text

  A function to extract and escape the name of the column corresponding to the provided field.

  Since: 2.12.0.0

- connEscapeTableName :: EntityDef -> Text

  A function to extract and escape the name of the table corresponding to the provided entity. PostgreSQL uses this to support schemas.

  Since: 2.12.0.0

- connEscapeRawName :: Text -> Text

  A function to escape raw DB identifiers. MySQL uses backticks, while PostgreSQL uses quotes, and so on.

  Since: 2.12.0.0

- connNoLimit :: Text
- connRDBMS :: Text

  A tag displaying what database the `SqlBackend` is for. Can be used to differentiate features in downstream libraries for different database backends.

- connLimitOffset :: (Int, Int) -> Text -> Text

  Attach a 'LIMIT/OFFSET' clause to a SQL query. Note that LIMIT/OFFSET is problematic for performance, and indexed range queries are the superior way to offer pagination.

- connLogFunc :: LogFunc

  A log function for the `SqlBackend` to use.

- connMaxParams :: Maybe Int

  Some databases (probably only Sqlite) have a limit on how many question-mark parameters may be used in a statement

  Since: 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: 2.9.0

- connVault :: Vault

  Carry arbitrary payloads for the connection that may be used to propagate information into hooks.

- connHooks :: SqlBackendHooks

  Instrumentation hooks that may be used to track the behaviour of a backend.

#### Instances

Instances details

PersistQueryRead SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record SqlBackend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT SqlBackend m1 (Acquire (ConduitM () (Entity record) m2 ())) Source #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlBackend m (Maybe (Entity record)) Source #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record SqlBackend) => [Filter record] -> [SelectOpt record] -> ReaderT SqlBackend m1 (Acquire (ConduitM () (Key record) m2 ())) Source #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> ReaderT SqlBackend m Int Source #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> ReaderT SqlBackend m Bool Source #

PersistQueryWrite SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistQuery

Methods

updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> [Update record] -> ReaderT SqlBackend m () Source #

deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record SqlBackend) => [Filter record] -> ReaderT SqlBackend m () Source #

HasPersistBackend SqlBackend Source # |

Instance details

Defined in Database.Persist.SqlBackend.Internal

Associated Types

type BaseBackend SqlBackend |
Instance details Defined in Database.Persist.SqlBackend.Internal type BaseBackend SqlBackend = SqlBackend

Methods

persistBackend :: SqlBackend -> BaseBackend SqlBackend Source #

IsPersistBackend SqlBackend Source # |
Instance details Defined in Database.Persist.SqlBackend.Internal Methods mkPersistBackend :: BaseBackend SqlBackend -> SqlBackend Source #
PersistCore SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

newtype BackendKey SqlBackend |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlBackend = SqlBackendKey {

- unSqlBackendKey :: Int64

}

PersistStoreRead SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> ReaderT SqlBackend m (Maybe record) Source #

getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => [Key record] -> ReaderT SqlBackend m (Map (Key record) record) Source #

PersistStoreWrite SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => record -> ReaderT SqlBackend m (Key record) Source #

insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => record -> ReaderT SqlBackend m () Source #

insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => [record] -> ReaderT SqlBackend m [Key record] Source #

insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => [record] -> ReaderT SqlBackend m () Source #

insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => [Entity record] -> ReaderT SqlBackend m () Source #

insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> record -> ReaderT SqlBackend m () Source #

repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> record -> ReaderT SqlBackend m () Source #

repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => [(Key record, record)] -> ReaderT SqlBackend m () Source #

replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> record -> ReaderT SqlBackend m () Source #

delete :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> ReaderT SqlBackend m () Source #

update :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> [Update record] -> ReaderT SqlBackend m () Source #

updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Key record -> [Update record] -> ReaderT SqlBackend m record Source #

PersistUniqueRead SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m (Maybe (Entity record)) Source #

existsBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m Bool Source #

PersistUniqueWrite SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistUnique

Methods

deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend) => Unique record -> ReaderT SqlBackend m () Source #

insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => record -> ReaderT SqlBackend m (Maybe (Key record)) Source #

insertUnique_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => record -> ReaderT SqlBackend m (Maybe ()) Source #

upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, SafeToInsert record) => record -> [Update record] -> ReaderT SqlBackend m (Entity record) Source #

upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => Unique record -> record -> [Update record] -> ReaderT SqlBackend m (Entity record) Source #

putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record SqlBackend, SafeToInsert record) => [record] -> ReaderT SqlBackend m () Source #

BackendCompatible SqlBackend SqlReadBackend Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlReadBackend -> SqlBackend Source #
BackendCompatible SqlBackend SqlWriteBackend Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlWriteBackend -> SqlBackend Source #
BackendCompatible SqlBackend SqlBackend Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods projectBackend :: SqlBackend -> SqlBackend Source #
FromJSON (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseJSON :: Value -> Parser (BackendKey SqlBackend) Source # parseJSONList :: Value -> Parser [BackendKey SqlBackend] Source # omittedField :: Maybe (BackendKey SqlBackend) Source #
ToJSON (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toJSON :: BackendKey SqlBackend -> Value Source # toEncoding :: BackendKey SqlBackend -> Encoding Source # toJSONList :: [BackendKey SqlBackend] -> Value Source # toEncodingList :: [BackendKey SqlBackend] -> Encoding Source # omitField :: BackendKey SqlBackend -> Bool Source #
Bounded (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods minBound :: BackendKey SqlBackend Source # maxBound :: BackendKey SqlBackend Source #
Enum (BackendKey SqlBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

succ :: BackendKey SqlBackend -> BackendKey SqlBackend Source #

pred :: BackendKey SqlBackend -> BackendKey SqlBackend Source #

toEnum :: Int -> BackendKey SqlBackend Source #

fromEnum :: BackendKey SqlBackend -> Int Source #

enumFrom :: BackendKey SqlBackend -> [BackendKey SqlBackend] Source #

enumFromThen :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] Source #

enumFromTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] Source #

enumFromThenTo :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend -> [BackendKey SqlBackend] Source #

Generic (BackendKey SqlBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Associated Types

type Rep (BackendKey SqlBackend) |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.17.1.0-EQFFjlejpWP10lX0h8hkWO" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

Methods

from :: BackendKey SqlBackend -> Rep (BackendKey SqlBackend) x Source #

to :: Rep (BackendKey SqlBackend) x -> BackendKey SqlBackend Source #

Num (BackendKey SqlBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

(+) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

(-) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

(*) :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

negate :: BackendKey SqlBackend -> BackendKey SqlBackend Source #

abs :: BackendKey SqlBackend -> BackendKey SqlBackend Source #

signum :: BackendKey SqlBackend -> BackendKey SqlBackend Source #

fromInteger :: Integer -> BackendKey SqlBackend Source #

Read (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods readsPrec :: Int -> ReadS (BackendKey SqlBackend) Source # readList :: ReadS [BackendKey SqlBackend] Source # readPrec :: ReadPrec (BackendKey SqlBackend) Source # readListPrec :: ReadPrec [BackendKey SqlBackend] Source #
Integral (BackendKey SqlBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

quot :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

rem :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

div :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

mod :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

quotRem :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) Source #

divMod :: BackendKey SqlBackend -> BackendKey SqlBackend -> (BackendKey SqlBackend, BackendKey SqlBackend) Source #

toInteger :: BackendKey SqlBackend -> Integer Source #

Real (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toRational :: BackendKey SqlBackend -> Rational Source #
Show (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods showsPrec :: Int -> BackendKey SqlBackend -> ShowS Source # show :: BackendKey SqlBackend -> String Source # showList :: [BackendKey SqlBackend] -> ShowS Source #
Eq (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods (==) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool Source # (/=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool Source #
Ord (BackendKey SqlBackend) Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

Methods

compare :: BackendKey SqlBackend -> BackendKey SqlBackend -> Ordering Source #

(<) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool Source #

(<=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool Source #

(>) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool Source #

(>=) :: BackendKey SqlBackend -> BackendKey SqlBackend -> Bool Source #

max :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

min :: BackendKey SqlBackend -> BackendKey SqlBackend -> BackendKey SqlBackend Source #

FromHttpApiData (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods parseUrlPiece :: Text -> Either Text (BackendKey SqlBackend) Source # parseHeader :: ByteString -> Either Text (BackendKey SqlBackend) Source # parseQueryParam :: Text -> Either Text (BackendKey SqlBackend) Source #
ToHttpApiData (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toUrlPiece :: BackendKey SqlBackend -> Text Source # toEncodedUrlPiece :: BackendKey SqlBackend -> Builder Source # toHeader :: BackendKey SqlBackend -> ByteString Source # toQueryParam :: BackendKey SqlBackend -> Text Source # toEncodedQueryParam :: BackendKey SqlBackend -> Builder Source #
PathPiece (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods fromPathPiece :: Text -> Maybe (BackendKey SqlBackend) Source # toPathPiece :: BackendKey SqlBackend -> Text Source #
PersistField (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods toPersistValue :: BackendKey SqlBackend -> PersistValue Source # fromPersistValue :: PersistValue -> Either Text (BackendKey SqlBackend) Source #
PersistFieldSql (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore Methods sqlType :: Proxy (BackendKey SqlBackend) -> SqlType Source #
newtype BackendKey SqlBackend Source # |

Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlBackend = SqlBackendKey {

- unSqlBackendKey :: Int64

}

type BaseBackend SqlBackend Source # |
Instance details Defined in Database.Persist.SqlBackend.Internal type BaseBackend SqlBackend = SqlBackend
type Rep (BackendKey SqlBackend) Source # |
Instance details Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.17.1.0-EQFFjlejpWP10lX0h8hkWO" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

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

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) Source #

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

type SqlReadT (m :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m a Source #

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

type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a Source #

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

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

A backend which is a wrapper around `SqlBackend`.

newtype SqlBackendHooks Source #

Constructors

SqlBackendHooks |

Fields

- hookGetStatement :: SqlBackend -> Text -> Statement -> IO Statement