withSqlitePool :: (MonadUnliftIO m, MonadLoggerIO m)=> Text-> Intnumber of connections to open
-> (Pool SqlBackend -> m a)-> m a
Run the given action with a connection pool.
Like createSqlitePool, this should not be used with :memory:.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulepersistent-sqlite-2.13.3.0Haskell2010
A sqlite backend for persistent.
Note: If you prepend WAL=off to your connection string, it will disable
the write-ahead log. This functionality is now deprecated in favour of using SqliteConnectionInfo.
withSqlitePool :: (MonadUnliftIO m, MonadLoggerIO m)=> Text-> Intnumber of connections to open
-> (Pool SqlBackend -> m a)-> m aRun the given action with a connection pool.
Like createSqlitePool, this should not be used with :memory:.
withSqlitePoolInfo :: (MonadUnliftIO m, MonadLoggerIO m)=> SqliteConnectionInfo-> Intnumber of connections to open
-> (Pool SqlBackend -> m a)-> m aRun the given action with a connection pool.
Like createSqlitePool, this should not be used with :memory:.
Create a pool of SQLite connections.
Note that this should not be used with the :memory: connection string, as
the pool will regularly remove connections, destroying your database.
Instead, use withSqliteConn.
Create a pool of SQLite connections.
Note that this should not be used with the :memory: connection string, as
the pool will regularly remove connections, destroying your database.
Instead, use withSqliteConn.
createSqlitePoolWithConfig :: (MonadUnliftIO m, MonadLoggerIO m)=> Textconnection string
-> ConnectionPoolConfig-> m (Pool SqlBackend)Create a pool of SQLite connections.
A Statement is a representation of a database query that has been prepared and stored on the server side.
StatementstmtFinalize :: IO ()stmtReset :: IO ()stmtExecute :: [PersistValue] -> IO Int64stmtQuery :: forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())A raw value which can be stored in any backend and can be marshalled to
and from a PersistField.
PersistText TextPersistByteString ByteStringPersistInt64 Int64PersistDouble DoublePersistRational RationalPersistBool BoolPersistDay DayPersistTimeOfDay TimeOfDayPersistUTCTime UTCTimePersistNullPersistList [PersistValue]PersistMap [(Text, PersistValue)]PersistObjectId ByteStringIntended especially for MongoDB backend
PersistArray [PersistValue]Intended especially for PostgreSQL backend for text arrays
PersistLiteral_ LiteralType ByteStringThis constructor is used to specify some raw literal value for the backend. The LiteralType value specifies how the value should be escaped. This can be used to make special, custom types avaialable in the back end.
Eq PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueOrd PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueRead PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueShow PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueNFData PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueFromJSON PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueToJSON PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueFromHttpApiData PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValueToHttpApiData PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValuePathPiece PersistValueDefined in persistent-2.14.6.3 · Database.Persist.PersistValuePersistField PersistValueDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistFieldSql PersistValueDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassDeprecated. Deprecated since 2.11 because of inconsistent escaping behavior across backends. The Postgres backend escapes these values, while the MySQL backend does not. If you are using this, please switch to PersistLiteral_ and provide a relevant LiteralType for your conversion.
This pattern synonym used to be a data constructor for the PersistValue type. It was changed to be a pattern so that JSON-encoded database values could be parsed into their corresponding values. You should not use this, and instead prefer to pattern match on PersistLiteral_ directly.
If you use this, it will overlap a patern match on the 'PersistLiteral_, PersistLiteral, and PersistLiteralEscaped patterns. If you need to disambiguate between these constructors, pattern match on PersistLiteral_ directly.
This pattern synonym used to be a data constructor on PersistValue, but was changed into a catch-all pattern synonym to allow backwards compatiblity with database types. See the documentation on PersistDbSpecific for more details.
This pattern synonym used to be a data constructor on PersistValue, but was changed into a catch-all pattern synonym to allow backwards compatiblity with database types. See the documentation on PersistDbSpecific for more details.
Convert list of PersistValues into textual representation of JSON object. This is a type-constrained synonym for toJsonText.
Convert map (list of tuples) into textual representation of JSON object. This is a type-constrained synonym for toJsonText.
A type that determines how a backend should handle the literal.
EscapedThe accompanying value will be escaped before inserting into the database. This is the correct default choice to use.
UnescapedThe accompanying value will not be escaped when inserting into the database. This is potentially dangerous - use this with care.
DbSpecificThe DbSpecific constructor corresponds to the legacy PersistDbSpecific constructor. We need to keep this around because old databases may have serialized JSON representations that reference this. We don't want to break the ability of a database to load rows.
Eq LiteralTypeDefined in persistent-2.14.6.3 · Database.Persist.PersistValueOrd LiteralTypeDefined in persistent-2.14.6.3 · Database.Persist.PersistValueRead LiteralTypeDefined in persistent-2.14.6.3 · Database.Persist.PersistValueShow LiteralTypeDefined in persistent-2.14.6.3 · Database.Persist.PersistValueA 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 , known as a Pool
SqlBackendConnectionPool, 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.
PersistQueryRead SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanPersistQueryWrite SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanHasPersistBackend SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.InternalIsPersistBackend SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.InternalPersistCore SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreRead SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreWrite SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistUniqueRead SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanPersistUniqueWrite SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanBackendCompatible SqlBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBackendCompatible SqlBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBackendCompatible SqlBackend SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBounded (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEnum (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEq (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanIntegral (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanNum (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanOrd (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanRead (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanReal (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanShow (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanGeneric (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromJSON (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToJSON (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromHttpApiData (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToHttpApiData (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPathPiece (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey"
"Database.Persist.Sql.Orphan.PersistStore"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'True) (C1 ('MetaCons "SqlBackendKey"
'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype BaseBackend SqlBackend = SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.InternalRead PersistFilterDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow PersistFilterDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift PersistFilterDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseBackends supporting conditional read operations.
selectSourceRes :: (PersistRecordBackend record backend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 (Acquire (ConduitM () (Entity record) m2 ()))Get all records matching the given criterion in the specified order. Returns also the identifiers.
NOTE: This function returns an Acquire and a ConduitM, which implies
that it streams from the database. It does not. Please use selectList
to simplify the code. If you want streaming behavior, consider
persistent-pagination which efficiently chunks a query into ranges, or
investigate a backend-specific streaming solution.
selectFirst :: (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m (Maybe (Entity record))Get just the first record for the criterion.
selectKeysRes :: (MonadIO m1, MonadIO m2, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 (Acquire (ConduitM () (Key record) m2 ()))Get the Keys of all records matching the given criterion.
count :: (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m IntThe total number of records fulfilling the given criterion.
exists :: (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m BoolCheck if there is at least one record fulfilling the given criterion.
PersistQueryRead SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanPersistQueryRead SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanPersistQueryRead SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphan(HasPersistBackend b, PersistQueryRead b) => PersistQueryRead (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, BackendCompatible b s, PersistQueryRead b) => PersistQueryRead (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Typesclass (Show (BackendKey backend), Read (BackendKey backend), Eq (BackendKey backend), Ord (BackendKey backend), PersistStoreRead backend, PersistField (BackendKey backend), ToJSON (BackendKey backend), FromJSON (BackendKey backend)) => PersistStoreWrite backend whereinsert :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => record -> ReaderT backend m (Key record)Create a new record in the database, returning an automatically created key (in SQL an auto-increment id).
Using schema-1 and dataset-1, let's insert a new user John.
insertJohn :: MonadIO m => ReaderT SqlBackend m (Key User)
insertJohn = insert $ User "John" 30johnId <- insertJohnThe above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |John |30 |
+-----+------+-----+insert_ :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => record -> ReaderT backend m ()Same as insert, but doesn't return a Key.
insertJohn :: MonadIO m => ReaderT SqlBackend m (Key User)
insertJohn = insert_ $ User "John" 30The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |John |30 |
+-----+------+-----+insertMany :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => [record] -> ReaderT backend m [Key record]Create multiple records in the database and return their Keys.
If you don't need the inserted Keys, use insertMany_.
The MongoDB and PostgreSQL backends insert all records and retrieve their keys in one database query.
The SQLite and MySQL backends use the slow, default implementation of
mapM insert.
insertUsers :: MonadIO m => ReaderT SqlBackend m [Key User]
insertUsers = insertMany [User "John" 30, User "Nick" 32, User "Jane" 20]userIds <- insertUsersThe above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |John |30 |
+-----+------+-----+
|4 |Nick |32 |
+-----+------+-----+
|5 |Jane |20 |
+-----+------+-----+insertMany_ :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => [record] -> ReaderT backend m ()Same as insertMany, but doesn't return any Keys.
The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records in one database query.
insertUsers_ :: MonadIO m => ReaderT SqlBackend m ()
insertUsers_ = insertMany_ [User "John" 30, User "Nick" 32, User "Jane" 20]The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |John |30 |
+-----+------+-----+
|4 |Nick |32 |
+-----+------+-----+
|5 |Jane |20 |
+-----+------+-----+insertEntityMany :: (MonadIO m, PersistRecordBackend record backend) => [Entity record] -> ReaderT backend m ()Same as insertMany_, but takes an Entity instead of just a record.
Useful when migrating data from one entity to another and want to preserve ids.
The MongoDB, PostgreSQL, SQLite and MySQL backends insert all records in one database query.
insertUserEntityMany :: MonadIO m => ReaderT SqlBackend m ()
insertUserEntityMany = insertEntityMany [SnakeEntity, EvaEntity]The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |Snake |38 |
+-----+------+-----+
|4 |Eva |38 |
+-----+------+-----+insertKey :: (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()Create a new record in the database using the given key.
insertAliceKey :: MonadIO m => Key User -> ReaderT SqlBackend m ()
insertAliceKey key = insertKey key $ User "Alice" 20insertAliceKey $ UserKey {unUserKey = SqlBackendKey {unSqlBackendKey = 3}}The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |Alice |20 |
+-----+------+-----+repsert :: (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()Put the record in the database with the given key. Unlike replace, if a record with the given key does not exist then a new record will be inserted.
We try to explain upsertBy using schema-1 and dataset-1.
First, we insert Philip to dataset-1.
insertPhilip :: MonadIO m => ReaderT SqlBackend m (Key User)
insertPhilip = insert $ User "Philip" 42philipId <- insertPhilipThis query will produce:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |Philip|42 |
+-----+------+-----+repsertHaskell :: MonadIO m => Key record -> ReaderT SqlBackend m ()
repsertHaskell id = repsert id $ User "Haskell" 81repsertHaskell philipIdThis query will replace Philip's record with Haskell's one:
+-----+-----------------+--------+
|id |name |age |
+-----+-----------------+--------+
|1 |SPJ |40 |
+-----+-----------------+--------+
|2 |Simon |41 |
+-----+-----------------+--------+
|3 |Philip -> Haskell|42 -> 81|
+-----+-----------------+--------+repsert inserts the given record if the key doesn't exist.
repsertXToUnknown :: MonadIO m => ReaderT SqlBackend m ()
repsertXToUnknown = repsert unknownId $ User "X" 999For example, applying the above query to dataset-1 will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |X |999 |
+-----+------+-----+repsertMany :: (MonadIO m, PersistRecordBackend record backend) => [(Key record, record)] -> ReaderT backend m ()Put many entities into the database.
Batch version of repsert for SQL backends.
Useful when migrating data from one entity to another and want to preserve ids.
repsertManyUsers :: MonadIO m =>ReaderT SqlBackend m ()
repsertManyusers = repsertMany [(simonId, User "Philip" 20), (unknownId999, User "Mr. X" 999)]The above query when applied on dataset-1, will produce this:
+-----+----------------+---------+
|id |name |age |
+-----+----------------+---------+
|1 |SPJ |40 |
+-----+----------------+---------+
|2 |Simon -> Philip |41 -> 20 |
+-----+----------------+---------+
|999 |Mr. X |999 |
+-----+----------------+---------+replace :: (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()Replace the record in the database with the given key. Note that the result is undefined if such record does not exist, so you must use insertKey or repsert in these cases.
With schema-1 schama-1 and dataset-1,
replaceSpj :: MonadIO m => User -> ReaderT SqlBackend m ()
replaceSpj record = replace spjId recordThe above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |Mike |45 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+delete :: (MonadIO m, PersistRecordBackend record backend) => Key record -> ReaderT backend m ()Delete a specific record by identifier. Does nothing if record does not exist.
deleteSpj :: MonadIO m => ReaderT SqlBackend m ()
deleteSpj = delete spjIdThe above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+update :: (MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m ()Update individual fields on a specific record.
updateSpj :: MonadIO m => [Update User] -> ReaderT SqlBackend m ()
updateSpj updates = update spjId updatesupdateSpj [UserAge +=. 100]The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |140 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+updateGet :: (MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m recordUpdate individual fields on a specific record, and retrieve the updated value from the database.
Note that this function will throw an exception if the given key is not found in the database.
updateGetSpj :: MonadIO m => [Update User] -> ReaderT SqlBackend m User
updateGetSpj updates = updateGet spjId updatesspj <- updateGetSpj [UserAge +=. 100]The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |140 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+PersistStoreWrite SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreWrite SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(HasPersistBackend b, PersistStoreWrite b) => PersistStoreWrite (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, BackendCompatible b s, PersistStoreWrite b) => PersistStoreWrite (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.TypesA backwards-compatible alias for those that don't care about distinguishing between read and write queries. It signifies the assumption that, by default, a backend can write as well as read.
A backwards-compatible alias for those that don't care about distinguishing between read and write queries. It signifies the assumption that, by default, a backend can write as well as read.
A backwards-compatible alias for those that don't care about distinguishing between read and write queries. It signifies the assumption that, by default, a backend can write as well as read.
Represents a value containing all the configuration options for a specific backend. This abstraction makes it easier to write code that can easily swap backends.
type family PersistConfigBackend c :: (Type -> Type) -> Type -> Typetype family PersistConfigPool cloadConfig :: Value -> Parser cLoad the config settings from a Value, most likely taken from a YAML config file.
applyEnv :: c -> IO cModify the config settings based on environment variables.
createPoolConfig :: c -> IO (PersistConfigPool c)Create a new connection pool based on the given config settings.
runPool :: MonadUnliftIO m => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m aRun a database action by taking a connection from the pool.
PersistConfig SqliteConfDefined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistConfig c1, PersistConfig c2, PersistConfigPool c1 ~ PersistConfigPool c2, PersistConfigBackend c1 ~ PersistConfigBackend c2) => PersistConfig (Either c1 c2)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistConfigtype PersistConfigBackend SqliteConf = SqlPersistTDefined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitetype PersistConfigBackend (Either c1 c2) = PersistConfigBackend c1Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistConfigtype PersistConfigPool SqliteConf = ConnectionPoolDefined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitetype PersistConfigPool (Either c1 c2) = PersistConfigPool c1Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistConfigQuery options.
Persistent users use these directly.
forall typ. Asc (EntityField record typ)forall typ. Desc (EntityField record typ)OffsetBy IntLimitTo IntFilters which are available for select, updateWhere and
deleteWhere. Each filter constructor specifies the field being
filtered on, the type of comparison applied (equals, not equals, etc)
and the argument for the comparison.
Persistent users use combinators to create these.
Note that it's important to be careful about the PersistFilter that you are using, if you use this directly. For example, using the In PersistFilter requires that you have an array- or list-shaped EntityField. It is possible to construct values using this that will create malformed runtime values.
forall typ. PersistField typ => FilterfilterField :: EntityField record typfilterValue :: FilterValue typfilterFilter :: PersistFilterFilterAnd [Filter record]convenient for internal use, not needed for the API
FilterOr [Filter record]BackendFilter (BackendSpecificFilter (PersistEntityBackend record) record)Read PersistUpdateDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow PersistUpdateDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift PersistUpdateDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseUpdating a database entity.
Persistent users use combinators to create these.
forall typ. PersistField typ => UpdateupdateField :: EntityField record typupdateValue :: typupdateUpdate :: PersistUpdateBackendUpdate (BackendSpecificUpdate (PersistEntityBackend record) record)Datatype that represents an entity, with both its Key and its Haskell record representation.
When using a SQL-based backend (such as SQLite or
PostgreSQL), an Entity may take any number of columns
depending on how many fields it has. In order to reconstruct
your entity on the Haskell side, persistent needs all of
your entity columns and in the right order. Note that you
don't need to worry about this when using persistent's API
since everything is handled correctly behind the scenes.
However, if you want to issue a raw SQL command that returns
an Entity, then you have to be careful with the column
order. While you could use SELECT Entity.* WHERE ... and
that would work most of the time, there are times when the
order of the columns on your database is different from the
order that persistent expects (for example, if you add a new
field in the middle of you entity definition and then use the
migration code -- persistent will expect the column to be in
the middle, but your DBMS will put it as the last column).
So, instead of using a query like the one above, you may use
rawSql (from the
Database.Persist.Sql module) with its /entity
selection placeholder/ (a double question mark ??). Using
rawSql the query above must be written as SELECT ?? WHERE
... Then rawSql will replace ?? with the list of all
columns that we need from your entity in the right order. If
your query returns two entities (i.e. (Entity backend a,
Entity backend b)), then you must you use SELECT ??, ??
WHERE ..., and so on.
(Eq (Key record), Eq record) => Eq (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(Ord (Key record), Ord record) => Ord (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(Read (Key record), Read record) => Read (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(Show (Key record), Show record) => Show (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(Generic (Key record), Generic record) => Generic (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntityTypeError (EntityErrorMessage a) => SafeToInsert (Entity a)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(PersistEntity record, PersistField record, PersistField (Key record)) => PersistField (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(PersistField record, PersistEntity record) => PersistFieldSql (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(PersistEntity record, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Classtype Rep (Entity record) = D1 ('MetaData "Entity"
"Database.Persist.Class.PersistEntity"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'False) (C1 ('MetaCons "Entity"
'PrefixI 'True) (S1 ('MetaSel ('Just "entityKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Key record)) :*: S1 ('MetaSel ('Just "entityVal"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 record)))Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntityclass (PersistField (Key record), ToJSON (Key record), FromJSON (Key record), Show (Key record), Read (Key record), Eq (Key record), Ord (Key record)) => PersistEntity record wherePersistent serialized Haskell records to the database. A Database Entity (A row in SQL, a document in MongoDB, etc) corresponds to a Key plus a Haskell record.
For every Haskell record type stored in the database there is a corresponding PersistEntity instance. An instance of PersistEntity contains meta-data for the record. PersistEntity also helps abstract over different record types. That way the same query interface can return a PersistEntity, with each query returning different types of Haskell records.
Some advanced type system capabilities are used to make this process type-safe. Persistent users usually don't need to understand the class associated data and functions.
type family PersistEntityBackend recordPersistent allows multiple different backends (databases).
data family Key recordBy default, a backend will automatically generate the key Instead you can specify a Primary key made up of unique values.
data family EntityField record :: Type -> TypeAn EntityField is parameterised by the Haskell record it belongs to and the additional type of that field.
As of persistent-2.11.0.0, it's possible to use the OverloadedLabels
language extension to refer to EntityField values polymorphically. See
the documentation on SymbolToField for more information.
data family Unique recordUnique keys besides the Key.
keyToValues :: Key record -> [PersistValue]A lower-level key operation.
keyFromValues :: [PersistValue] -> Either Text (Key record)A lower-level key operation.
persistIdField :: EntityField record (Key record)A meta-operation to retrieve the Key EntityField.
entityDef :: proxy record -> EntityDefRetrieve the EntityDef meta-data for the record.
persistFieldDef :: EntityField record typ -> FieldDefReturn meta-data for a given EntityField.
toPersistFields :: record -> [PersistValue]A meta-operation to get the database fields of a record.
fromPersistValues :: [PersistValue] -> Either Text recordA lower-level operation to convert from database values to a Haskell record.
tabulateEntityA :: Applicative f => (forall a. EntityField record a -> f a) -> f (Entity record)This function allows you to build an Entity a by specifying an
action that returns a value for the field in the callback function.
Let's look at an example.
parseFromEnvironmentVariables :: IO (Entity User)
parseFromEnvironmentVariables =
tabulateEntityA $ \userField ->
case userField of
UserName ->
getEnv USER_NAME
UserAge -> do
ageVar <- getEnv USER_AGE
case readMaybe ageVar of
Just age ->
pure age
Nothing ->
error $ "Failed to parse Age from: " <> ageVar
UserAddressId -> do
addressVar <- getEnv USER_ADDRESS_ID
pure $ AddressKey addressVar
persistUniqueKeys :: record -> [Unique record]A meta operation to retrieve all the Unique keys.
persistUniqueToFieldNames :: Unique record -> NonEmpty (FieldNameHS, FieldNameDB)A lower level operation.
persistUniqueToValues :: Unique record -> [PersistValue]A lower level operation.
fieldLens :: EntityField record field -> forall (f :: Type -> Type). Functor f => (field -> f field) -> Entity record -> f (Entity record)Use a PersistField as a lens.
keyFromRecordM :: Maybe (record -> Key record)Extract a Key record from a record value. Currently, this is
only defined for entities using the Primary syntax for
natural/composite keys. In a future version of persistent which
incorporates the ID directly into the entity, this will always be Just.
An EntityField is parameterised by the Haskell record it belongs to and the additional type of that field.
As of persistent-2.11.0.0, it's possible to use the OverloadedLabels
language extension to refer to EntityField values polymorphically. See
the documentation on SymbolToField for more information.
SymbolToField sym rec typ => IsLabel sym (EntityField rec typ)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntityThis instance delegates to SymbolToField to provide
OverloadedLabels support to the EntityField type.
Value to filter with. Highly dependant on the type of filter used.
FilterValue :: typ -> FilterValue typFilterValues :: [typ] -> FilterValue typUnsafeValue :: PersistField a => a -> FilterValue typBy default, a backend will automatically generate the key Instead you can specify a Primary key made up of unique values.
(PersistEntity a, PersistEntityBackend a ~ backend, IsPersistBackend backend) => RawSql (Key a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistent allows multiple different backends (databases).
A type class which is used to witness that a type is safe to insert into the database without providing a primary key.
The TemplateHaskell function mkPersist will generate instances of this
class for any entity that it works on. If the entity has a default primary
key, then it provides a regular instance. If the entity has a Primary
natural key, then this works fine. But if the entity has an Id column with
no default=, then this does a TypeError and forces the user to use
insertKey.
TypeError (EntityErrorMessage a) => SafeToInsert (Entity a)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntityTypeError (FunctionErrorMessage a b) => SafeToInsert (a -> b)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntityThis type class is used with the OverloadedLabels extension to
provide a more convenient means of using the EntityField type.
EntityField definitions are prefixed with the type name to avoid
ambiguity, but this ambiguity can result in verbose code.
If you have a table User with a name Text field, then the
corresponding EntityField is UserName. With this, we can write
#name :: EntityField User Text.
What's more fun is that the type is more general: it's actually
#name
:: (SymbolToField "name" rec typ)
=> EntityField rec typ
Which means it is *polymorphic* over the actual record. This allows you to write code that can be generic over the tables, provided they have the right fields.
symbolToField :: EntityField rec typUnique keys besides the Key.
Predefined parseJSON. The input JSON looks like
{"id": 1, "name": ...}.
The typical usage is:
instance FromJSON (Entity User) where
parseJSON = entityIdFromJSON
Predefined toJSON. The resulting JSON looks like
{"id": 1, "name": ...}.
The typical usage is:
instance ToJSON (Entity User) where
toJSON = entityIdToJSON
Get list of values corresponding to given entity.
Convenience function for getting a free PersistField instance from a type with JSON instances. The JSON parser used will accept JSON values other that object and arrays. So, if your instance serializes the data to a JSON string, this will still work.
Example usage in combination with toPersistValueJSON:
instance PersistField MyData where
fromPersistValue = fromPersistValueJSON
toPersistValue = toPersistValueJSON
Predefined parseJSON. The input JSON looks like
{"key": 1, "value": {"name": ...}}.
The typical usage is:
instance FromJSON (Entity User) where
parseJSON = keyValueEntityFromJSON
Predefined toJSON. The resulting JSON looks like
{"key": 1, "value": {"name": ...}}.
The typical usage is:
instance ToJSON (Entity User) where
toJSON = keyValueEntityToJSON
Construct an Entity record by providing a value for each of the
record's fields.
These constructions are equivalent:
entityMattConstructor, entityMattTabulate :: Entity User
entityMattConstructor =
Entity
{ entityKey = toSqlKey 123
, entityVal =
User
{ userName = Matt
, userAge = 33
}
}
entityMattTabulate =
tabulateEntity $ \case
UserId ->
toSqlKey 123
UserName ->
Matt
UserAge ->
33
This is a specialization of tabulateEntityA, which allows you to construct an Entity by providing an Applicative action for each field instead of a regular function.
Convenience function for getting a free PersistField instance from a type with JSON instances.
Example usage in combination with fromPersistValueJSON:
instance PersistField MyData where
fromPersistValue = fromPersistValueJSON
toPersistValue = toPersistValueJSON
Prior to persistent-2.11.0, we provided an instance of
PersistField for the Natural type. This was in error, because
Natural represents an infinite value, and databases don't have
reasonable types for this.
The instance for Natural used the Int64 underlying type, which will cause underflow and overflow errors. This type has the exact same code in the instances, and will work seamlessly.
A more appropriate type for this is the Word series of types from Data.Word. These have a bounded size, are guaranteed to be non-negative, and are quite efficient for the database to store.
Eq OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldNum OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldOrd OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldShow OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistFieldSql OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassThis type uses the SqlInt64 version, which will exhibit overflow and underflow behavior. Additionally, it permits negative values in the database, which isn't ideal.
This class teaches Persistent how to take a custom type and marshal it to and from a PersistValue, allowing it to be stored in a database.
You can use newtype to add more type safety/readability to a basis type like ByteString. In these cases, just derive PersistField and PersistFieldSql:
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
newtype HashedPassword = HashedPassword ByteString
deriving (Eq, Show, PersistField, PersistFieldSql)
In this example, we create a PersistField instance for a newtype following the "Smart Constructor" pattern.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import qualified Data.Text as T
import qualified Data.Char as C
-- | An American Social Security Number
newtype SSN = SSN Text
deriving (Eq, Show, PersistFieldSql)
mkSSN :: Text -> Either Text SSN
mkSSN t = if (T.length t == 9) && (T.all C.isDigit t)
then Right $ SSN t
else Left $ "Invalid SSN: " <> t
instance PersistField SSN where
toPersistValue (SSN t) = PersistText t
fromPersistValue (PersistText t) = mkSSN t
-- Handle cases where the database does not give us PersistText
fromPersistValue x = Left $ "File.hs: When trying to deserialize an SSN: expected PersistText, received: " <> T.pack (show x)
Tips:
This file contain dozens of PersistField instances you can look at for examples.
Typically custom PersistField instances will only accept a single PersistValue constructor in fromPersistValue.
Internal PersistField instances accept a wide variety of PersistValues to accomodate e.g. storing booleans as integers, booleans or strings.
If you're making a custom instance and using a SQL database, you'll also need PersistFieldSql to specify the type of the database column.
toPersistValue :: a -> PersistValuefromPersistValue :: PersistValue -> Either Text aTypeError ((((('Text "The instance of PersistField for the Natural type was removed."
':$$: 'Text "Please see the documentation for OverflowNatural if you want to "
) ':$$: 'Text "continue using the old behavior or want to see documentation on "
) ':$$: 'Text "why the instance was removed."
) ':$$: 'Text ""
) ':$$: 'Text "This error instance will be removed in a future release."
) => PersistField NaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField HtmlDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField ByteStringDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Int16Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Int32Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Int64Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Int8Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField RationalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Word16Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Word32Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Word64Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField Word8Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField BoolDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField DoubleDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField IntDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField WordDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField PersistValueDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField TextDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField TextDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField DayDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField UTCTimeDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField TimeOfDayDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField [Char]Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField a => PersistField (Maybe a)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField a => PersistField (Vector a)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField a => PersistField [a]Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField v => PersistField (IntMap v)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistField(Ord a, PersistField a) => PersistField (Set a)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistField(PersistEntity record, PersistField record, PersistField (Key record)) => PersistField (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistEntity(BackendCompatible b s, PersistField (BackendKey b)) => PersistField (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), PersistField (BackendKey b)) => PersistField (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteHasResolution a => PersistField (Fixed a)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistField v => PersistField (Map Text v)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistField(PersistField a, PersistField b) => PersistField (a, b)Defined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldFIXME Add documentation to that.
class (PersistQueryRead backend, PersistStoreWrite backend) => PersistQueryWrite backend whereBackends supporting conditional write operations
updateWhere :: (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [Update record] -> ReaderT backend m ()Update individual fields on any record matching the given criterion.
deleteWhere :: (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m ()Delete all records matching the given criterion.
PersistQueryWrite SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanPersistQueryWrite SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphan(HasPersistBackend b, PersistQueryWrite b) => PersistQueryWrite (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, BackendCompatible b s, PersistQueryWrite b) => PersistQueryWrite (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.TypesGet the Keys of all records matching the given criterion.
For an example, see selectList.
Call selectKeys but return the result as a list.
Returns a [Entity record] corresponding to the filters and options
provided.
Filters are constructed using the operators defined in Database.Persist (and re-exported from Database.Persist.Sql). Let's look at some examples:
usersWithAgeOver40 :: SqlPersistT IO [Entity User]
usersWithAgeOver40 =
selectList [UserAge >=. 40] []
If you provide multiple values in the list, the conditions are ANDed
together.
usersWithAgeBetween30And50 :: SqlPersistT IO [Entity User]
usersWithAgeBetween30And50 =
selectList
[ UserAge >=. 30
, UserAge <=. 50
]
[]
The second list contains the SelectOpt for a record. We can select the first ten records with LimitTo
firstTenUsers =
selectList [] [LimitTo 10]
And we can select the second ten users with OffsetBy.
secondTenUsers =
selectList [] [LimitTo 10, OffsetBy 10]
Warning that LIMIT/OFFSET is bad for pagination!
The type of record can usually be infered from the types of the provided filters and select options. In the previous two examples, though, you'll notice that the select options are polymorphic, applying to any record type. In order to help type inference in such situations, or simply as an enhancement to readability, you might find type application useful, illustrated below.
{-# LANGUAGE TypeApplications #-}
...
firstTenUsers =
selectList User [] [LimitTo 10]
secondTenUsers =
selectList User [] [LimitTo 10, OffsetBy 10]
With Asc and Desc, we can provide the field we want to sort on. We can provide multiple sort orders - later ones are used to sort records that are equal on the first field.
newestUsers =
selectList [] [Desc UserCreatedAt, LimitTo 10]
oldestUsers =
selectList [] [Asc UserCreatedAt, LimitTo 10]
Get all records matching the given criterion in the specified order. Returns also the identifiers.
WARNING: This function returns a ConduitM, which suggests that it streams
the results. It does not stream results on most backends. If you need
streaming, see persistent-pagination for a means of chunking results based
on indexed ranges.
This class witnesses that two backend are compatible, and that you can
convert from the sub backend into the sup backend. This is similar
to the HasPersistBackend and IsPersistBackend classes, but where you
don't want to fix the type associated with the PersistEntityBackend of
a record.
Generally speaking, where you might have:
foo ::
( PersistEntity record
, PersistEntityBackend record ~ BaseBackend backend
, IsSqlBackend backend
)
this can be replaced with:
foo ::
( PersistEntity record,
, PersistEntityBackend record ~ backend
, BackendCompatible SqlBackend backend
)
This works for SqlReadBackend because of the instance BackendCompatible , without needing to go through the BaseBackend type family.SqlBackend SqlReadBackend
Likewise, functions that are currently hardcoded to use SqlBackend can be generalized:
-- before:
asdf :: ReaderT SqlBackend m ()
asdf = pure ()
-- after:
asdf' :: BackendCompatible SqlBackend backend => ReaderT backend m ()
asdf' = withCompatibleBackend asdf
projectBackend :: sub -> supBackendCompatible SqlBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBackendCompatible SqlBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBackendCompatible SqlBackend SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBackendCompatible b (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitedata family BackendKey backendPersistCore SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistCore SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistCore SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistCore b => PersistCore (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(BackendCompatible b s, PersistCore b) => PersistCore (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.TypesBounded (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBounded (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBounded (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Bounded (BackendKey b)) => Bounded (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Bounded (BackendKey b)) => Bounded (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteEnum (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEnum (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEnum (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Enum (BackendKey b)) => Enum (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Enum (BackendKey b)) => Enum (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteEq (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEq (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEq (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Eq (BackendKey b)) => Eq (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Eq (BackendKey b)) => Eq (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteIntegral (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanIntegral (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanIntegral (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Integral (BackendKey b)) => Integral (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Integral (BackendKey b)) => Integral (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteNum (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanNum (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanNum (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Num (BackendKey b)) => Num (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Num (BackendKey b)) => Num (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteOrd (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanOrd (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanOrd (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Ord (BackendKey b)) => Ord (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Ord (BackendKey b)) => Ord (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteRead (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanRead (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanRead (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Read (BackendKey b)) => Read (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Read (BackendKey b)) => Read (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteReal (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanReal (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanReal (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Real (BackendKey b)) => Real (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Real (BackendKey b)) => Real (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteShow (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanShow (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanShow (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, Show (BackendKey b)) => Show (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), Show (BackendKey b)) => Show (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteGeneric (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanGeneric (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanGeneric (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromJSON (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromJSON (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromJSON (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, FromJSON (BackendKey b)) => FromJSON (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), FromJSON (BackendKey b)) => FromJSON (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteToJSON (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToJSON (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToJSON (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, ToJSON (BackendKey b)) => ToJSON (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), ToJSON (BackendKey b)) => ToJSON (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteFromHttpApiData (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromHttpApiData (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromHttpApiData (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToHttpApiData (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToHttpApiData (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToHttpApiData (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPathPiece (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPathPiece (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPathPiece (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, PersistField (BackendKey b)) => PersistField (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), PersistField (BackendKey b)) => PersistField (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqlitePersistFieldSql (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(BackendCompatible b s, PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitetype Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey"
"Database.Persist.Sql.Orphan.PersistStore"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'True) (C1 ('MetaCons "SqlReadBackendKey"
'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey"
"Database.Persist.Sql.Orphan.PersistStore"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'True) (C1 ('MetaCons "SqlWriteBackendKey"
'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey"
"Database.Persist.Sql.Orphan.PersistStore"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'True) (C1 ('MetaCons "SqlBackendKey"
'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey (Compatible b s)CompatibleKeyunCompatibleKey :: BackendKey bdata BackendKey (RawSqlite b)RawSqliteKeyunRawSqliteKey :: BackendKey (Compatible b (RawSqlite b))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
type family BaseBackend backendpersistBackend :: backend -> BaseBackend backendHasPersistBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalHasPersistBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalHasPersistBackend SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.InternalHasPersistBackend b => HasPersistBackend (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(BackendCompatible b s, HasPersistBackend b) => HasPersistBackend (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Typestype BaseBackend SqlReadBackend = SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.Internaltype BaseBackend SqlWriteBackend = SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.Internaltype BaseBackend SqlBackend = SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internaltype BaseBackend (Compatible b s) = BaseBackend bDefined in persistent-2.14.6.3 · Database.Persist.Compatible.Typestype BaseBackend (RawSqlite b0) = BaseBackend (Compatible b0 (RawSqlite b0))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteClass 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.
IsPersistBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalIsPersistBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalIsPersistBackend SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internaltype PersistRecordBackend record backend = (PersistEntity record, PersistEntityBackend record ~ BaseBackend backend)A convenient alias for common type signatures
class (Show (BackendKey backend), Read (BackendKey backend), Eq (BackendKey backend), Ord (BackendKey backend), PersistCore backend, PersistField (BackendKey backend), ToJSON (BackendKey backend), FromJSON (BackendKey backend)) => PersistStoreRead backend whereget :: (MonadIO m, PersistRecordBackend record backend) => Key record -> ReaderT backend m (Maybe record)Get a record by identifier, if available.
getSpj :: MonadIO m => ReaderT SqlBackend m (Maybe User)
getSpj = get spjIdmspj <- getSpjThe above query when applied on dataset-1, will get this:
+------+-----+
| name | age |
+------+-----+
| SPJ | 40 |
+------+-----+getMany :: (MonadIO m, PersistRecordBackend record backend) => [Key record] -> ReaderT backend m (Map (Key record) record)Get many records by their respective identifiers, if available.
getUsers :: MonadIO m => ReaderT SqlBackend m (Map (Key User) User)
getUsers = getMany allkeysmusers <- getUsersThe above query when applied on dataset-1, will get these records:
+----+-------+-----+
| id | name | age |
+----+-------+-----+
| 1 | SPJ | 40 |
+----+-------+-----+
| 2 | Simon | 41 |
+----+-------+-----+PersistStoreRead SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreRead SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreRead SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphan(HasPersistBackend b, PersistStoreRead b) => PersistStoreRead (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, BackendCompatible b s, PersistStoreRead b) => PersistStoreRead (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Typesclass (PersistEntity record, PersistEntityBackend record ~ backend, PersistCore backend) => ToBackendKey backend record whereToBackendKey converts a PersistEntity Key into a BackendKey
This can be used by each backend to convert between a Key and a plain
Haskell type. For Sql, that is done with toSqlKey and fromSqlKey.
By default, a PersistEntity uses the default BackendKey for its Key and is an instance of ToBackendKey
A Key that instead uses a custom type will not be an instance of ToBackendKey.
toBackendKey :: Key record -> BackendKey backendfromBackendKey :: BackendKey backend -> Key recordCurry this to make a convenience function that loads an associated model.
foreign = belongsTo foreignIdSame as belongsTo, but uses getJust and therefore is similarly unsafe.
Like get, but returns the complete Entity.
getSpjEntity :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User))
getSpjEntity = getEntity spjIdmSpjEnt <- getSpjEntityThe above query when applied on dataset-1, will get this entity:
+----+------+-----+
| id | name | age |
+----+------+-----+
| 1 | SPJ | 40 |
+----+------+-----+Same as get, but for a non-null (not Maybe) foreign key. Unsafe unless your database is enforcing that the foreign key is valid.
getJustSpj :: MonadIO m => ReaderT SqlBackend m User
getJustSpj = getJust spjIdspj <- getJust spjIdThe above query when applied on dataset-1, will get this record:
+----+------+-----+
| id | name | age |
+----+------+-----+
| 1 | SPJ | 40 |
+----+------+-----+getJustUnknown :: MonadIO m => ReaderT SqlBackend m User
getJustUnknown = getJust unknownIdmrx <- getJustUnknown
This just throws an error.
Same as getJust, but returns an Entity instead of just the record.
getJustEntitySpj :: MonadIO m => ReaderT SqlBackend m (Entity User)
getJustEntitySpj = getJustEntity spjIdspjEnt <- getJustEntitySpjThe above query when applied on dataset-1, will get this entity:
+----+------+-----+
| id | name | age |
+----+------+-----+
| 1 | SPJ | 40 |
+----+------+-----+Like insert, but returns the complete Entity.
insertHaskellEntity :: MonadIO m => ReaderT SqlBackend m (Entity User)
insertHaskellEntity = insertEntity $ User "Haskell" 81haskellEnt <- insertHaskellEntityThe above query when applied on dataset-1, will produce this:
+----+---------+-----+
| id | name | age |
+----+---------+-----+
| 1 | SPJ | 40 |
+----+---------+-----+
| 2 | Simon | 41 |
+----+---------+-----+
| 3 | Haskell | 81 |
+----+---------+-----+Like insertEntity but just returns the record instead of Entity.
insertDaveRecord :: MonadIO m => ReaderT SqlBackend m User
insertDaveRecord = insertRecord $ User "Dave" 50dave <- insertDaveRecordThe above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |Dave |50 |
+-----+------+-----+Run a query against a larger backend by plucking out BaseBackend backend
This is a helper for reusing existing queries when expanding the backend type.
Run a query against a compatible backend, by projecting the backend
This is a helper for using queries which run against a specific backend type that your backend is compatible with.
This class is used to ensure that functions requring at least one
unique key are not called with records that have 0 unique keys. The
quasiquoter automatically writes working instances for appropriate
entities, and generates TypeError instances for records that have
0 unique keys.
requireUniquesP :: record -> NonEmpty (Unique record)type MultipleUniqueKeysError ty = ((('Text "The entity "
':<>: 'ShowType ty) ':<>: 'Text " has multiple unique keys."
) ':$$: ('Text "The function you are trying to call requires only a single "
':<>: 'Text "unique key."
)) ':$$: (('Text "There is probably a variant of the function with 'By' "
':<>: 'Text "appended that will allow you to select a unique key "
) ':<>: 'Text "for the operation."
)This is an error message. It is used when an entity has multiple unique keys, and the function expects a single unique key.
type NoUniqueKeysError ty = (('Text "The entity "
':<>: 'ShowType ty) ':<>: 'Text " does not have any unique keys."
) ':$$: ('Text "The function you are trying to call requires a unique key "
':<>: 'Text "to be defined on the entity."
)This is an error message. It is used when writing instances of OnlyOneUniqueKey for an entity that has no unique keys.
This class is used to ensure that upsert is only called on records
that have a single Unique key. The quasiquoter automatically generates
working instances for appropriate records, and generates TypeError
instances for records that have 0 or multiple unique keys.
onlyUniqueP :: record -> Unique recordQueries against Unique keys (other than the id Key).
Please read the general Persistent documentation to learn how to create Unique keys.
Using this with an Entity without a Unique key leads to undefined behavior. A few of these functions require a single Unique, so using an Entity with multiple Uniques is also undefined. In these cases persistent's goal is to throw an exception as soon as possible, but persistent is still transitioning to that.
SQL backends automatically create uniqueness constraints, but for MongoDB you must manually place a unique index on a field to have a uniqueness constraint.
getBy :: (MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m (Maybe (Entity record))Get a record by unique key, if available. Returns also the identifier.
getBySpjName :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User))
getBySpjName = getBy $ UniqueUserName "SPJ"mSpjEnt <- getBySpjNameThe above query when applied on dataset-1, will get this entity:
+----+------+-----+
| id | name | age |
+----+------+-----+
| 1 | SPJ | 40 |
+----+------+-----+existsBy :: (MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m BoolReturns True if a record with this unique key exists, otherwise False.
existsBySpjName :: MonadIO m => ReaderT SqlBackend m Bool
existsBySpjName = existsBy $ UniqueUserName "SPJ"spjEntExists <- existsBySpjNameThe above query when applied on dataset-1, will return the value True.
PersistUniqueRead SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanPersistUniqueRead SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanPersistUniqueRead SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphan(HasPersistBackend b, PersistUniqueRead b) => PersistUniqueRead (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, BackendCompatible b s, PersistUniqueRead b) => PersistUniqueRead (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Typesclass (PersistUniqueRead backend, PersistStoreWrite backend) => PersistUniqueWrite backend whereSome functions in this module (insertUnique, insertBy, and replaceUnique) first query the unique indexes to check for conflicts. You could instead optimistically attempt to perform the operation (e.g. replace instead of replaceUnique). However,
there is some fragility to trying to catch the correct exception and determing the column of failure;
an exception will automatically abort the current SQL transaction.
deleteBy :: (MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m ()Delete a specific record by unique key. Does nothing if no record matches.
deleteBySpjName :: MonadIO m => ReaderT SqlBackend m ()
deleteBySpjName = deleteBy UniqueUserName "SPJ"The above query when applied on dataset-1, will produce this:
+-----+------+-----+
|id |name |age |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+insertUnique :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => record -> ReaderT backend m (Maybe (Key record))Like insert, but returns Nothing when the record couldn't be inserted because of a uniqueness constraint.
With schema-1 and dataset-1, we try to insert the following two records:
linusId <- insertUnique $ User "Linus" 48
spjId <- insertUnique $ User "SPJ" 90+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |Linus |48 |
+-----+------+-----+Linus's record was inserted to dataset-1, while SPJ wasn't because SPJ already exists in dataset-1.
insertUnique_ :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => record -> ReaderT backend m (Maybe ())Same as insertUnique but doesn't return a Key.
With schema-1 and dataset-1, we try to insert the following two records:
linusId <- insertUnique_ $ User "Linus" 48
spjId <- insertUnique_ $ User "SPJ" 90+-----+------+-----+
|id |name |age |
+-----+------+-----+
|1 |SPJ |40 |
+-----+------+-----+
|2 |Simon |41 |
+-----+------+-----+
|3 |Linus |48 |
+-----+------+-----+Linus's record was inserted to dataset-1, while SPJ wasn't because SPJ already exists in dataset-1.
upsert :: (MonadIO m, PersistRecordBackend record backend, OnlyOneUniqueKey record, SafeToInsert record) => record -> [Update record] -> ReaderT backend m (Entity record)Update based on a uniqueness constraint or insert:
insert the new record if it does not exist;
If the record exists (matched via it's uniqueness constraint), then update the existing record with the parameters which is passed on as list to the function.
First, we try to explain upsert using schema-1 and dataset-1.
upsertSpj :: MonadIO m => [Update User] -> ReaderT SqlBackend m (Maybe (Entity User))
upsertSpj updates = upsert (User "SPJ" 999) updatesmSpjEnt <- upsertSpj [UserAge +=. 15]The above query when applied on dataset-1, will produce this:
+-----+-----+--------+
|id |name |age |
+-----+-----+--------+
|1 |SPJ |40 -> 55|
+-----+-----+--------+
|2 |Simon|41 |
+-----+-----+--------+upsertX :: MonadIO m => [Update User] -> ReaderT SqlBackend m (Maybe (Entity User))
upsertX updates = upsert (User "X" 999) updatesmXEnt <- upsertX [UserAge +=. 15]The above query when applied on dataset-1, will produce this:
+-----+-----+--------+
|id |name |age |
+-----+-----+--------+
|1 |SPJ |40 |
+-----+-----+--------+
|2 |Simon|41 |
+-----+-----+--------+
|3 |X |999 |
+-----+-----+--------+Next, what if the schema has two uniqueness constraints? Let's check it out using schema-2:
mSpjEnt <- upsertSpj [UserAge +=. 15]This fails with a compile-time type error alerting us to the fact that this record has multiple unique keys, and suggests that we look for upsertBy to select the unique key we want.
upsertBy :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => Unique record -> record -> [Update record] -> ReaderT backend m (Entity record)Update based on a given uniqueness constraint or insert:
insert the new record if it does not exist;
update the existing record that matches the given uniqueness constraint.
We try to explain upsertBy using schema-2 and dataset-1.
upsertBySpjName :: MonadIO m => User -> [Update User] -> ReaderT SqlBackend m (Entity User)
upsertBySpjName record updates = upsertBy (UniqueUserName "SPJ") record updatesmSpjEnt <- upsertBySpjName (Person "X" 999) [PersonAge += .15]The above query will alter dataset-1 to:
+-----+-----+--------+
|id |name |age |
+-----+-----+--------+
|1 |SPJ |40 -> 55|
+-----+-----+--------+
|2 |Simon|41 |
+-----+-----+--------+upsertBySimonAge :: MonadIO m => User -> [Update User] -> ReaderT SqlBackend m (Entity User)
upsertBySimonAge record updates = upsertBy (UniqueUserName "SPJ") record updatesmPhilipEnt <- upsertBySimonAge (User "X" 999) [UserName =. "Philip"]The above query will alter dataset-1 to:
+----+-----------------+-----+
| id | name | age |
+----+-----------------+-----+
| 1 | SPJ | 40 |
+----+-----------------+-----+
| 2 | Simon -> Philip | 41 |
+----+-----------------+-----+upsertByUnknownName :: MonadIO m => User -> [Update User] -> ReaderT SqlBackend m (Entity User)
upsertByUnknownName record updates = upsertBy (UniqueUserName "Unknown") record updatesmXEnt <- upsertByUnknownName (User "X" 999) [UserAge +=. 15]This query will alter dataset-1 to:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|1 |SPJ |40 |
+-----+-----+-----+
|2 |Simon|41 |
+-----+-----+-----+
|3 |X |999 |
+-----+-----+-----+putMany :: (MonadIO m, PersistRecordBackend record backend, SafeToInsert record) => [record] -> ReaderT backend m ()Put many records into db
insert new records that do not exist (or violate any unique constraints)
replace existing records (matching any unique constraint)
PersistUniqueWrite SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanPersistUniqueWrite SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphan(HasPersistBackend b, PersistUniqueWrite b) => PersistUniqueWrite (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, BackendCompatible b s, PersistUniqueWrite b) => PersistUniqueWrite (Compatible b s)Defined in persistent-2.14.6.3 · Database.Persist.Compatible.TypesCheck whether there are any conflicts for unique keys with this entity and existing entities in the database.
Returns Nothing if the entity would be unique, and could thus safely be inserted. on a conflict returns the conflicting key
We use schema-1 and dataset-1 here.
This would be Nothing:
mAlanConst <- checkUnique $ User "Alan" 70While this would be Just because SPJ already exists:
mSpjConst <- checkUnique $ User "SPJ" 60Check whether there are any conflicts for unique keys with this entity and existing entities in the database.
Returns Nothing if the entity would stay unique, and could thus safely be updated. on a conflict returns the conflicting key
This is similar to checkUnique, except it's useful for updating - when the particular entity already exists, it would normally conflict with itself. This variant ignores those conflicts
We use schema-1 and dataset-1 here.
This would be Nothing:
mAlanConst <- checkUnique $ User "Alan" 70While this would be Just because SPJ already exists:
mSpjConst <- checkUnique $ User "SPJ" 60A modification of getBy, which takes the PersistEntity itself instead of a Unique record. Returns a record matching one of the unique keys. This function makes the most sense on entities with a single Unique constructor.
getBySpjValue :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User))
getBySpjValue = getByValue $ User SPJ 999
mSpjEnt <- getBySpjValueThe above query when applied on dataset-1, will get this record:
+----+------+-----+
| id | name | age |
+----+------+-----+
| 1 | SPJ | 40 |
+----+------+-----+Insert a value, checking for conflicts with any unique constraints. If a duplicate exists in the database, it is returned as Left. Otherwise, the new 'Key is returned as Right.
With schema-2 and dataset-1, we have following lines of code:
l1 <- insertBy $ User "SPJ" 20
l2 <- insertBy $ User "XXX" 41
l3 <- insertBy $ User "SPJ" 40
r1 <- insertBy $ User "XXX" 100First three lines return Left because there're duplicates in given record's uniqueness constraints. While the last line returns a new key as Right.
Like insertEntity, but returns Nothing when the record couldn't be inserted because of a uniqueness constraint.
We use schema-2 and dataset-1 here.
insertUniqueSpjEntity :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User))
insertUniqueSpjEntity = insertUniqueEntity $ User "SPJ" 50mSpjEnt <- insertUniqueSpjEntityThe above query results Nothing as SPJ already exists.
insertUniqueAlexaEntity :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User))
insertUniqueAlexaEntity = insertUniqueEntity $ User "Alexa" 3mAlexaEnt <- insertUniqueSpjEntityBecause there's no such unique keywords of the given record, the above query when applied on dataset-1, will produce this:
+----+-------+-----+
| id | name | age |
+----+-------+-----+
| 1 | SPJ | 40 |
+----+-------+-----+
| 2 | Simon | 41 |
+----+-------+-----+
| 3 | Alexa | 3 |
+----+-------+-----+Given a proxy for a PersistEntity record, this returns the sole UniqueDef for that entity.
Return the single unique key for a record.
We use shcema-1 and dataset-1 here.
onlySimonConst :: MonadIO m => ReaderT SqlBackend m (Unique User)
onlySimonConst = onlyUnique $ User "Simon" 999mSimonConst <- onlySimonConstmSimonConst would be Simon's uniqueness constraint. Note that
onlyUnique doesn't work if there're more than two constraints. It will
fail with a type error instead.
Return the database name for the given entity.
Retrieve the list of FieldDef that makes up the fields of the entity.
This does not return the fields for an Id column or an implicit id. It
will return the key columns if you used the Primary syntax for defining the
primary key.
This does not return fields that are marked SafeToRemove or MigrationOnly
- so it only returns fields that are represented in the Haskell type. If you
need those fields, use getEntityFieldsDatabase.
This returns all of the FieldDef defined for the EntityDef, including
those fields that are marked as MigrationOnly (and therefore only present
in the database) or SafeToRemove (and a migration will drop the column if
it exists in the database).
For all the fields that are present on the Haskell-type, see getEntityFields.
Retrieve the Haskell name of the given entity.
Retrieve the list of UniqueDef from an EntityDef. As of version 2.14, this will also include the primary key on the entity, if one is defined. If you do not want the primary key, see getEntityUniquesNoPrimaryKey.
Perform a mapping function over all of the entity fields, as determined by getEntityFieldsDatabase.
Add an attribute to the list of field attributes.
Check if the field is `Maybe a`
Check if the field definition is nullable
Modify the list of field attributes.
A ConstraintNameDB represents the datastore-side name that persistent
will use for a constraint.
Eq ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesOrd ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesRead ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesShow ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesDatabaseName ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesLift ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesAn ConstraintNameHS represents the Haskell-side name that persistent
will use for a constraint.
Eq ConstraintNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesOrd ConstraintNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesRead ConstraintNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesShow ConstraintNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesLift ConstraintNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesConvenience operations for working with '-NameDB' types.
escapeWith :: (Text -> str) -> a -> strDatabaseName ConstraintNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesDatabaseName EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesDatabaseName FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesAn EntityNameDB represents the datastore-side name that persistent
will use for an entity.
Eq EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesOrd EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesRead EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesShow EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesDatabaseName EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesLift EntityNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesAn EntityNameHS represents the Haskell-side name that persistent
will use for an entity.
Eq EntityNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesOrd EntityNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesRead EntityNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesShow EntityNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesLift EntityNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesA FieldNameDB represents the datastore-side name that persistent
will use for a field.
Eq FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesOrd FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesRead FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesShow FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesDatabaseName FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesLift FieldNameDBDefined in persistent-2.14.6.3 · Database.Persist.NamesA FieldNameHS represents the Haskell-side name that persistent
will use for a field.
Eq FieldNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesOrd FieldNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesRead FieldNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesShow FieldNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesLift FieldNameHSDefined in persistent-2.14.6.3 · Database.Persist.NamesA Checkmark should be used as a field type whenever a uniqueness constraint should guarantee that a certain kind of record may appear at most once, but other kinds of records may appear any number of times.
NOTE: You need to mark any Checkmark fields as nullable
(see the following example).
For example, suppose there's a Location entity that
represents where a user has lived:
Location
user UserId
name Text
current Checkmark nullable
UniqueLocation user current
The UniqueLocation constraint allows any number of
Inactive Locations to be current. However, there may be
at most one current Location per user (i.e., either zero
or one per user).
This data type works because of the way that SQL treats
NULLable fields within uniqueness constraints. The SQL
standard says that NULL values should be considered
different, so we represent Inactive as SQL NULL, thus
allowing any number of Inactive records. On the other hand,
we represent Active as TRUE, so the uniqueness constraint
will disallow more than one Active record.
Note: There may be DBMSs that do not respect the SQL
standard's treatment of NULL values on uniqueness
constraints, please check if this data type works before
relying on it.
The SQL BOOLEAN type is used because it's the smallest data
type available. Note that we never use FALSE, just TRUE
and NULL. Provides the same behavior Maybe () would if
() was a valid PersistField.
Bounded CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseEnum CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseEq CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseFromHttpApiData CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseToHttpApiData CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BasePathPiece CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Types.BasePersistField CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Class.PersistFieldPersistFieldSql CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassThe reason why a field is nullable is very important. A
field that is nullable because of a Maybe tag will have its
type changed from A to Maybe A. OTOH, a field that is
nullable because of a nullable tag will remain with the same
type.
Eq WhyNullableDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow WhyNullableDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseAn action that might happen on a deletion or update on a foreign key change.
Eq CascadeActionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd CascadeActionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead CascadeActionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow CascadeActionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift CascadeActionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseEq CompositeDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd CompositeDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead CompositeDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow CompositeDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift CompositeDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseAn EmbedEntityDef is the same as an EntityDef But it is only used for fieldReference so it only has data needed for embedding
Eq EmbedEntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd EmbedEntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead EmbedEntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow EmbedEntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift EmbedEntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseAn EmbedFieldDef is the same as a FieldDef But it is only used for embeddedFields so it only has data needed for embedding
EmbedFieldDefemFieldDB :: FieldNameDBemFieldEmbed :: Maybe (Either SelfEmbed EntityNameHS)Eq EmbedFieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd EmbedFieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead EmbedFieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow EmbedFieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift EmbedFieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseThere are 3 kinds of references 1) composite (to fields that exist in the record) 2) single field 3) embedded
NoReferenceForeignRef !EntityNameHSA ForeignRef has a late binding to the EntityDef it references via name and has the Haskell type of the foreign key in the form of FieldType
EmbedRef EntityNameHSSelfReferenceA SelfReference stops an immediate cycle which causes non-termination at compile-time (issue #311).
Eq ReferenceDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd ReferenceDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead ReferenceDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow ReferenceDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift ReferenceDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseAn EntityDef represents the information that persistent knows
about an Entity. It uses this information to generate the Haskell
datatype, the SQL migrations, and other relevant conversions.
Eq EntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd EntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead EntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow EntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift EntityDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseThe definition for the entity's primary key ID.
EntityIdField !FieldDefThe entity has a single key column, and it is a surrogate key - that
is, you can't go from rec -> Key rec.
EntityIdNaturalKey !CompositeDefThe entity has a natural key. This means you can write rec -> Key rec
because all the key fields are present on the datatype.
A natural key can have one or more columns.
Eq EntityIdDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd EntityIdDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead EntityIdDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow EntityIdDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift EntityIdDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseA FieldType describes a field parsed from the QuasiQuoter and is used to determine the Haskell type in the generated code.
name Text parses into FTTypeCon Nothing Text
name T.Text parses into FTTypeCon (Just T Text)
name (Jsonb User) parses into:
FTApp (FTTypeCon Nothing Jsonb) (FTTypeCon Nothing User)
Eq FieldTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd FieldTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead FieldTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow FieldTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift FieldTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseAttributes that may be attached to fields that can affect migrations and serialization in backend-specific ways.
While we endeavor to, we can't forsee all use cases for all backends, and so FieldAttr is extensible through its constructor FieldAttrOther.
FieldAttrMaybeFieldAttrNullableThis indicates that the column is nullable, but should not have
a Maybe type. For this to work out, you need to ensure that the
PersistField instance for the type in question can support
a PersistNull value.
data What = NoWhat | Hello Text
instance PersistField What where
fromPersistValue PersistNull =
pure NoWhat
fromPersistValue pv =
Hello $ fromPersistValue pv
instance PersistFieldSql What where
sqlType _ = SqlString
User
what What nullable
FieldAttrMigrationOnlyThis tag means that the column will not be present on the Haskell code, but will not be removed from the database. Useful to deprecate fields in phases.
You should set the column to be nullable in the database. Otherwise, inserts won't have values.
User
oldName Text MigrationOnly
newName Text
FieldAttrSafeToRemoveA SafeToRemove attribute is not present on the Haskell datatype, and
the backend migrations should attempt to drop the column without
triggering any unsafe migration warnings.
Useful after you've used MigrationOnly to remove a column from the
database in phases.
User
oldName Text SafeToRemove
newName Text
FieldAttrNoreferenceThis attribute indicates that we should not create a foreign key
reference from a column. By default, persistent will try and create a
foreign key reference for a column if it can determine that the type of
the column is a or an Key entityEntityId and the Entity's name
was present in mkPersist.
This is useful if you want to use the explicit foreign key syntax.
Post
title Text
Comment
postId PostId noreference
Foreign Post fk_comment_post postId
FieldAttrReference TextThis is set to specify precisely the database table the column refers to.
Post
title Text
Comment
postId PostId references="post"
You should not need this - persistent should be capable of correctly
determining the target table's name. If you do need this, please file an
issue describing why.
FieldAttrConstraint TextSpecify a name for the constraint on the foreign key reference for this table.
Post
title Text
Comment
postId PostId constraint="my_cool_constraint_name"
FieldAttrDefault TextSpecify the default value for a column.
User
createdAt UTCTime default="NOW()"
Note that a default= attribute does not mean you can omit the value
while inserting.
FieldAttrSqltype TextSpecify a custom SQL type for the column. Generally, you should define
a custom datatype with a custom PersistFieldSql instance instead of
using this.
User
uuid Text sqltype=UUID
FieldAttrMaxlen IntegerSet a maximum length for a column. Useful for VARCHAR and indexes.
User
name Text maxlen=200
UniqueName name
FieldAttrSql TextSpecify the database name of the column.
User
blarghle Int sql="b_l_a_r_g_h_l_e"
Useful for performing phased migrations, where one column is renamed to another column over time.
FieldAttrOther TextA grab bag of random attributes that were unrecognized by the parser.
Eq FieldAttrDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd FieldAttrDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead FieldAttrDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow FieldAttrDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift FieldAttrDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseThis datatype describes how a foreign reference field cascades deletes or updates.
This type is used in both parsing the model definitions and performing migrations. A Nothing in either of the field values means that the user has not specified a CascadeAction. An unspecified CascadeAction is defaulted to Restrict when doing migrations.
Eq FieldCascadeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd FieldCascadeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead FieldCascadeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow FieldCascadeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift FieldCascadeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseA FieldDef represents the inormation that persistent knows about
a field of a datatype. This includes information used to parse the field
out of the database and what the field corresponds to.
FieldDeffieldHaskell :: !FieldNameHSThe name of the field. Note that this does not corresponds to the
record labels generated for the particular entity - record labels
are generated with the type name prefixed to the field, so
a FieldDef that contains a FieldNameHS "name" for a type
User will have a record field userName.
fieldDB :: !FieldNameDBThe name of the field in the database. For SQL databases, this corresponds to the column name.
fieldType :: !FieldTypeThe type of the field in Haskell.
fieldSqlType :: !SqlTypeThe type of the field in a SQL database.
fieldAttrs :: ![FieldAttr]User annotations for a field. These are provided with the !
operator.
fieldStrict :: !BoolfieldReference :: !ReferenceDeffieldCascade :: !FieldCascadeDefines how operations on the field cascade on to the referenced tables. This doesn't have any meaning if the fieldReference is set to NoReference or SelfReference. The cascade option here should be the same as the one obtained in the fieldReference.
fieldComments :: !Maybe TextOptional comments for a Field.
fieldGenerated :: !Maybe TextWhether or not the field is a GENERATED column, and additionally
the expression to use for generation.
fieldIsImplicitIdColumn :: !BoolEq FieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd FieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead FieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow FieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift FieldDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseForeignDefforeignRefTableHaskell :: !EntityNameHSforeignRefTableDBName :: !EntityNameDBforeignConstraintNameHaskell :: !ConstraintNameHSforeignConstraintNameDBName :: !ConstraintNameDBforeignFieldCascade :: !FieldCascadeDetermine how the field will cascade on updates and deletions.
foreignFields :: ![(ForeignFieldDef, ForeignFieldDef)]foreignAttrs :: ![Attr]foreignNullable :: BoolforeignToPrimary :: BoolDetermines if the reference is towards a Primary Key or not.
Eq ForeignDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd ForeignDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead ForeignDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow ForeignDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift ForeignDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseUsed instead of FieldDef to generate a smaller amount of code
Eq IsNullableDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow IsNullableDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow UpdateExceptionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseException UpdateExceptionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow PersistExceptionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseException PersistExceptionDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseA SQL data type. Naming attempts to reflect the underlying Haskell datatypes, eg SqlString instead of SqlVarchar. Different SQL databases may have different translations for these types.
Eq SqlTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd SqlTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead SqlTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow SqlTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift SqlTypeDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseType for storing the Uniqueness constraint in the Schema. Assume you have the following schema with a uniqueness constraint:
Person
name String
age Int
UniqueAge age
This will be represented as:
UniqueDef
{ uniqueHaskell = ConstraintNameHS (packPTH UniqueAge)
, uniqueDBName = ConstraintNameDB (packPTH "unique_age")
, uniqueFields = [(FieldNameHS (packPTH "age"), FieldNameDB (packPTH "age"))]
, uniqueAttrs = []
}
Eq UniqueDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseOrd UniqueDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseRead UniqueDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseShow UniqueDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseLift UniqueDefDefined in persistent-2.14.6.3 · Database.Persist.Types.BaseReturn the [FieldDef] for the entity keys.
A FieldCascade that does nothing.
Parse raw field attributes into structured form. Any unrecognized attributes will be preserved, identically as they are encountered, as FieldAttrOther values.
Render a CascadeAction to Text such that it can be used in a SQL command.
Renders a FieldCascade value such that it can be used in SQL migrations.
Non-equality check.
selectSimon :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectSimon = selectList [UserName !=. "SPJ" ] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|2 |Simon|41 |
+-----+-----+-----+Assign a field by multiplication (*=).
multiplyAge :: MonadIO m => ReaderT SqlBackend m ()
multiplyAge = updateWhere [UserName ==. "SPJ" ] [UserAge *=. 2]
The above query when applied on dataset-1, will produce this:
+-----+-----+--------+
|id |name |age |
+-----+-----+--------+
|1 |SPJ |40 -> 80|
+-----+-----+--------+
|2 |Simon|41 |
+-----+-----+--------+Assign a field by addition (+=).
addAge :: MonadIO m => ReaderT SqlBackend m ()
addAge = updateWhere [UserName ==. "SPJ" ] [UserAge +=. 1]
The above query when applied on dataset-1, will produce this:
+-----+-----+---------+
|id |name |age |
+-----+-----+---------+
|1 |SPJ |40 -> 41 |
+-----+-----+---------+
|2 |Simon|41 |
+-----+-----+---------+Assign a field by subtraction (-=).
subtractAge :: MonadIO m => ReaderT SqlBackend m ()
subtractAge = updateWhere [UserName ==. "SPJ" ] [UserAge -=. 1]
The above query when applied on dataset-1, will produce this:
+-----+-----+---------+
|id |name |age |
+-----+-----+---------+
|1 |SPJ |40 -> 39 |
+-----+-----+---------+
|2 |Simon|41 |
+-----+-----+---------+Check if value is not in given list.
selectSimon :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectSimon = selectList [UserAge /<-. [40]] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|2 |Simon|41 |
+-----+-----+-----+Assign a field by division (/=).
divideAge :: MonadIO m => ReaderT SqlBackend m ()
divideAge = updateWhere [UserName ==. "SPJ" ] [UserAge /=. 2]
The above query when applied on dataset-1, will produce this:
+-----+-----+---------+
|id |name |age |
+-----+-----+---------+
|1 |SPJ |40 -> 20 |
+-----+-----+---------+
|2 |Simon|41 |
+-----+-----+---------+Check if value is in given list.
selectUsers :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectUsers = selectList [UserAge <-. [40, 41]] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|1 |SPJ |40 |
+-----+-----+-----+
|2 |Simon|41 |
+-----+-----+-----+selectSPJ :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectSPJ = selectList [UserAge <-. [40]] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|1 |SPJ |40 |
+-----+-----+-----+Less-than check.
selectLessAge :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectLessAge = selectList [UserAge <. 41 ] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|1 |SPJ |40 |
+-----+-----+-----+Less-than or equal check.
selectLessEqualAge :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectLessEqualAge = selectList [UserAge <=. 40 ] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|1 |SPJ |40 |
+-----+-----+-----+Assign a field a value.
updateAge :: MonadIO m => ReaderT SqlBackend m ()
updateAge = updateWhere [UserName ==. "SPJ" ] [UserAge =. 45]
Similar to updateWhere which is shown in the above example you can use other functions present in the module Database.Persist.Class. Note that the first parameter of updateWhere is [Filter val] and second parameter is [Update val]. By comparing this with the type of ==. and =., you can see that they match up in the above usage.
The above query when applied on dataset-1, will produce this:
+-----+-----+--------+
|id |name |age |
+-----+-----+--------+
|1 |SPJ |40 -> 45|
+-----+-----+--------+
|2 |Simon|41 |
+-----+-----+--------+Check for equality.
selectSPJ :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectSPJ = selectList [UserName ==. "SPJ" ] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|1 |SPJ |40 |
+-----+-----+-----+Greater-than check.
selectGreaterAge :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectGreaterAge = selectList [UserAge >. 40 ] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|2 |Simon|41 |
+-----+-----+-----+Greater-than or equal check.
selectGreaterEqualAge :: MonadIO m => ReaderT SqlBackend m [Entity User]
selectGreaterEqualAge = selectList [UserAge >=. 41 ] []
The above query when applied on dataset-1, will produce this:
+-----+-----+-----+
|id |name |age |
+-----+-----+-----+
|2 |Simon|41 |
+-----+-----+-----+The OR of two lists of filters. For example:
selectList
([ PersonAge >. 25
, PersonAge <. 30 ] ||.
[ PersonIncome >. 15000
, PersonIncome <. 25000 ])
[]will filter records where a person's age is between 25 and 30 or a person's income is between (15000 and 25000).
If you are looking for an (&&.) operator to do (A AND B AND (C OR D))
you can use the (++) operator instead as there is no (&&.). For
example:
selectList
([ PersonAge >. 25
, PersonAge <. 30 ] ++
([PersonCategory ==. 1] ||.
[PersonCategory ==. 5]))
[]will filter records where a person's age is between 25 and 30 and (person's category is either 1 or 5).
FIXME What's this exactly?
Values to configure a pool of database connections. See Data.Pool for details.
ConnectionPoolConfigconnectionPoolConfigStripes :: IntHow many stripes to divide the pool into. See Data.Pool for details. Default: 1.
connectionPoolConfigIdleTimeout :: NominalDiffTimeHow long connections can remain idle before being disposed of, in seconds. Default: 600
connectionPoolConfigSize :: IntHow many connections should be held in the connection pool. Default: 10
Show ConnectionPoolConfigDefined in persistent-2.14.6.3 · Database.Persist.Sql.TypescreateSqlPoolWithConfig :: (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend)=> (LogFunc -> IO backend)Function to create a new connection
-> ConnectionPoolConfig-> m (Pool backend)Creates a pool of connections to a SQL database.
withSqlPool :: (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend)=> (LogFunc -> IO backend)create a new connection
-> Intconnection count
-> (Pool backend -> m a)-> m aCreate a connection and run sql queries within it. This function automatically closes the connection on it's completion.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies#-}
{-# LANGUAGE TemplateHaskell#-}
{-# LANGUAGE QuasiQuotes#-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Logger
import Conduit
import Database.Persist
import Database.Sqlite
import Database.Persist.Sqlite
import Database.Persist.TH
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Person
name String
age Int Maybe
deriving Show
|]
openConnection :: LogFunc -> IO SqlBackend
openConnection logfn = do
conn <- open "/home/sibi/test.db"
wrapConnection conn logfn
main :: IO ()
main = do
runNoLoggingT $ runResourceT $ withSqlConn openConnection (\backend ->
flip runSqlConn backend $ do
runMigration migrateAll
insert_ $ Person "John doe" $ Just 35
insert_ $ Person "Divya" $ Just 36
(pers :: [Entity Person]) <- selectList [] []
liftIO $ print pers
return ()
)On executing it, you get this output:
Migrating: CREATE TABLE "person"("id" INTEGER PRIMARY KEY,"name" VARCHAR NOT NULL,"age" INTEGER NULL)
[Entity {entityKey = PersonKey {unPersonKey = SqlBackendKey {unSqlBackendKey = 1}}, entityVal = Person {personName = "John doe", personAge = Just 35}},Entity {entityKey = PersonKey {unPersonKey = SqlBackendKey {unSqlBackendKey = 2}}, entityVal = Person {personName = "Hema", personAge = Just 36}}]rawExecute :: (MonadIO m, BackendCompatible SqlBackend backend)=> TextSQL statement, possibly with placeholders.
-> [PersistValue]Values to fill the placeholders.
-> ReaderT backend m ()Execute a raw SQL statement
Generates sql for limit and offset for postgres, sqlite and mysql.
ColumncName :: !FieldNameDBcNull :: !BoolcSqlType :: !SqlTypecDefault :: !Maybe TextcGenerated :: !Maybe TextcDefaultConstraintName :: !Maybe ConstraintNameDBcMaxLen :: !Maybe IntegercReference :: !Maybe ColumnReferenceCreate the list of columns for the given entity.
Creates an empty BackendSpecificOverrides (i.e. use the default behavior; no overrides)
A Migration is a four level monad stack consisting of:
WriterT [Text] representing a log of errors in the migrations.
WriterT CautiousMigration representing a list of migrations to
run, along with whether or not they are safe.
ReaderT SqlBackend, aka the SqlPersistT transformer for
database interop.
IO for arbitrary IO.
This value specifies how a field references another table.
ColumnReferencecrTableName :: !EntityNameDBThe table name that the
crConstraintName :: !ConstraintNameDBThe name of the foreign key constraint.
crFieldCascade :: !FieldCascadeWhether or not updates/deletions to the referenced table cascade to this table.
Eq ColumnReferenceDefined in persistent-2.14.6.3 · Database.Persist.Sql.TypesOrd ColumnReferenceDefined in persistent-2.14.6.3 · Database.Persist.Sql.TypesShow ColumnReferenceDefined in persistent-2.14.6.3 · Database.Persist.Sql.TypesGet a connection from the pool, run the given action, and then return the connection to the pool.
This function performs the given action in a transaction. If an exception occurs during the action, then the transaction is rolled back.
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.
Report a single error in a Migration.
This newtype wrapper is useful when selecting an entity out of the database and you want to provide a prefix to the table being selected.
Consider this raw SQL query:
SELECT ??
FROM my_long_table_name AS mltn
INNER JOIN other_table AS ot
ON mltn.some_col = ot.other_col
WHERE ...We don't want to refer to my_long_table_name every time, so we create
an alias. If we want to select it, we have to tell the raw SQL
quasi-quoter that we expect the entity to be prefixed with some other
name.
We can give the above query a type with this, like:
getStuff :: SqlPersistM [EntityWithPrefix "mltn" MyLongTableName]
getStuff = rawSql queryText []
The EntityWithPrefix bit is a boilerplate newtype wrapper, so you can remove it with unPrefix, like this:
getStuff :: SqlPersistM [Entity MyLongTableName]
getStuff = unPrefix @"mltn" <$> rawSql queryText []
The symbol is a "type application" and requires the TypeApplications@
language extension.
EntityWithPrefixunEntityWithPrefix :: Entity record(PersistEntity record, KnownSymbol prefix, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (EntityWithPrefix prefix record)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassTells Persistent what database column type should be used to store a Haskell type.
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
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 = PersistLiteralEncoded . toASCIIBytes
fromPersistValue (PersistLiteralEncoded 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 PersistLiteralEncoded, received: "-- > <> T.pack (show x)
instance PersistFieldSql UUID where
sqlType _ = SqlOther "uuid"
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"
PersistFieldSql HtmlDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql ByteStringDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Int16Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Int32Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Int64Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Int8Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql RationalDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Word16Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Word32Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Word64Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql Word8Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql BoolDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql DoubleDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql IntDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql WordDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql OverflowNaturalDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassThis type uses the SqlInt64 version, which will exhibit overflow and underflow behavior. Additionally, it permits negative values in the database, which isn't ideal.
PersistFieldSql PersistValueDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql CheckmarkDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql TextDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql TextDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql DayDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql UTCTimeDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql TimeOfDayDefined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql [Char]Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql a => PersistFieldSql (Maybe a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql a => PersistFieldSql (Vector a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql a => PersistFieldSql [a]Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql v => PersistFieldSql (IntMap v)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(Ord a, PersistFieldSql a) => PersistFieldSql (Set a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(PersistField record, PersistEntity record) => PersistFieldSql (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(BackendCompatible b s, PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (Compatible b s))Defined in persistent-2.14.6.3 · Database.Persist.Compatible.Types(PersistCore b, PersistCore (RawSqlite b), PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteHasResolution a => PersistFieldSql (Fixed a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassPersistFieldSql v => PersistFieldSql (Map Text v)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(PersistFieldSql a, PersistFieldSql b) => PersistFieldSql (a, b)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassClass for data types that may be retrived from a rawSql
query.
rawSqlCols :: (Text -> Text) -> a -> (Int, [Text])Number of columns that this data type needs and the list
of substitutions for SELECT placeholders ??.
rawSqlColCountReason :: a -> StringA string telling the user why the column count is what it is.
rawSqlProcessRow :: [PersistValue] -> Either Text aTransform a row of the result into the data type.
PersistField a => RawSql (Single a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassRawSql a => RawSql (Maybe a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(PersistEntity a, PersistEntityBackend a ~ backend, IsPersistBackend backend) => RawSql (Key a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(PersistEntity record, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (Entity record)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(PersistEntity record, KnownSymbol prefix, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (EntityWithPrefix prefix record)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b) => RawSql (a, b)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c) => RawSql (a, b, c)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d) => RawSql (a, b, c, d)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e) => RawSql (a, b, c, d, e)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f) => RawSql (a, b, c, d, e, f)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g) => RawSql (a, b, c, d, e, f, g)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(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)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i) => RawSql (a, b, c, d, e, f, g, h, i)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j) => RawSql (a, b, c, d, e, f, g, h, i, j)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k) => RawSql (a, b, c, d, e, f, g, h, i, j, k)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3, RawSql h3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3, h3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3, RawSql h3, RawSql i3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3, h3, i3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Class(RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3, RawSql h3, RawSql i3, RawSql j3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3, h3, i3, j3)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassA helper function to tell GHC what the EntityWithPrefix prefix should be. This allows you to use a type application to specify the prefix, instead of specifying the etype on the result.
As an example, here's code that uses this:
myQuery :: SqlPersistM [Entity Person]
myQuery = fmap (unPrefix @"p") $ rawSql query []
where
query = "SELECT ?? FROM person AS p"
Record of functions to override the default behavior in mkColumns. It is recommended you initialize this with emptyBackendSpecificOverrides and override the default values, so that as new fields are added, your code still compiles.
For added safety, use the getBackendSpecific* and setBackendSpecific*
functions, as a breaking change to the record field labels won't be reflected
in a major version bump of the library.
If the override is defined, then this returns a function that accepts an entity name and field name and provides the ConstraintNameDB for the foreign key constraint.
An abstract accessor for the BackendSpecificOverrides
Set the backend's foreign key generation function to this value.
An exception indicating that Persistent refused to run some unsafe migrations. Contains a list of pairs where the Bool tracks whether the migration was unsafe (True means unsafe), and the Sql is the sql statement for the migration.
Show PersistUnsafeMigrationExceptionDefined in persistent-2.14.6.3 · Database.Persist.Sql.MigrationThis Show instance renders an error message suitable for printing to the console. This is a little dodgy, but since GHC uses Show instances when displaying uncaught exceptions, we have little choice.
Exception PersistUnsafeMigrationExceptionDefined in persistent-2.14.6.3 · Database.Persist.Sql.MigrationaddMigration Add a migration to the migration plan.
Add a CautiousMigration (aka a [(Bool, Text)]) to the
migration plan.
Given a Migration, this parses it and returns either a list of errors associated with the migration or a list of migrations to do.
Like parseMigration, but instead of returning the value in an Either value, it calls error on the error values.
Prints a migration.
Report multiple errors in a Migration.
Runs a migration. If the migration fails to parse or if any of the migrations are unsafe, then this throws a PersistUnsafeMigrationException.
Same as runMigration, but does not report the individual migrations on stderr. Instead it returns a list of the executed SQL commands.
This is a safer/more robust alternative to runMigrationSilent, but may be less silent for some persistent implementations, most notably persistent-postgresql
Same as runMigration, but returns a list of the SQL commands executed instead of printing them to stderr.
This function silences the migration by remapping stderr. As a result, it is not thread-safe and can clobber output from other parts of the program. This implementation method was chosen to also silence postgresql migration output on stderr, but is not recommended!
Like runMigration, but this will perform the unsafe database migrations instead of erroring out.
Same as runMigrationUnsafe, but returns a list of the SQL commands executed instead of printing them to stderr.
Run an action against the database during a migration. Can be useful for eg creating Postgres extensions:
runSqlCommand $ rawExecute "CREATE EXTENSION IF NOT EXISTS "uuid-ossp";" []
Used when determining how to prefix a column name in a WHERE clause.
PrefixTableNamePrefix the column with the table name. This is useful if the column name might be ambiguous.
PrefixExcludedPrefix the column name with the EXCLUDED keyword. This is used with
the Postgresql backend when doing ON CONFLICT DO UPDATE clauses - see
the documentation on upsertWhere and upsertManyWhere.
Same as deleteWhere, but returns the number of rows affected.
filterClause :: PersistEntity val=> Maybe FilterTablePrefixinclude table name or EXCLUDED
-> SqlBackend-> [Filter val]-> TextfilterClauseWithVals :: PersistEntity val=> Maybe FilterTablePrefixinclude table name or EXCLUDED
-> SqlBackend-> [Filter val]-> (Text, [PersistValue])Render a [Filter record] into a Text value suitable for inclusion
into a SQL query, as well as the [PersistValue] to properly fill in the
? place holders.
orderClause :: PersistEntity val=> Maybe FilterTablePrefixinclude table name or EXCLUDED
-> SqlBackend-> [SelectOpt val]-> TextSame as updateWhere, but returns the number of rows affected.
useful for a backend to implement fieldName by adding escaping
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
get the SQL string for the table that a PersistEntity represents Useful for raw SQL queries
Your backend may provide a more convenient tableName function which does not operate in a Monad
useful for a backend to implement tableName by adding escaping
rawExecuteCount :: (MonadIO m, BackendCompatible SqlBackend backend)=> TextSQL statement, possibly with placeholders.
-> [PersistValue]Values to fill the placeholders.
-> ReaderT backend m Int64Execute a raw SQL statement and return the number of rows it has modified.
rawSql :: (RawSql a, MonadIO m, BackendCompatible SqlBackend backend)=> TextSQL statement, possibly with placeholders.
-> [PersistValue]Values to fill the placeholders.
-> ReaderT backend m [a]Execute a raw SQL statement and return its results as a list. If you do not expect a return value, use of rawExecute is recommended.
If you're using Entitys (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 Entitys 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)
acquireSqlConn :: (MonadReader backend m, BackendCompatible SqlBackend backend) => m (Acquire backend)Starts a new transaction on the connection. When the acquired connection is released the transaction is committed and the connection returned to the pool.
Upon an exception the transaction is rolled back and the connection destroyed.
This is equivalent to runSqlConn but does not incur the MonadUnliftIO
constraint, meaning it can be used within, for example, a Conduit
pipeline.
Like acquireSqlConn, but lets you specify an explicit isolation level.
Like runSqlConn, but supports specifying an isolation level.
Like runSqlPool, but does not surround the action in a transaction. This action might leave your database in a weird state.
This function is how runSqlPoolWithHooks is defined.
It's currently the most general function for using a SQL pool.
runSqlPoolWithHooks :: (MonadUnliftIO m, BackendCompatible SqlBackend backend)=> ReaderT backend m a-> Pool backend-> Maybe IsolationLevel-> (backend -> m before)Run this action immediately before the action is performed.
-> (backend -> m after)Run this action immediately after the action is completed.
-> (backend -> SomeException -> m onException)This action is performed when an exception is received. The exception is provided as a convenience - it is rethrown once this cleanup function is complete.
-> m aThis function is how runSqlPool and runSqlPoolNoTransaction are defined. In addition to the action to be performed and the Pool of conections to use, we give you the opportunity to provide three actions - initialize, afterwards, and onException.
Like runSqlPool, but supports specifying an isolation level.
withSqlPoolWithConfig :: (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend)=> (LogFunc -> IO backend)Function to create a new connection
-> ConnectionPoolConfig-> (Pool backend -> m a)-> m aCreates a pool of connections to a SQL database which can be used by the Pool backend -> m a function.
After the function completes, the connections are destroyed.
Show PersistentSqlExceptionDefined in persistent-2.14.6.3 · Database.Persist.Sql.TypesException PersistentSqlExceptionDefined in persistent-2.14.6.3 · Database.Persist.Sql.TypesA single column (see rawSql). Any PersistField may be
used here, including PersistValue (which does not do any
processing).
Eq a => Eq (Single a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.TypesOrd a => Ord (Single a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.TypesRead a => Read (Single a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.TypesShow a => Show (Single a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.TypesPersistField a => RawSql (Single a)Defined in persistent-2.14.6.3 · Database.Persist.Sql.ClassInitializes a ConnectionPoolConfig with default values. See the documentation of ConnectionPoolConfig for each field's default value.
A backend which is a wrapper around SqlBackend.
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.
An SQL backend which can only handle read queries
The constructor was exposed in 2.10.0.
PersistQueryRead SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanHasPersistBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalIsPersistBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalPersistCore SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreRead SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistUniqueRead SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanBackendCompatible SqlBackend SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBounded (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEnum (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEq (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanIntegral (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanNum (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanOrd (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanRead (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanReal (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanShow (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanGeneric (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromJSON (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToJSON (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromHttpApiData (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToHttpApiData (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPathPiece (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlReadBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey"
"Database.Persist.Sql.Orphan.PersistStore"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'True) (C1 ('MetaCons "SqlReadBackendKey"
'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey SqlReadBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype BaseBackend SqlReadBackend = SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.Internaltype SqlReadT (m :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m aLike SqlPersistT but compatible with any SQL backend which can handle read queries.
An SQL backend which can handle read or write queries
The constructor was exposed in 2.10.0
PersistQueryRead SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanPersistQueryWrite SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistQuery · orphanHasPersistBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalIsPersistBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.InternalPersistCore SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreRead SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistStoreWrite SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistUniqueRead SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanPersistUniqueWrite SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistUnique · orphanBackendCompatible SqlBackend SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanBounded (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEnum (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanEq (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanIntegral (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanNum (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanOrd (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanRead (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanReal (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanShow (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanGeneric (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromJSON (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToJSON (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanFromHttpApiData (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanToHttpApiData (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPathPiece (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistField (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphanPersistFieldSql (BackendKey SqlWriteBackend)Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey"
"Database.Persist.Sql.Orphan.PersistStore"
"persistent-2.14.6.3-31NeHlMbZ2g6XoXmn516lt"
'True) (C1 ('MetaCons "SqlWriteBackendKey"
'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))Defined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphandata BackendKey SqlWriteBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Orphan.PersistStore · orphantype BaseBackend SqlWriteBackend = SqlBackendDefined in persistent-2.14.6.3 · Database.Persist.Sql.Types.Internaltype SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m aLike SqlPersistT but compatible with any SQL backend which can handle read and write queries.
Useful for running a read query against a backend with unknown capabilities.
Useful for running a read query against a backend with read and write capabilities.
Useful for running a write query against an untagged backend with unknown capabilities.
Please refer to the documentation for the database in question for a full overview of the semantics of the varying isloation levels
Bounded IsolationLevelDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internal.IsolationLevelEnum IsolationLevelDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internal.IsolationLevelEq IsolationLevelDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internal.IsolationLevelOrd IsolationLevelDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internal.IsolationLevelShow IsolationLevelDefined in persistent-2.14.6.3 · Database.Persist.SqlBackend.Internal.IsolationLevelCommit the current transaction and begin a new one. This is used when a transaction commit is required within the context of runSqlConn (which brackets its provided action with a transaction begin/commit pair).
Commit the current transaction and begin a new one with the specified isolation level.
Roll back the current transaction and begin a new one. This rolls back to the state of the last call to transactionSave or the enclosing runSqlConn call.
Roll back the current transaction and begin a new one with the specified isolation level.
Information required to setup a connection pool.
Show SqliteConfDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteFromJSON SqliteConfDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqlitePersistConfig SqliteConfDefined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitetype PersistConfigBackend SqliteConf = SqlPersistTDefined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitetype PersistConfigPool SqliteConf = ConnectionPoolDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteInformation required to connect to a sqlite database. We export lenses instead of fields to avoid being limited to the current implementation.
Show SqliteConnectionInfoDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteFromJSON SqliteConnectionInfoDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteCreates a SqliteConnectionInfo from a connection string, with the default settings.
runSqlite :: MonadUnliftIO m=> Textconnection string
-> ReaderT SqlBackend (NoLoggingT (ResourceT m)) adatabase action
-> m aA convenience helper which creates a new database connection and runs the
given block, handling MonadResource and MonadLogger requirements. Note
that all log messages are discarded.
runSqliteInfo :: MonadUnliftIO m=> SqliteConnectionInfo-> ReaderT SqlBackend (NoLoggingT (ResourceT m)) adatabase action
-> m aA convenience helper which creates a new database connection and runs the
given block, handling MonadResource and MonadLogger requirements. Note
that all log messages are discarded.
Wrap up a raw Connection as a Persistent SQL Connection.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class (liftIO)
import Database.Persist
import Database.Sqlite
import Database.Persist.Sqlite
import Database.Persist.TH
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Person
name String
age Int Maybe
deriving Show
|]
main :: IO ()
main = do
conn <- open "/home/sibi/test.db"
(backend :: SqlBackend) <- wrapConnection conn (\_ _ _ _ -> return ())
flip runSqlPersistM backend $ do
runMigration migrateAll
insert_ $ Person "John doe" $ Just 35
insert_ $ Person "Hema" $ Just 36
(pers :: [Entity Person]) <- selectList [] []
liftIO $ print pers
close' backendOn executing it, you get this output:
Migrating: CREATE TABLE "person"("id" INTEGER PRIMARY KEY,"name" VARCHAR NOT NULL,"age" INTEGER NULL)
[Entity {entityKey = PersonKey {unPersonKey = SqlBackendKey {unSqlBackendKey = 1}}, entityVal = Person {personName = "John doe", personAge = Just 35}},Entity {entityKey = PersonKey {unPersonKey = SqlBackendKey {unSqlBackendKey = 2}}, entityVal = Person {personName = "Hema", personAge = Just 36}}]Wrap up a raw Connection as a Persistent SQL Connection, allowing full control over WAL and FK constraints.
Mock a migration even when the database is not present. This function performs the same functionality of printMigration with the difference that an actual database isn't needed for it.
Retry if a Busy is thrown, following an exponential backoff strategy.
waitForDatabase :: (MonadUnliftIO m, MonadLoggerIO m, BackendCompatible SqlBackend backend) => ReaderT backend m ()Wait until some noop action on the database does not return an ErrorBusy. See retryOnBusy.
Data type for reporting foreign key violations using checkForeignKeys.
ForeignKeyViolationforeignKeyTable :: TextThe table of the violated constraint
foreignKeyColumn :: TextThe column of the violated constraint
foreignKeyRowId :: Int64The ROWID of the row with the violated foreign key constraint
Eq ForeignKeyViolationDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteOrd ForeignKeyViolationDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteShow ForeignKeyViolationDefined in persistent-sqlite-2.13.3.0 · Database.Persist.SqlitecheckForeignKeys :: (MonadResource m, MonadReader env m, BackendCompatible SqlBackend env) => ConduitM () ForeignKeyViolation m ()Outputs all (if any) the violated foreign key constraints in the database.
The main use is to validate that no foreign key constraints were
broken/corrupted by anyone operating on the database with foreign keys
disabled. See fkEnabled.
Wrapper for persistent SqlBackends that carry the corresponding Connection.
BackendCompatible b (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Bounded (BackendKey b)) => Bounded (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Enum (BackendKey b)) => Enum (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Eq (BackendKey b)) => Eq (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Integral (BackendKey b)) => Integral (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Num (BackendKey b)) => Num (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Ord (BackendKey b)) => Ord (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Read (BackendKey b)) => Read (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Real (BackendKey b)) => Real (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), Show (BackendKey b)) => Show (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), FromJSON (BackendKey b)) => FromJSON (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), ToJSON (BackendKey b)) => ToJSON (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), PersistField (BackendKey b)) => PersistField (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, PersistQueryRead b) => PersistQueryRead (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, PersistQueryWrite b) => PersistQueryWrite (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteHasPersistBackend b => HasPersistBackend (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqlitePersistCore b => PersistCore (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, PersistStoreRead b) => PersistStoreRead (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, PersistStoreWrite b) => PersistStoreWrite (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, PersistUniqueRead b) => PersistUniqueRead (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(HasPersistBackend b, PersistUniqueWrite b) => PersistUniqueWrite (RawSqlite b)Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlite(PersistCore b, PersistCore (RawSqlite b), PersistFieldSql (BackendKey b)) => PersistFieldSql (BackendKey (RawSqlite b))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.Sqlitedata BackendKey (RawSqlite b)RawSqliteKeyunRawSqliteKey :: BackendKey (Compatible b (RawSqlite b))type BaseBackend (RawSqlite b0) = BaseBackend (Compatible b0 (RawSqlite b0))Defined in persistent-sqlite-2.13.3.0 · Database.Persist.SqliteOpen a RawSqlite SqlBackend connection from a SqliteConnectionInfo.
When using this function, the caller has to accept the responsibility of
cleaning up the resulting connection. To do this, use close with the
rawSqliteConnection - it's enough to simply drop the persistBackend
afterwards.
Like withSqliteConnInfo, but exposes the internal Connection. For power users who want to manually interact with SQLite's C API via internals exposed by Database.Sqlite.Internal
createRawSqlitePoolFromInfo :: (MonadLoggerIO m, MonadUnliftIO m)=> SqliteConnectionInfo-> (RawSqlite SqlBackend -> m ())An action that is run whenever a new RawSqlite connection is allocated in the pool. The main use of this function is to register custom functions with the SQLite connection upon creation.
-> Int-> m (Pool (RawSqlite SqlBackend))Like createSqlitePoolFromInfo, but like withRawSqliteConnInfo it exposes the internal Connection.
For power users who want to manually interact with SQLite's C API via internals exposed by Database.Sqlite.Internal. The callback can be used to run arbitrary actions on the connection upon allocation from the pool.
Like createRawSqlitePoolFromInfo, but doesn't require a callback operating on the connection.
withRawSqlitePoolInfo :: (MonadUnliftIO m, MonadLoggerIO m)=> SqliteConnectionInfo-> (RawSqlite SqlBackend -> m ())-> Intnumber of connections to open
-> (Pool (RawSqlite SqlBackend) -> m a)-> m aLike createSqlitePoolInfo, but based on createRawSqlitePoolFromInfo.
withRawSqlitePoolInfo_ :: (MonadUnliftIO m, MonadLoggerIO m)=> SqliteConnectionInfo-> Intnumber of connections to open
-> (Pool (RawSqlite SqlBackend) -> m a)-> m aLike createSqlitePoolInfo, but based on createRawSqlitePoolFromInfo_.