| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Database.Esqueleto.Experimental
Description
This module contains a new way (introduced in 3.3.3.0) of using FROM in
 Haskell. The old method was a bit finicky and could permit runtime errors,
 and this new way is both significantly safer and much more powerful.
Esqueleto users are encouraged to migrate to this module, as it will become
 the default in a new major version 4.0.0.0.
Synopsis
- data From a where- Table :: PersistEntity ent => From (SqlExpr (Entity ent))
- SubQuery :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a
- FromCte :: Ident -> a -> From a
- SqlSetOperation :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlSetOperation a -> From a
- InnerJoinFrom :: From a -> (From b, (a :& b) -> SqlExpr (Value Bool)) -> From (a :& b)
- InnerJoinFromLateral :: (SqlSelect b r, ToAlias b, ToAliasReference b) => From a -> (a -> SqlQuery b, (a :& b) -> SqlExpr (Value Bool)) -> From (a :& b)
- CrossJoinFrom :: From a -> From b -> From (a :& b)
- CrossJoinFromLateral :: (SqlSelect b r, ToAlias b, ToAliasReference b) => From a -> (a -> SqlQuery b) -> From (a :& b)
- LeftJoinFrom :: ToMaybe b => From a -> (From b, (a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> From (a :& ToMaybeT b)
- LeftJoinFromLateral :: (SqlSelect b r, ToAlias b, ToAliasReference b, ToMaybe b) => From a -> (a -> SqlQuery b, (a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> From (a :& ToMaybeT b)
- RightJoinFrom :: ToMaybe a => From a -> (From b, (ToMaybeT a :& b) -> SqlExpr (Value Bool)) -> From (ToMaybeT a :& b)
- FullJoinFrom :: (ToMaybe a, ToMaybe b) => From a -> (From b, (ToMaybeT a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> From (ToMaybeT a :& ToMaybeT b)
 
- on :: ValidOnClauseValue a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool))
- from :: ToFrom a => a -> SqlQuery (ToFromT a)
- data a :& b = a :& b
- union_ :: a -> b -> Union a b
- data Union a b = a `Union` b
- unionAll_ :: a -> b -> UnionAll a b
- data UnionAll a b = a `UnionAll` b
- except_ :: a -> b -> Except a b
- data Except a b = a `Except` b
- intersect_ :: a -> b -> Intersect a b
- data Intersect a b = a `Intersect` b
- pattern SelectQuery :: SqlQuery a -> SqlSetOperation a
- with :: (ToAlias a, ToAliasReference a, SqlSelect a r) => SqlQuery a -> SqlQuery (From a)
- withRecursive :: (ToAlias a, ToAliasReference a, SqlSelect a r, RecursiveCteUnion unionKind) => SqlQuery a -> unionKind -> (From a -> SqlQuery a) -> SqlQuery (From a)
- class ToFrom a where
- class ToMaybe a where
- class ToAlias a where
- type ToAliasT a = a
- class ToAliasReference a where- toAliasReference :: Ident -> a -> SqlQuery a
 
- type ToAliasReferenceT a = a
- type family ValidOnClauseValue a :: Constraint where ...
- where_ :: SqlExpr (Value Bool) -> SqlQuery ()
- groupBy :: ToSomeValues a => a -> SqlQuery ()
- orderBy :: [SqlExpr OrderBy] -> SqlQuery ()
- rand :: SqlExpr OrderBy
- asc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy
- desc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy
- limit :: Int64 -> SqlQuery ()
- offset :: Int64 -> SqlQuery ()
- distinct :: SqlQuery a -> SqlQuery a
- distinctOn :: [SqlExpr DistinctOn] -> SqlQuery a -> SqlQuery a
- don :: SqlExpr (Value a) -> SqlExpr DistinctOn
- distinctOnOrderBy :: [SqlExpr OrderBy] -> SqlQuery a -> SqlQuery a
- having :: SqlExpr (Value Bool) -> SqlQuery ()
- locking :: LockingKind -> SqlQuery ()
- sub_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)
- (^.) :: forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ)
- (?.) :: (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ))
- val :: PersistField typ => typ -> SqlExpr (Value typ)
- isNothing :: PersistField typ => SqlExpr (Value (Maybe typ)) -> SqlExpr (Value Bool)
- just :: SqlExpr (Value typ) -> SqlExpr (Value (Maybe typ))
- nothing :: SqlExpr (Value (Maybe typ))
- joinV :: SqlExpr (Value (Maybe (Maybe typ))) -> SqlExpr (Value (Maybe typ))
- withNonNull :: PersistField typ => SqlExpr (Value (Maybe typ)) -> (SqlExpr (Value typ) -> SqlQuery a) -> SqlQuery a
- countRows :: Num a => SqlExpr (Value a)
- count :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
- countDistinct :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
- not_ :: SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- (==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- (>=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- (>.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- (<=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- (<.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- (!=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- (&&.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- (||.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- between :: PersistField a => SqlExpr (Value a) -> (SqlExpr (Value a), SqlExpr (Value a)) -> SqlExpr (Value Bool)
- (+.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- (-.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- (/.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- (*.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- random_ :: (PersistField a, Num a) => SqlExpr (Value a)
- round_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- ceiling_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- floor_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- min_ :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe a))
- max_ :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe a))
- sum_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b))
- avg_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b))
- castNum :: (Num a, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- castNumM :: (Num a, Num b) => SqlExpr (Value (Maybe a)) -> SqlExpr (Value (Maybe b))
- coalesce :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value (Maybe a))
- coalesceDefault :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
- lower_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- upper_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- trim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- ltrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- rtrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- length_ :: (SqlString s, Num a) => SqlExpr (Value s) -> SqlExpr (Value a)
- left_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s)
- right_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s)
- like :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool)
- ilike :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool)
- (%) :: SqlString s => SqlExpr (Value s)
- concat_ :: SqlString s => [SqlExpr (Value s)] -> SqlExpr (Value s)
- (++.) :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value s)
- castString :: (SqlString s, SqlString r) => SqlExpr (Value s) -> SqlExpr (Value r)
- subList_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)
- valList :: PersistField typ => [typ] -> SqlExpr (ValueList typ)
- justList :: SqlExpr (ValueList typ) -> SqlExpr (ValueList (Maybe typ))
- in_ :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)
- notIn :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)
- exists :: SqlQuery () -> SqlExpr (Value Bool)
- notExists :: SqlQuery () -> SqlExpr (Value Bool)
- set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery ()
- (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val)
- (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- case_ :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
- toBaseId :: ToBaseId ent => SqlExpr (Value (Key ent)) -> SqlExpr (Value (Key (BaseEnt ent)))
- subSelect :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value (Maybe a))
- subSelectMaybe :: PersistField a => SqlQuery (SqlExpr (Value (Maybe a))) -> SqlExpr (Value (Maybe a))
- subSelectCount :: (Num a, PersistField a) => SqlQuery ignored -> SqlExpr (Value a)
- subSelectForeign :: (BackendCompatible SqlBackend (PersistEntityBackend val1), PersistEntity val1, PersistEntity val2, PersistField a) => SqlExpr (Entity val2) -> EntityField val2 (Key val1) -> (SqlExpr (Entity val1) -> SqlExpr (Value a)) -> SqlExpr (Value a)
- subSelectList :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)
- subSelectUnsafe :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)
- class ToBaseId ent where- type BaseEnt ent :: *
- toBaseIdWitness :: Key (BaseEnt ent) -> Key ent
 
- when_ :: expr (Value Bool) -> () -> expr a -> (expr (Value Bool), expr a)
- then_ :: ()
- else_ :: expr a -> expr a
- newtype Value a = Value {- unValue :: a
 
- newtype ValueList a = ValueList a
- data OrderBy
- data DistinctOn
- data LockingKind
- class PersistField a => SqlString a
- data InnerJoin a b = a `InnerJoin` b
- data CrossJoin a b = a `CrossJoin` b
- data LeftOuterJoin a b = a `LeftOuterJoin` b
- data RightOuterJoin a b = a `RightOuterJoin` b
- data FullOuterJoin a b = a `FullOuterJoin` b
- data JoinKind
- data OnClauseWithoutMatchingJoinException = OnClauseWithoutMatchingJoinException String
- data SqlQuery a
- data SqlExpr a
- type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend)
- select :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r]
- selectSource :: (SqlSelect a r, BackendCompatible SqlBackend backend, IsPersistBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend, MonadResource m) => SqlQuery a -> ConduitT () r (ReaderT backend m) ()
- delete :: MonadIO m => SqlQuery () -> SqlWriteT m ()
- deleteCount :: MonadIO m => SqlQuery () -> SqlWriteT m Int64
- update :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m ()
- updateCount :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m Int64
- insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m ()
- insertSelectCount :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m Int64
- (<#) :: (a -> b) -> SqlExpr (Value a) -> SqlExpr (Insertion b)
- (<&>) :: SqlExpr (Insertion (a -> b)) -> SqlExpr (Value a) -> SqlExpr (Insertion b)
- renderQueryToText :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => Mode -> SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- renderQuerySelect :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- renderQueryUpdate :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- renderQueryDelete :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- renderQueryInsertInto :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- valkey :: (ToBackendKey SqlBackend entity, PersistField (Key entity)) => Int64 -> SqlExpr (Value (Key entity))
- valJ :: PersistField (Key entity) => Value (Key entity) -> SqlExpr (Value (Key entity))
- associateJoin :: forall e1 e0. Ord (Key e0) => [(Entity e0, e1)] -> Map (Key e0) (e0, [e1])
- deleteKey :: (PersistStore backend, BaseBackend backend ~ PersistEntityBackend val, MonadIO m, PersistEntity val) => Key val -> ReaderT backend m ()
- toJsonText :: ToJSON j => j -> Text
- entityIdFromJSON :: (PersistEntity record, FromJSON record) => Value -> Parser (Entity record)
- entityIdToJSON :: (PersistEntity record, ToJSON record) => Entity record -> Value
- entityValues :: PersistEntity record => Entity record -> [PersistValue]
- fromPersistValueJSON :: FromJSON a => PersistValue -> Either Text a
- keyValueEntityFromJSON :: (PersistEntity record, FromJSON record) => Value -> Parser (Entity record)
- keyValueEntityToJSON :: (PersistEntity record, ToJSON record) => Entity record -> Value
- toPersistValueJSON :: ToJSON a => a -> PersistValue
- selectKeys :: forall record backend (m :: Type -> Type). (PersistQueryRead backend, MonadResource m, PersistRecordBackend record backend, MonadReader backend m) => [Filter record] -> [SelectOpt record] -> ConduitM () (Key record) m ()
- belongsTo :: forall ent1 ent2 backend (m :: Type -> Type). (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Maybe (Key ent2)) -> ent1 -> ReaderT backend m (Maybe ent2)
- belongsToJust :: forall ent1 ent2 backend (m :: Type -> Type). (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Key ent2) -> ent1 -> ReaderT backend m ent2
- getEntity :: forall e backend (m :: Type -> Type). (PersistStoreRead backend, PersistRecordBackend e backend, MonadIO m) => Key e -> ReaderT backend m (Maybe (Entity e))
- getJust :: forall record backend (m :: Type -> Type). (PersistStoreRead backend, PersistRecordBackend record backend, MonadIO m) => Key record -> ReaderT backend m record
- getJustEntity :: forall record backend (m :: Type -> Type). (PersistEntityBackend record ~ BaseBackend backend, MonadIO m, PersistEntity record, PersistStoreRead backend) => Key record -> ReaderT backend m (Entity record)
- insertEntity :: forall e backend (m :: Type -> Type). (PersistStoreWrite backend, PersistRecordBackend e backend, MonadIO m) => e -> ReaderT backend m (Entity e)
- insertRecord :: forall record backend (m :: Type -> Type). (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStoreWrite backend) => record -> ReaderT backend m record
- liftPersist :: (MonadIO m, MonadReader backend m) => ReaderT backend IO b -> m b
- checkUnique :: forall record backend (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, PersistUniqueRead backend) => record -> ReaderT backend m (Maybe (Unique record))
- getByValue :: forall record (m :: Type -> Type) backend. (MonadIO m, PersistUniqueRead backend, PersistRecordBackend record backend, AtLeastOneUniqueKey record) => record -> ReaderT backend m (Maybe (Entity record))
- insertBy :: forall record backend (m :: Type -> Type). (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend, AtLeastOneUniqueKey record) => record -> ReaderT backend m (Either (Entity record) (Key record))
- insertUniqueEntity :: forall record backend (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, PersistUniqueWrite backend) => record -> ReaderT backend m (Maybe (Entity record))
- onlyUnique :: forall record backend (m :: Type -> Type). (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend, OnlyOneUniqueKey record) => record -> ReaderT backend m (Unique record)
- replaceUnique :: forall record backend (m :: Type -> Type). (MonadIO m, Eq (Unique record), PersistRecordBackend record backend, PersistUniqueWrite backend) => Key record -> record -> ReaderT backend m (Maybe (Unique record))
- transactionSave :: forall (m :: Type -> Type). MonadIO m => ReaderT SqlBackend m ()
- transactionUndo :: forall (m :: Type -> Type). MonadIO m => ReaderT SqlBackend m ()
- defaultAttribute :: [FieldAttr] -> Maybe Text
- mkColumns :: [EntityDef] -> EntityDef -> BackendSpecificOverrides -> ([Column], [UniqueDef], [ForeignDef])
- getMigration :: forall (m :: Type -> Type). (MonadIO m, HasCallStack) => Migration -> ReaderT SqlBackend m [Sql]
- migrate :: [EntityDef] -> EntityDef -> Migration
- parseMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m (Either [Text] CautiousMigration)
- parseMigration' :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m CautiousMigration
- printMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m ()
- runMigration :: forall (m :: Type -> Type). MonadIO m => Migration -> ReaderT SqlBackend m ()
- runMigrationSilent :: forall (m :: Type -> Type). MonadUnliftIO m => Migration -> ReaderT SqlBackend m [Text]
- runMigrationUnsafe :: forall (m :: Type -> Type). MonadIO m => Migration -> ReaderT SqlBackend m ()
- showMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m [Text]
- decorateSQLWithLimitOffset :: Text -> (Int, Int) -> Text -> Text
- fieldDBName :: PersistEntity record => EntityField record typ -> FieldNameDB
- fromSqlKey :: ToBackendKey SqlBackend record => Key record -> Int64
- getFieldName :: forall record typ (m :: Type -> Type) backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, BackendCompatible SqlBackend backend, Monad m) => EntityField record typ -> ReaderT backend m Text
- getTableName :: forall record (m :: Type -> Type) backend. (PersistEntity record, BackendCompatible SqlBackend backend, Monad m) => record -> ReaderT backend m Text
- tableDBName :: PersistEntity record => record -> EntityNameDB
- toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record
- withRawQuery :: forall (m :: Type -> Type) a. MonadIO m => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> ReaderT SqlBackend m a
- getStmtConn :: SqlBackend -> Text -> IO Statement
- rawExecute :: forall (m :: Type -> Type) backend. (MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m ()
- rawExecuteCount :: forall (m :: Type -> Type) backend. (MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m Int64
- rawQuery :: forall (m :: Type -> Type) env. (MonadResource m, MonadReader env m, BackendCompatible SqlBackend env) => Text -> [PersistValue] -> ConduitM () [PersistValue] m ()
- rawQueryRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) env. (MonadIO m1, MonadIO m2, BackendCompatible SqlBackend env) => Text -> [PersistValue] -> ReaderT env m1 (Acquire (ConduitM () [PersistValue] m2 ()))
- rawSql :: forall a (m :: Type -> Type) backend. (RawSql a, MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m [a]
- close' :: BackendCompatible SqlBackend backend => backend -> IO ()
- createSqlPool :: forall backend m. (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> Int -> m (Pool backend)
- liftSqlPersistMPool :: forall backend m a. (MonadIO m, BackendCompatible SqlBackend backend) => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> m a
- runSqlConn :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> backend -> m a
- runSqlPersistM :: BackendCompatible SqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> backend -> IO a
- runSqlPersistMPool :: BackendCompatible SqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> IO a
- runSqlPool :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> Pool backend -> m a
- withSqlConn :: forall backend m a. (MonadUnliftIO m, MonadLoggerIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> (backend -> m a) -> m a
- withSqlPool :: forall backend m a. (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> Int -> (Pool backend -> m a) -> m a
- readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a
- readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a
- writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a
- getEntityKeyFields :: EntityDef -> NonEmpty FieldDef
- entityPrimary :: EntityDef -> Maybe CompositeDef
- keyAndEntityFields :: EntityDef -> NonEmpty FieldDef
- type PersistStore a = PersistStoreWrite a
- type PersistUnique a = PersistUniqueWrite a
- class (PersistStoreWrite backend, PersistEntity record, BaseBackend backend ~ PersistEntityBackend record) => DeleteCascade record backend where
- class PersistConfig c where- type PersistConfigBackend c :: (Type -> Type) -> Type -> Type
- type PersistConfigPool c
- loadConfig :: Value -> Parser c
- applyEnv :: c -> IO c
- createPoolConfig :: c -> IO (PersistConfigPool c)
- runPool :: MonadUnliftIO m => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m a
 
- type family BackendSpecificUpdate backend record
- data Entity record = Entity {}
- class (PersistField (Key record), ToJSON (Key record), FromJSON (Key record), Show (Key record), Read (Key record), Eq (Key record), Ord (Key record)) => PersistEntity record where- type PersistEntityBackend record
- data Key record
- data EntityField record :: Type -> Type
- data Unique record
- keyToValues :: Key record -> [PersistValue]
- keyFromValues :: [PersistValue] -> Either Text (Key record)
- persistIdField :: EntityField record (Key record)
- entityDef :: proxy record -> EntityDef
- persistFieldDef :: EntityField record typ -> FieldDef
- toPersistFields :: record -> [SomePersistField]
- fromPersistValues :: [PersistValue] -> Either Text record
- persistUniqueKeys :: record -> [Unique record]
- persistUniqueToFieldNames :: Unique record -> NonEmpty (FieldNameHS, FieldNameDB)
- persistUniqueToValues :: Unique record -> [PersistValue]
- fieldLens :: EntityField record field -> forall (f :: Type -> Type). Functor f => (field -> f field) -> Entity record -> f (Entity record)
- keyFromRecordM :: Maybe (record -> Key record)
 
- class PersistField a where- toPersistValue :: a -> PersistValue
- fromPersistValue :: PersistValue -> Either Text a
 
- data SomePersistField = PersistField a => SomePersistField a
- class (PersistCore backend, PersistStoreRead backend) => PersistQueryRead backend where- selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record backend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 (Acquire (ConduitM () (Entity record) m2 ()))
- selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m (Maybe (Entity record))
- selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 (Acquire (ConduitM () (Key record) m2 ()))
 
- class (PersistQueryRead backend, PersistStoreWrite backend) => PersistQueryWrite backend where- updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [Update record] -> ReaderT backend m ()
- deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m ()
 
- class BackendCompatible sup sub where- projectBackend :: sub -> sup
 
- data family BackendKey backend
- class HasPersistBackend backend where- type BaseBackend backend
- persistBackend :: backend -> BaseBackend backend
 
- class HasPersistBackend backend => IsPersistBackend backend
- class PersistCore backend where- data BackendKey backend
 
- type PersistRecordBackend record backend = (PersistEntity record, PersistEntityBackend record ~ BaseBackend backend)
- 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 where
- class (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 where- insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Key record)
- insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m ()
- insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m [Key record]
- insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m ()
- insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [Entity record] -> ReaderT backend m ()
- insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()
- repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()
- repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [(Key record, record)] -> ReaderT backend m ()
- replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()
- updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m record
 
- class (PersistEntity record, PersistEntityBackend record ~ backend, PersistCore backend) => ToBackendKey backend record where- toBackendKey :: Key record -> BackendKey backend
- fromBackendKey :: BackendKey backend -> Key record
 
- class PersistStoreRead backend => PersistUniqueRead backend where
- class (PersistUniqueRead backend, PersistStoreWrite backend) => PersistUniqueWrite backend where- deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m ()
- insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Maybe (Key record))
- upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, OnlyOneUniqueKey record) => record -> [Update record] -> ReaderT backend m (Entity record)
- upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Unique record -> record -> [Update record] -> ReaderT backend m (Entity record)
- putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m ()
 
- class PersistField a => PersistFieldSql a where
- class RawSql a where- rawSqlCols :: (Text -> Text) -> a -> (Int, [Text])
- rawSqlColCountReason :: a -> String
- rawSqlProcessRow :: [PersistValue] -> Either Text a
 
- type CautiousMigration = [(Bool, Sql)]
- data Column = Column {- cName :: !FieldNameDB
- cNull :: !Bool
- cSqlType :: !SqlType
- cDefault :: !(Maybe Text)
- cGenerated :: !(Maybe Text)
- cDefaultConstraintName :: !(Maybe ConstraintNameDB)
- cMaxLen :: !(Maybe Integer)
- cReference :: !(Maybe ColumnReference)
 
- type ConnectionPool = Pool SqlBackend
- type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT SqlBackend IO)) ()
- data PersistentSqlException
- newtype Single a = Single {- unSingle :: a
 
- type Sql = Text
- type SqlPersistM = SqlPersistT (NoLoggingT (ResourceT IO))
- type SqlPersistT = ReaderT SqlBackend
- data InsertSqlResult
- type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend)
- type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- data SqlBackend
- type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend)
- type SqlBackendCanWrite backend = (SqlBackendCanRead backend, PersistQueryWrite backend, PersistStoreWrite backend, PersistUniqueWrite backend)
- newtype SqlReadBackend = SqlReadBackend {}
- type SqlReadT (m :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m a
- newtype SqlWriteBackend = SqlWriteBackend {}
- type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a
- data Statement = Statement {- stmtFinalize :: IO ()
- stmtReset :: IO ()
- stmtExecute :: [PersistValue] -> IO Int64
- stmtQuery :: forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())
 
- type Attr = Text
- data Checkmark
- data CompositeDef = CompositeDef {- compositeFields :: !(NonEmpty FieldDef)
- compositeAttrs :: ![Attr]
 
- data EmbedEntityDef = EmbedEntityDef {}
- data EmbedFieldDef = EmbedFieldDef {- emFieldDB :: FieldNameDB
- emFieldEmbed :: Maybe (Either SelfEmbed EntityNameHS)
 
- data EntityDef
- data EntityIdDef
- type ExtraLine = [Text]
- data FieldDef = FieldDef {- fieldHaskell :: !FieldNameHS
- fieldDB :: !FieldNameDB
- fieldType :: !FieldType
- fieldSqlType :: !SqlType
- fieldAttrs :: ![FieldAttr]
- fieldStrict :: !Bool
- fieldReference :: !ReferenceDef
- fieldCascade :: !FieldCascade
- fieldComments :: !(Maybe Text)
- fieldGenerated :: !(Maybe Text)
- fieldIsImplicitIdColumn :: !Bool
 
- data FieldType
- data ForeignDef = ForeignDef {- foreignRefTableHaskell :: !EntityNameHS
- foreignRefTableDBName :: !EntityNameDB
- foreignConstraintNameHaskell :: !ConstraintNameHS
- foreignConstraintNameDBName :: !ConstraintNameDB
- foreignFieldCascade :: !FieldCascade
- foreignFields :: ![(ForeignFieldDef, ForeignFieldDef)]
- foreignAttrs :: ![Attr]
- foreignNullable :: Bool
- foreignToPrimary :: Bool
 
- type ForeignFieldDef = (FieldNameHS, FieldNameDB)
- data IsNullable
- data PersistException
- data PersistFilter
- data PersistUpdate
- data PersistValue where- PersistText Text
- PersistByteString ByteString
- PersistInt64 Int64
- PersistDouble Double
- PersistRational Rational
- PersistBool Bool
- PersistDay Day
- PersistTimeOfDay TimeOfDay
- PersistUTCTime UTCTime
- PersistNull
- PersistList [PersistValue]
- PersistMap [(Text, PersistValue)]
- PersistObjectId ByteString
- PersistArray [PersistValue]
- PersistLiteral_ LiteralType ByteString
- pattern PersistLiteral :: ByteString -> PersistValue
- pattern PersistLiteralEscaped :: ByteString -> PersistValue
- pattern PersistDbSpecific :: ByteString -> PersistValue
 
- data ReferenceDef
- data SqlType
- data UniqueDef = UniqueDef {- uniqueHaskell :: !ConstraintNameHS
- uniqueDBName :: !ConstraintNameDB
- uniqueFields :: !(NonEmpty (FieldNameHS, FieldNameDB))
- uniqueAttrs :: ![Attr]
 
- data UpdateException
- data WhyNullable
- getEntityFields :: EntityDef -> [FieldDef]
- getEntityId :: EntityDef -> EntityIdDef
- getEntityDBName :: EntityDef -> EntityNameDB
- getEntityUniques :: EntityDef -> [UniqueDef]
- getEntityDBName :: EntityDef -> EntityNameDB
Setup
If you're already using Database.Esqueleto, then you can get started using this module just by changing your imports slightly, as well as enabling the TypeApplications extension.
{-# LANGUAGE TypeApplications #-}
...
import Database.Esqueleto.Experimental
Note: Prior to esqueleto-3.3.4.0, the Database.Esqueleto.Experimental
 module did not reexport Data.Esqueleto.
Introduction
This module is fully backwards-compatible extension to the esqueleto
 EDSL that expands subquery functionality and enables
 SQL set operations
 to be written directly in Haskell. Specifically, this enables:
- Subqueries in JOINstatements
- UNION
- UNION- ALL
- INTERSECT
- EXCEPT
As a consequence of this, several classes of runtime errors are now
 caught at compile time. This includes missing on clauses and improper
 handling of Maybe values in outer joins.
This module can be used in conjunction with the main Database.Esqueleto
 module, but doing so requires qualified imports to avoid ambiguous
 definitions of on and from, which are defined in both modules.
Below we will give an overview of how to use this module and the features it enables.
A New Syntax
This module introduces a new syntax that serves to enable the aforementioned
 features. This new syntax also changes how joins written in the esqueleto
 EDSL to more closely resemble the underlying SQL.
For our examples, we'll use a schema similar to the one in the Getting Started section of Database.Esqueleto:
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist|
  Person
    name String
    age Int Maybe
    deriving Eq Show
  BlogPost
    title String
    authorId PersonId
    deriving Eq Show
  Follow
    follower PersonId
    followed PersonId
    deriving Eq Show
|]
Example 1: Simple select
Let's select all people who are named "John".
Database.Esqueleto:
select $ from $ \people -> do where_ (people ^. PersonName ==. val "John") pure people
Database.Esqueleto.Experimental:
select $ do people <- from $ Table @Person where_ (people ^. PersonName ==. val "John") pure people
Example 2: Select with join
Let's select all people and their blog posts who are over the age of 18.
Database.Esqueleto:
select $ from $ \(people `LeftOuterJoin` blogPosts) -> do on (people ^. PersonId ==. blogPosts ?. BlogPostAuthorId) where_ (people ^. PersonAge >. val 18) pure (people, blogPosts)
Database.Esqueleto.Experimental:
Here we use the :& operator to pattern match against the joined tables.
select $ do
(people :& blogPosts) <-
    from $ Table @Person
    `LeftOuterJoin` Table @BlogPost
    `on` (\(people :& blogPosts) ->
            people ^. PersonId ==. blogPosts ?. BlogPostAuthorId)
where_ (people ^. PersonAge >. val 18)
pure (people, blogPosts)
Example 3: Select with multi-table join
Let's select all people who follow a person named "John", including the name of each follower.
Database.Esqueleto:
select $ from $ \( people1 `InnerJoin` followers `InnerJoin` people2 ) -> do on (people1 ^. PersonId ==. followers ^. FollowFollowed) on (followers ^. FollowFollower ==. people2 ^. PersonId) where_ (people1 ^. PersonName ==. val "John") pure (followers, people2)
Database.Esqueleto.Experimental:
In this version, with each successive on clause, only the tables
 we have already joined into are in scope, so we must pattern match
 accordingly. In this case, in the second InnerJoin, we do not use
 the first Person reference, so we use _ as a placeholder to
 ignore it. This prevents a possible runtime error where a table
 is referenced before it appears in the sequence of JOINs.
select $ do
(people1 :& followers :& people2) <-
    from $ Table @Person
    `InnerJoin` Table @Follow
    `on` (\(people1 :& followers) ->
            people1 ^. PersonId ==. followers ^. FollowFollowed)
    `InnerJoin` Table @Person
    `on` (\(_ :& followers :& people2) ->
            followers ^. FollowFollower ==. people2 ^. PersonId)
where_ (people1 ^. PersonName ==. val "John")
pure (followers, people2)
Example 4: Counting results of a subquery
Let's count the number of people who have posted at least 10 posts
Database.Esqueleto:
select $ pure $ subSelectCount $ from $ \( people `InnerJoin` blogPosts ) -> do on (people ^. PersonId ==. blogPosts ^. BlogPostAuthorId) groupBy (people ^. PersonId) having ((count $ blogPosts ^. BlogPostId) >. val 10) pure people
Database.Esqueleto.Experimental:
select $ do
peopleWithPosts <-
  from $ do
    (people :& blogPosts) <-
      from $ Table @Person
      `InnerJoin` Table @BlogPost
      `on` (\(p :& bP) ->
              p ^. PersonId ==. bP ^. BlogPostAuthorId)
    groupBy (people ^. PersonId)
    having ((count $ blogPosts ^. BlogPostId) >. val 10)
    pure people
pure $ count (peopleWithPosts ^. PersonId)
We now have the ability to refactor this
Example 5: Sorting the results of a UNION with limits
Out of all of the posts created by a person and the people they follow, generate a list of the first 25 posts, sorted alphabetically.
Database.Esqueleto:
Since UNION is not supported, this requires using rawSql. (Not shown)
Database.Esqueleto.Experimental:
Since this module supports all set operations (see SqlSetOperation), we can use
 Union to write this query.
select $ do
(authors, blogPosts) <- from $
  (do
    (author :& blogPost) <-
      from $ Table @Person
      `InnerJoin` Table @BlogPost
      `on` (\(a :& bP) ->
              a ^. PersonId ==. bP ^. BlogPostAuthorId)
    where_ (author ^. PersonId ==. val currentPersonId)
    pure (author, blogPost)
  )
  `union_`
  (do
    (follow :& blogPost :& author) <-
      from $ Table @Follow
      `InnerJoin` Table @BlogPost
      `on` (\(f :& bP) ->
              f ^. FollowFollowed ==. bP ^. BlogPostAuthorId)
      `InnerJoin` Table @Person
      `on` (\(_ :& bP :& a) ->
              bP ^. BlogPostAuthorId ==. a ^. PersonId)
    where_ (follow ^. FollowFollower ==. val currentPersonId)
    pure (author, blogPost)
  )
orderBy [ asc (blogPosts ^. BlogPostTitle) ]
limit 25
pure (authors, blogPosts)
Example 6: LATERAL JOIN
As of version 3.4.0.0, lateral subquery joins are supported.
select $ do
(salesPerson :& maxSaleAmount :& maxSaleCustomerName) <-
  from $ Table @SalesPerson
  `CrossJoin` (\salesPerson -> do
        sales <- from $ Table @Sale
        where_ $ sales ^. SaleSalesPersonId ==. salesPerson ^. SalesPersonId
        pure $ max_ (sales ^. SaleAmount)
        )
  `CrossJoin` (\(salesPerson :& maxSaleAmount) -> do
        sales <- from $ Table @Sale
        where_ $ sales ^. SaleSalesPersonId ==. salesPerson ^. SalesPersonId
             &&. sales ^. SaleAmount ==. maxSaleAmount
        pure $ sales ^. SaleCustomerName)
        )
pure (salesPerson ^. SalesPersonName, maxSaleAmount, maxSaleCustomerName)
This is the equivalent to the following SQL (example taken from the MySQL Lateral Derived Table documentation):
SELECT
  salesperson.name,
  max_sale.amount,
  max_sale_customer.customer_name
FROM
  salesperson,
  -- calculate maximum size, cache it in transient derived table max_sale
  LATERAL
  (SELECT MAX(amount) AS amount
    FROM all_sales
    WHERE all_sales.salesperson_id = salesperson.id)
  AS max_sale,
  LATERAL
  (SELECT customer_name
    FROM all_sales
    WHERE all_sales.salesperson_id = salesperson.id
    AND all_sales.amount =
        -- the cached maximum size
        max_sale.amount)
  AS max_sale_customer;
Documentation
Data type that represents the syntax of a JOIN tree. In practice,
 only the Table constructor is used directly when writing queries. For example,
select $ from $ Table @People
Constructors
on :: ValidOnClauseValue a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool)) infix 9 Source #
An ON clause that describes how two tables are related. This should be
 used as an infix operator after a JOIN. For example,
select $
from $ Table @Person
`InnerJoin` Table @BlogPost
`on` (\(p :& bP) ->
        p ^. PersonId ==. bP ^. BlogPostAuthorId)
from :: ToFrom a => a -> SqlQuery (ToFromT a) Source #
FROM clause, used to bring entities into scope.
Internally, this function uses the From datatype and the
 ToFrom typeclass. Unlike the old from,
 this does not take a function as a parameter, but rather
 a value that represents a JOIN tree constructed out of
 instances of ToFrom. This implementation eliminates certain
 types of runtime errors by preventing the construction of
 invalid SQL (e.g. illegal nested-from).
A left-precedence pair. Pronounced "and". Used to represent expressions that have been joined together.
The precedence behavior can be demonstrated by:
a :& b :& c == ((a :& b) :& c)
See the examples at the beginning of this module to see how this
 operator is used in JOIN operations.
Constructors
| a :& b infixl 2 | 
Instances
| (ToMaybe a, ToMaybe b) => ToMaybe (a :& b) Source # | |
| (ToFrom a, ToFromT a ~ a', ToFrom b, ToFromT b ~ b', ToMaybe a', ma ~ ToMaybeT a', ToMaybe b', mb ~ ToMaybeT b', ErrorOnLateral b) => ToFrom (FullOuterJoin a (b, (ma :& mb) -> SqlExpr (Value Bool))) Source # | |
| (ToFrom a, ToFromT a ~ a', ToMaybe a', ma ~ ToMaybeT a', ToFrom b, ToFromT b ~ b', ErrorOnLateral b) => ToFrom (RightOuterJoin a (b, (ma :& b') -> SqlExpr (Value Bool))) Source # | |
| type ToMaybeT (a :& b) Source # | |
| type ToFromT (FullOuterJoin a (b, (ma :& mb) -> SqlExpr (Value Bool))) Source # | |
| Defined in Database.Esqueleto.Experimental | |
| type ToFromT (RightOuterJoin a (b, (ma :& b') -> SqlExpr (Value Bool))) Source # | |
| Defined in Database.Esqueleto.Experimental | |
Set Operations
Data type that represents SQL set operations. This includes
 UNION, UNION ALL, EXCEPT, and INTERSECT. These types form
 a binary tree, with SqlQuery values on the leaves.
Each function corresponding to the aforementioned set operations
 can be used as an infix in a from to help with readability
 and lead to code that closely resembles the underlying SQL. For example,
select $ from $
  (do
     a <- from Table A
     pure $ a ^. ASomeCol
  )
  `union_`
  (do
     b <- from Table B
     pure $ b ^. BSomeCol
  )
is translated into
SELECT * FROM ( (SELECT a.some_col FROM a) UNION (SELECT b.some_col FROM b) )
union_ :: a -> b -> Union a b Source #
UNION SQL set operation. Can be used as an infix function between SqlQuery values.
Constructors
| a `Union` b | 
unionAll_ :: a -> b -> UnionAll a b Source #
UNION ALL SQL set operation. Can be used as an infix function between SqlQuery values.
Constructors
| a `UnionAll` b | 
except_ :: a -> b -> Except a b Source #
EXCEPT SQL set operation. Can be used as an infix function between SqlQuery values.
Constructors
| a `Except` b | 
intersect_ :: a -> b -> Intersect a b Source #
INTERSECT SQL set operation. Can be used as an infix function between SqlQuery values.
Deprecated: Since: 3.4.0.0 - Use the intersect_ function instead of the Intersect data constructor
Constructors
| a `Intersect` b | Deprecated: Since: 3.4.0.0 - Use the  | 
pattern SelectQuery :: SqlQuery a -> SqlSetOperation a Source #
Deprecated: Since: 3.4.0.0 - It is no longer necessary to tag SqlQuery values with SelectQuery
Common Table Expressions
with :: (ToAlias a, ToAliasReference a, SqlSelect a r) => SqlQuery a -> SqlQuery (From a) Source #
WITH clause used to introduce a Common Table Expression (CTE).
 CTEs are supported in most modern SQL engines and can be useful
 in performance tuning. In Esqueleto, CTEs should be used as a
 subquery memoization tactic. When writing plain SQL, CTEs
 are sometimes used to organize the SQL code, in Esqueleto, this
 is better achieved through function that return SqlQuery values.
select $ do cte <- with subQuery cteResult <- from cte where_ $ cteResult ... pure cteResult
WARNING: In some SQL engines using a CTE can diminish performance. In these engines the CTE is treated as an optimization fence. You should always verify that using a CTE will in fact improve your performance over a regular subquery.
Since: 3.4.0.0
withRecursive :: (ToAlias a, ToAliasReference a, SqlSelect a r, RecursiveCteUnion unionKind) => SqlQuery a -> unionKind -> (From a -> SqlQuery a) -> SqlQuery (From a) Source #
WITH RECURSIVE allows one to make a recursive subquery, which can
 reference itself. Like WITH, this is supported in most modern SQL engines.
 Useful for hierarchical, self-referential data, like a tree of data.
select $ do
cte <- withRecursive
         (do $
             person <- from $ Table @Person
             where_ $ person ^. PersonId ==. val personId
             pure person
         )
         unionAll_
         (\self -> do $
             (p :& f :& p2 :& pSelf) <- from self
                      `InnerJoin` $ Table @Follow
                      `on` (\(p :& f) ->
                              p ^. PersonId ==. f ^. FollowFollower)
                      `InnerJoin` $ Table @Person
                      `on` (\(p :& f :& p2) ->
                              f ^. FollowFollowed ==. p2 ^. PersonId)
                      `LeftOuterJoin` self
                      `on` (\(_ :& _ :& p2 :& pSelf) ->
                              just (p2 ^. PersonId) ==. pSelf ?. PersonId)
             where_ $ isNothing (pSelf ?. PersonId)
             groupBy (p2 ^. PersonId)
             pure p2
         )
from cte
Since: 3.4.0.0
Internals
Instances
class ToMaybe a where Source #
Instances
| ToMaybe (SqlExpr (Maybe a)) Source # | |
| ToMaybe (SqlExpr (Entity a)) Source # | |
| ToMaybe (SqlExpr (Value a)) Source # | |
| (ToMaybe a, ToMaybe b) => ToMaybe (a, b) Source # | |
| (ToMaybe a, ToMaybe b) => ToMaybe (a :& b) Source # | |
| (ToMaybe a, ToMaybe b, ToMaybe c) => ToMaybe (a, b, c) Source # | |
| (ToMaybe a, ToMaybe b, ToMaybe c, ToMaybe d) => ToMaybe (a, b, c, d) Source # | |
| (ToMaybe a, ToMaybe b, ToMaybe c, ToMaybe d, ToMaybe e) => ToMaybe (a, b, c, d, e) Source # | |
| (ToMaybe a, ToMaybe b, ToMaybe c, ToMaybe d, ToMaybe e, ToMaybe f) => ToMaybe (a, b, c, d, e, f) Source # | |
| (ToMaybe a, ToMaybe b, ToMaybe c, ToMaybe d, ToMaybe e, ToMaybe f, ToMaybe g) => ToMaybe (a, b, c, d, e, f, g) Source # | |
| (ToMaybe a, ToMaybe b, ToMaybe c, ToMaybe d, ToMaybe e, ToMaybe f, ToMaybe g, ToMaybe h) => ToMaybe (a, b, c, d, e, f, g, h) Source # | |
class ToAlias a where Source #
Instances
Deprecated: This type alias doesn't do anything. Please delete it. Will be removed in the next release.
class ToAliasReference a where Source #
Methods
toAliasReference :: Ident -> a -> SqlQuery a Source #
Instances
type ToAliasReferenceT a = a Source #
Deprecated: This type alias doesn't do anything. Please delete it. Will be removed in the next release.
type family ValidOnClauseValue a :: Constraint where ... Source #
Constraint for on. Ensures that only types that require an on can be used on
 the left hand side. This was previously reusing the ToFrom class which was actually
 a bit too lenient as it allowed to much.
Since: 3.4.0.0
Equations
| ValidOnClauseValue (From a) = () | |
| ValidOnClauseValue (SqlQuery a) = () | |
| ValidOnClauseValue (SqlSetOperation a) = () | |
| ValidOnClauseValue (a -> SqlQuery b) = () | |
| ValidOnClauseValue _ = TypeError ('Text "Illegal use of ON") | 
The Normal Stuff
groupBy :: ToSomeValues a => a -> SqlQuery () Source #
GROUP BY clause. You can enclose multiple columns
 in a tuple.
select $from\(foo `InnerJoin` bar) -> doon(foo^.FooBarId==.bar^.BarId)groupBy(bar^.BarId, bar^.BarName) return (bar^.BarId, bar^.BarName, countRows)
With groupBy you can sort by aggregate functions, like so
 (we used let to restrict the more general countRows to
 SqlSqlExpr (Value Int) to avoid ambiguity---the second use of
 countRows has its type restricted by the :: Int below):
r <- select $from\(foo `InnerJoin` bar) -> doon(foo^.FooBarId==.bar^.BarId)groupBy$ bar^.BarName let countRows' =countRowsorderBy[asccountRows'] return (bar^.BarName, countRows') forM_ r $ \(Valuename,Valuecount) -> do print name print (count :: Int)
Need more columns?
The ToSomeValues class is defined for SqlExpr and tuples of SqlExprs.
 We only have definitions for up to 8 elements in a tuple right now, so it's
 possible that you may need to have more than 8 elements.
For example, consider a query with a groupBy call like this:
groupBy (e0, e1, e2, e3, e4, e5, e6, e7)
This is the biggest you can get with a single tuple. However, you can easily nest the tuples to add more:
groupBy ((e0, e1, e2, e3, e4, e5, e6, e7), e8, e9)
orderBy :: [SqlExpr OrderBy] -> SqlQuery () Source #
ORDER BY clause. See also asc and desc.
Multiple calls to orderBy get concatenated on the final
 query, including distinctOnOrderBy.
rand :: SqlExpr OrderBy Source #
Deprecated: Since 2.6.0: rand ordering function is not uniform across all databases! To avoid accidental partiality it will be removed in the next major version.
ORDER BY random() clause.
Since: 1.3.10
asc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy Source #
Ascending order of this field or SqlExpression.
desc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy Source #
Descending order of this field or SqlExpression.
distinctOn :: [SqlExpr DistinctOn] -> SqlQuery a -> SqlQuery a Source #
DISTINCT ON.  Change the current SELECT into
 SELECT DISTINCT ON (SqlExpressions).  For example:
select $from\foo ->distinctOn[don(foo ^. FooName),don(foo ^. FooState)] $ do ...
You can also chain different calls to distinctOn.  The
 above is equivalent to:
select $from\foo ->distinctOn[don(foo ^. FooName)] $distinctOn[don(foo ^. FooState)] $ do ...
Each call to distinctOn adds more SqlExpressions.  Calls to
 distinctOn override any calls to distinct.
Note that PostgreSQL requires the SqlExpressions on DISTINCT
 ON to be the first ones to appear on a ORDER BY.  This is
 not managed automatically by esqueleto, keeping its spirit
 of trying to be close to raw SQL.
Supported by PostgreSQL only.
Since: 2.2.4
don :: SqlExpr (Value a) -> SqlExpr DistinctOn Source #
Erase an SqlExpression's type so that it's suitable to
 be used by distinctOn.
Since: 2.2.4
distinctOnOrderBy :: [SqlExpr OrderBy] -> SqlQuery a -> SqlQuery a Source #
A convenience function that calls both distinctOn and
 orderBy.  In other words,
distinctOnOrderBy [asc foo, desc bar, desc quux] $ do
  ...
is the same as:
distinctOn[don foo, don bar, don quux] $ doorderBy[asc foo, desc bar, desc quux] ...
Since: 2.2.4
locking :: LockingKind -> SqlQuery () Source #
Add a locking clause to the query.  Please read
 LockingKind documentation and your RDBMS manual.
If multiple calls to locking are made on the same query,
 the last one is used.
Since: 2.2.7
sub_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a) Source #
Deprecated: sub_select sub_select is an unsafe function to use. If used with a SqlQuery that returns 0 results, then it may return NULL despite not mentioning Maybe in the return type. If it returns more than 1 result, then it will throw a SQL error. Instead, consider using one of the following alternatives: - subSelect: attaches a LIMIT 1 and the Maybe return type, totally safe. - subSelectMaybe: Attaches a LIMIT 1, useful for a query that already has a Maybe in the return type. - subSelectCount: Performs a count of the query - this is always safe. - subSelectUnsafe: Performs no checks or guarantees. Safe to use with countRows and friends.
Execute a subquery SELECT in an SqlExpression.  Returns a
 simple value so should be used only when the SELECT query
 is guaranteed to return just one row.
Deprecated in 3.2.0.
(^.) :: forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) infixl 9 Source #
Project a field of an entity.
(?.) :: (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ)) Source #
Project a field of an entity that may be null.
val :: PersistField typ => typ -> SqlExpr (Value typ) Source #
Lift a constant value from Haskell-land to the query.
isNothing :: PersistField typ => SqlExpr (Value (Maybe typ)) -> SqlExpr (Value Bool) Source #
IS NULL comparison.
For IS NOT NULL, you can negate this with not_, as in not_ (isNothing (person ^. PersonAge))
Warning: Persistent and Esqueleto have different behavior for != Nothing:
| Haskell | SQL | |
|---|---|---|
| Persistent |  | IS NOT NULL | 
| Esqueleto |  | != NULL | 
In SQL, = NULL and != NULL return NULL instead of true or false. For this reason, you very likely do not want to use !=. Nothinghlint rules helpful to enforce this:
- error: {lhs: v Database.Esqueleto.==. Database.Esqueleto.nothing, rhs: Database.Esqueleto.isNothing v, name: Use Esqueleto's isNothing}
- error: {lhs: v Database.Esqueleto.==. Database.Esqueleto.val Nothing, rhs: Database.Esqueleto.isNothing v, name: Use Esqueleto's isNothing}
- error: {lhs: v Database.Esqueleto.!=. Database.Esqueleto.nothing, rhs: not_ (Database.Esqueleto.isNothing v), name: Use Esqueleto's not isNothing}
- error: {lhs: v Database.Esqueleto.!=. Database.Esqueleto.val Nothing, rhs: not_ (Database.Esqueleto.isNothing v), name: Use Esqueleto's not isNothing}withNonNull :: PersistField typ => SqlExpr (Value (Maybe typ)) -> (SqlExpr (Value typ) -> SqlQuery a) -> SqlQuery a Source #
Project an SqlExpression that may be null, guarding against null cases.
countDistinct :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a) Source #
COUNT(DISTINCT x).
Since: 2.4.1
(==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 Source #
(>=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 Source #
(>.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 Source #
(<=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 Source #
(<.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 Source #
(!=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) infix 4 Source #
between :: PersistField a => SqlExpr (Value a) -> (SqlExpr (Value a), SqlExpr (Value a)) -> SqlExpr (Value Bool) Source #
BETWEEN.
@since: 3.1.0
(+.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a) infixl 6 Source #
(-.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a) infixl 6 Source #
(/.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a) infixl 7 Source #
(*.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a) infixl 7 Source #
round_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b) Source #
ceiling_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b) Source #
floor_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b) Source #
sum_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b)) Source #
avg_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b)) Source #
castNum :: (Num a, Num b) => SqlExpr (Value a) -> SqlExpr (Value b) Source #
Allow a number of one type to be used as one of another type via an implicit cast. An explicit cast is not made, this function changes only the types on the Haskell side.
Caveat: Trying to use castNum from Double to Int
 will not result in an integer, the original fractional
 number will still be used!  Use round_, ceiling_ or
 floor_ instead.
Safety: This operation is mostly safe due to the Num
 constraint between the types and the fact that RDBMSs
 usually allow numbers of different types to be used
 interchangeably.  However, there may still be issues with
 the query not being accepted by the RDBMS or persistent
 not being able to parse it.
Since: 2.2.9
castNumM :: (Num a, Num b) => SqlExpr (Value (Maybe a)) -> SqlExpr (Value (Maybe b)) Source #
Same as castNum, but for nullable values.
Since: 2.2.9
coalesce :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value (Maybe a)) Source #
COALESCE function. Evaluates the arguments in order and
 returns the value of the first non-NULL SqlExpression, or NULL
 (Nothing) otherwise. Some RDBMSs (such as SQLite) require
 at least two arguments; please refer to the appropriate
 documentation.
Since: 1.4.3
coalesceDefault :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value a) -> SqlExpr (Value a) Source #
Like coalesce, but takes a non-nullable SqlExpression
 placed at the end of the SqlExpression list, which guarantees
 a non-NULL result.
Since: 1.4.3
upper_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) Source #
UPPER function.
 @since 3.3.0
ltrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) Source #
LTRIM function.
 @since 3.3.0
rtrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) Source #
RTRIM function.
 @since 3.3.0
length_ :: (SqlString s, Num a) => SqlExpr (Value s) -> SqlExpr (Value a) Source #
LENGTH function.
 @since 3.3.0
left_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s) Source #
LEFT function.
 @since 3.3.0
right_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s) Source #
RIGHT function.
 @since 3.3.0
like :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool) infixr 2 Source #
LIKE operator.
ilike :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool) infixr 2 Source #
ILIKE operator (case-insensitive LIKE).
Supported by PostgreSQL only.
Since: 2.2.3
concat_ :: SqlString s => [SqlExpr (Value s)] -> SqlExpr (Value s) Source #
The CONCAT function with a variable number of
 parameters.  Supported by MySQL and PostgreSQL.
(++.) :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value s) infixr 5 Source #
castString :: (SqlString s, SqlString r) => SqlExpr (Value s) -> SqlExpr (Value r) Source #
Cast a string type into Text.  This function
 is very useful if you want to use newtypes, or if you want
 to apply functions such as like to strings of different
 types.
Safety: This is a slightly unsafe function, especially if
 you have defined your own instances of SqlString.  Also,
 since Maybe is an instance of SqlString, it's possible
 to turn a nullable value into a non-nullable one.  Avoid
 using this function if possible.
subList_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a) Source #
Execute a subquery SELECT in an SqlExpression.  Returns a
 list of values.
valList :: PersistField typ => [typ] -> SqlExpr (ValueList typ) Source #
Lift a list of constant value from Haskell-land to the query.
in_ :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool) Source #
IN operator. For example if you want to select all Persons by a list
 of IDs:
SELECT * FROM Person WHERE Person.id IN (?)
In esqueleto, we may write the same query above as:
select $from$ \person -> dowhere_$ person^.PersonId `in_`valListpersonIds return person
Where personIds is of type [Key Person].
notIn :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool) Source #
NOT IN operator.
set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery () Source #
SET clause used on UPDATEs.  Note that while it's not
 a type error to use this function on a SELECT, it will
 most certainly result in a runtime error.
(=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val) infixr 3 Source #
(+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val) infixr 3 Source #
(-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val) infixr 3 Source #
(*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val) infixr 3 Source #
(/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val) infixr 3 Source #
case_ :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a) Source #
CASE statement.  For example:
select $ return $case_[when_(exists$from$ \p -> dowhere_(p^.PersonName==.val"Mike"))then_(sub_select$from$ \v -> do let sub =from$ \c -> dowhere_(c^.PersonName==.val"Mike") return (c^.PersonFavNum)where_(v^.PersonFavNum >.sub_selectsub) return $count(v^.PersonName) +.val(1 :: Int)) ] (else_$val(-1))
This query is a bit complicated, but basically it checks if a person
 named "Mike" exists, and if that person does, run the subquery to find
 out how many people have a ranking (by Fav Num) higher than "Mike".
NOTE: There are a few things to be aware about this statement.
- This only implements the full CASE statement, it does not implement the "simple" CASE statement.
- At least one when_andthen_is mandatory otherwise it will emit an error.
- The else_is also mandatory, unlike the SQL statement in which if theELSEis omitted it will return aNULL. You can reproduce this vianothing.
Since: 2.1.2
toBaseId :: ToBaseId ent => SqlExpr (Value (Key ent)) -> SqlExpr (Value (Key (BaseEnt ent))) Source #
Convert an entity's key into another entity's.
This function is to be used when you change an entity's Id to be
 that of another entity. For example:
Bar barNum Int Foo bar BarId fooNum Int Primary bar
In this example, Bar is said to be the BaseEnt(ity), and Foo the child. To model this in Esqueleto, declare:
instance ToBaseId Foo where type BaseEnt Foo = Bar toBaseIdWitness barId = FooKey barId
Now you're able to write queries such as:
select$from$ (bar `InnerJoin` foo) -> doon(toBaseId(foo^.FooId)==.bar^.BarId) return (bar, foo)
Note: this function may be unsafe to use in conditions not like the one of the example above.
Since: 2.4.3
subSelect :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value (Maybe a)) Source #
Execute a subquery SELECT in a SqlExpr. The query passed to this
 function will only return a single result - it has a LIMIT 1 passed in to
 the query to make it safe, and the return type is Maybe to indicate that
 the subquery might result in 0 rows.
If you find yourself writing joinV . subSelectsubSelectMaybe.
If you're performing a countRows, then you can use subSelectCount which
 is safe.
If you know that the subquery will always return exactly one row (eg
 a foreign key constraint guarantees that you'll get exactly one row), then
 consider subSelectUnsafe, along with a comment explaining why it is safe.
Since: 3.2.0
subSelectMaybe :: PersistField a => SqlQuery (SqlExpr (Value (Maybe a))) -> SqlExpr (Value (Maybe a)) Source #
Execute a subquery SELECT in a SqlExpr. This function is a shorthand
 for the common joinV . subSelectsubSelect on an expression that would be Maybe already.
As an example, you would use this function when calling sum_ or max_,
 which have Maybe in the result type (for a 0 row query).
Since: 3.2.0
subSelectCount :: (Num a, PersistField a) => SqlQuery ignored -> SqlExpr (Value a) Source #
Performs a COUNT of the given query in a subSelect manner. This is
 always guaranteed to return a result value, and is completely safe.
Since: 3.2.0
Arguments
| :: (BackendCompatible SqlBackend (PersistEntityBackend val1), PersistEntity val1, PersistEntity val2, PersistField a) | |
| => SqlExpr (Entity val2) | An expression representing the table you have access to now. | 
| -> EntityField val2 (Key val1) | The foreign key field on the table. | 
| -> (SqlExpr (Entity val1) -> SqlExpr (Value a)) | A function to extract a value from the foreign reference table. | 
| -> SqlExpr (Value a) | 
Performs a sub-select using the given foreign key on the entity. This is useful to extract values that are known to be present by the database schema.
As an example, consider the following persistent definition:
User profile ProfileId Profile name Text
The following query will return the name of the user.
getUserWithName =
    select $
    from $ user ->
    pure (user, subSelectForeign user UserProfile (^. ProfileName)
Since: 3.2.0
subSelectList :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a) Source #
Execute a subquery SELECT in a SqlExpr that returns a list. This is an
 alias for subList_select and is provided for symmetry with the other safe
 subselect functions.
Since: 3.2.0
subSelectUnsafe :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a) Source #
Execute a subquery SELECT in a SqlExpr. This function is unsafe,
 because it can throw runtime exceptions in two cases:
- If the query passed has 0 result rows, then it will return a NULLvalue. Thepersistentparsing operations will fail on an unexpectedNULL.
- If the query passed returns more than one row, then the SQL engine will fail with an error like "More than one row returned by a subquery used as an expression".
This function is safe if you guarantee that exactly one row will be returned,
 or if the result already has a Maybe type for some reason.
For variants with the safety encoded already, see subSelect and
 subSelectMaybe. For the most common safe use of this, see subSelectCount.
Since: 3.2.0
when_ :: expr (Value Bool) -> () -> expr a -> (expr (Value Bool), expr a) Source #
Syntax sugar for case_.
Since: 2.1.2
A single value (as opposed to a whole entity).  You may use
 ( or ^.)( to get a ?.)Value from an Entity.
Instances
A list of single values.  There's a limited set of functions
 able to work with this data type (such as subList_select,
 valList, in_ and exists).
Constructors
| ValueList a | 
Instances
| Eq a => Eq (ValueList a) Source # | |
| Ord a => Ord (ValueList a) Source # | |
| Defined in Database.Esqueleto.Internal.Internal | |
| Show a => Show (ValueList a) Source # | |
data DistinctOn Source #
Phantom type used by distinctOn and don.
data LockingKind Source #
Different kinds of locking clauses supported by locking.
Note that each RDBMS has different locking support.  The
 constructors of this datatype specify only the syntax of the
 locking mechanism, not its semantics.  For example, even
 though both MySQL and PostgreSQL support ForUpdate, there
 are no guarantees that they will behave the same.
Since: 2.2.7
Constructors
| ForUpdate | 
 Since: 2.2.7 | 
| ForUpdateSkipLocked | 
 Since: 2.2.7 | 
| ForShare | 
 Since: 2.2.7 | 
| LockInShareMode | 
 Since: 2.2.7 | 
class PersistField a => SqlString a Source #
Phantom class of data types that are treated as strings by the RDBMS. It has no methods because it's only used to avoid type errors such as trying to concatenate integers.
If you have a custom data type or newtype, feel free to make
 it an instance of this class.
Since: 2.4.0
Instances
| SqlString ByteString Source # | Since: 2.3.0 | 
| Defined in Database.Esqueleto.Internal.Internal | |
| SqlString Text Source # | Since: 2.3.0 | 
| Defined in Database.Esqueleto.Internal.Internal | |
| SqlString Text Source # | Since: 2.3.0 | 
| Defined in Database.Esqueleto.Internal.Internal | |
| SqlString Html Source # | Since: 2.3.0 | 
| Defined in Database.Esqueleto.Internal.Internal | |
| a ~ Char => SqlString [a] Source # | Since: 2.3.0 | 
| Defined in Database.Esqueleto.Internal.Internal | |
| SqlString a => SqlString (Maybe a) Source # | Since: 2.4.0 | 
| Defined in Database.Esqueleto.Internal.Internal | |
Joins
data InnerJoin a b infixl 2 Source #
Data type that represents an INNER JOIN (see LeftOuterJoin for an example).
Constructors
| a `InnerJoin` b infixl 2 | 
Instances
| IsJoinKind InnerJoin Source # | |
| Defined in Database.Esqueleto.Internal.Internal | |
| FromPreprocess (InnerJoin a b) => From (InnerJoin a b) Source # | |
| ToInnerJoin (IsLateral b) a b b' => ToFrom (InnerJoin a (b, b' -> SqlExpr (Value Bool))) Source # | |
| ToFrom (InnerJoin a b) Source # | |
| type ToFromT (InnerJoin a (b, b' -> SqlExpr (Value Bool))) Source # | |
| type ToFromT (InnerJoin a b) Source # | |
| Defined in Database.Esqueleto.Experimental | |
data CrossJoin a b infixl 2 Source #
Data type that represents a CROSS JOIN (see LeftOuterJoin for an example).
Constructors
| a `CrossJoin` b infixl 2 | 
Instances
| IsJoinKind CrossJoin Source # | |
| Defined in Database.Esqueleto.Internal.Internal | |
| FromPreprocess (CrossJoin a b) => From (CrossJoin a b) Source # | |
| (ToFrom a, ToFromT a ~ a', SqlSelect b r, ToAlias b, ToAliasReference b) => ToFrom (CrossJoin a (a' -> SqlQuery b)) Source # | |
| (ToFrom a, ToFrom b, ToFromT (CrossJoin a b) ~ (ToFromT a :& ToFromT b)) => ToFrom (CrossJoin a b) Source # | |
| type ToFromT (CrossJoin a (a' -> SqlQuery b)) Source # | |
| Defined in Database.Esqueleto.Experimental | |
| type ToFromT (CrossJoin a b) Source # | |
| Defined in Database.Esqueleto.Experimental | |
data LeftOuterJoin a b infixl 2 Source #
Data type that represents a LEFT OUTER JOIN. For example,
select $from$ \(person `LeftOuterJoin` pet) -> ...
is translated into
SELECT ... FROM Person LEFT OUTER JOIN Pet ...
See also: from.
Constructors
| a `LeftOuterJoin` b infixl 2 | 
Instances
| IsJoinKind LeftOuterJoin Source # | |
| Defined in Database.Esqueleto.Internal.Internal Methods smartJoin :: a -> b -> LeftOuterJoin a b Source # reifyJoinKind :: LeftOuterJoin a b -> JoinKind Source # | |
| FromPreprocess (LeftOuterJoin a b) => From (LeftOuterJoin a b) Source # | |
| Defined in Database.Esqueleto.Internal.Internal Methods from_ :: SqlQuery (LeftOuterJoin a b) Source # | |
| ToLeftJoin (IsLateral b) a b b' => ToFrom (LeftOuterJoin a (b, b' -> SqlExpr (Value Bool))) Source # | |
| ToFrom (LeftOuterJoin a b) Source # | |
| Defined in Database.Esqueleto.Experimental Associated Types type ToFromT (LeftOuterJoin a b) Source # Methods toFrom :: LeftOuterJoin a b -> From (ToFromT (LeftOuterJoin a b)) Source # | |
| type ToFromT (LeftOuterJoin a (b, b' -> SqlExpr (Value Bool))) Source # | |
| Defined in Database.Esqueleto.Experimental | |
| type ToFromT (LeftOuterJoin a b) Source # | |
| Defined in Database.Esqueleto.Experimental | |
data RightOuterJoin a b infixl 2 Source #
Data type that represents a RIGHT OUTER JOIN (see LeftOuterJoin for an example).
Constructors
| a `RightOuterJoin` b infixl 2 | 
Instances
| IsJoinKind RightOuterJoin Source # | |
| Defined in Database.Esqueleto.Internal.Internal Methods smartJoin :: a -> b -> RightOuterJoin a b Source # reifyJoinKind :: RightOuterJoin a b -> JoinKind Source # | |
| FromPreprocess (RightOuterJoin a b) => From (RightOuterJoin a b) Source # | |
| Defined in Database.Esqueleto.Internal.Internal Methods from_ :: SqlQuery (RightOuterJoin a b) Source # | |
| (ToFrom a, ToFromT a ~ a', ToMaybe a', ma ~ ToMaybeT a', ToFrom b, ToFromT b ~ b', ErrorOnLateral b) => ToFrom (RightOuterJoin a (b, (ma :& b') -> SqlExpr (Value Bool))) Source # | |
| ToFrom (RightOuterJoin a b) Source # | |
| Defined in Database.Esqueleto.Experimental Associated Types type ToFromT (RightOuterJoin a b) Source # Methods toFrom :: RightOuterJoin a b -> From (ToFromT (RightOuterJoin a b)) Source # | |
| type ToFromT (RightOuterJoin a (b, (ma :& b') -> SqlExpr (Value Bool))) Source # | |
| Defined in Database.Esqueleto.Experimental | |
| type ToFromT (RightOuterJoin a b) Source # | |
| Defined in Database.Esqueleto.Experimental | |
data FullOuterJoin a b infixl 2 Source #
Data type that represents a FULL OUTER JOIN (see LeftOuterJoin for an example).
Constructors
| a `FullOuterJoin` b infixl 2 | 
Instances
(Internal) A kind of JOIN.
Constructors
| InnerJoinKind | INNER JOIN | 
| CrossJoinKind | CROSS JOIN | 
| LeftOuterJoinKind | LEFT OUTER JOIN | 
| RightOuterJoinKind | RIGHT OUTER JOIN | 
| FullOuterJoinKind | FULL OUTER JOIN | 
data OnClauseWithoutMatchingJoinException Source #
Exception thrown whenever on is used to create an ON
 clause but no matching JOIN is found.
Constructors
| OnClauseWithoutMatchingJoinException String | 
Instances
SQL backend
SQL backend for esqueleto using SqlPersistT.
Instances
| Monad SqlQuery Source # | |
| Functor SqlQuery Source # | |
| Applicative SqlQuery Source # | |
| (ToAlias a, ToAliasReference a, SqlSelect a r) => ToFrom (SqlQuery a) Source # | |
| (ToFrom a, ToFromT a ~ a', SqlSelect b r, ToAlias b, ToAliasReference b) => ToFrom (CrossJoin a (a' -> SqlQuery b)) Source # | |
| type ToFromT (SqlQuery a) Source # | |
| Defined in Database.Esqueleto.Experimental | |
| type ToFromT (CrossJoin a (a' -> SqlQuery b)) Source # | |
| Defined in Database.Esqueleto.Experimental | |
An expression on the SQL backend.
There are many comments describing the constructors of this data type. However, Haddock doesn't like GADTs, so you'll have to read them by hitting "Source".
Instances
type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend) Source #
Constraint synonym for persistent entities whose backend
 is SqlBackend.
select :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r] Source #
Execute an esqueleto SELECT query inside persistent's
 SqlPersistT monad and return a list of rows.
We've seen that from has some magic about which kinds of
 things you may bring into scope.  This select function also
 has some magic for which kinds of things you may bring back to
 Haskell-land by using SqlQuery's return:
- You may return a SqlExpr (for an entityEntityv)v(i.e., like the*in SQL), which is then returned to Haskell-land as justEntity v.
- You may return a SqlExpr (Maybe (Entity v))for an entityvthat may beNULL, which is then returned to Haskell-land asMaybe (Entity v). Used forOUTER JOINs.
- You may return a SqlExpr (for a valueValuet)t(i.e., a single column), wheretis any instance ofPersistField, which is then returned to Haskell-land asValue t. You may useValueto return projections of anEntity(see(and^.)() or to return any other value calculated on the query (e.g.,?.)countRowsorsubSelect).
The SqlSelect a r class has functional dependencies that
 allow type information to flow both from a to r and
 vice-versa.  This means that you'll almost never have to give
 any type signatures for esqueleto queries.  For example, the
 query select $ from $ \p -> return p
do ps <-select$from$ \p -> return p liftIO $ mapM_ (putStrLn . personName . entityVal) ps
we are able to infer from that single personName . entityVal
 function composition that the p inside the query is of type
 SqlExpr (Entity Person).
selectSource :: (SqlSelect a r, BackendCompatible SqlBackend backend, IsPersistBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend, MonadResource m) => SqlQuery a -> ConduitT () r (ReaderT backend m) () Source #
Execute an esqueleto SELECT query inside persistent's
 SqlPersistT monad and return a Source of rows.
delete :: MonadIO m => SqlQuery () -> SqlWriteT m () Source #
Execute an esqueleto DELETE query inside persistent's
 SqlPersistT monad.  Note that currently there are no type
 checks for statements that should not appear on a DELETE
 query.
Example of usage:
delete$from$ \appointment ->where_(appointment^.AppointmentDate<.valnow)
Unlike select, there is a useful way of using delete that
 will lead to type ambiguities.  If you want to delete all rows
 (i.e., no where_ clause), you'll have to use a type signature:
delete$from$ \(appointment ::SqlExpr(EntityAppointment)) -> return ()
deleteCount :: MonadIO m => SqlQuery () -> SqlWriteT m Int64 Source #
Same as delete, but returns the number of rows affected.
update :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m () Source #
Execute an esqueleto UPDATE query inside persistent's
 SqlPersistT monad.  Note that currently there are no type
 checks for statements that should not appear on a UPDATE
 query.
Example of usage:
update$ \p -> dosetp [ PersonAge=.just(valthisYear) -. p^.PersonBorn ]where_$ isNothing (p^.PersonAge)
updateCount :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m Int64 Source #
Same as update, but returns the number of rows affected.
insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m () Source #
Insert a PersistField for every selected value.
Since: 2.4.2
insertSelectCount :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m Int64 Source #
Insert a PersistField for every selected value, return the count afterward
(<#) :: (a -> b) -> SqlExpr (Value a) -> SqlExpr (Insertion b) Source #
Apply a PersistField constructor to SqlExpr Value arguments.
(<&>) :: SqlExpr (Insertion (a -> b)) -> SqlExpr (Value a) -> SqlExpr (Insertion b) Source #
Apply extra SqlExpr Value arguments to a PersistField constructor
Rendering Queries
Arguments
| :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) | |
| => Mode | |
| -> SqlQuery a | The SQL query you want to render. | 
| -> ReaderT backend m (Text, [PersistValue]) | 
Renders a SqlQuery into a Text value along with the list of
 PersistValues that would be supplied to the database for ? placeholders.
You must ensure that the Mode you pass to this function corresponds with
 the actual SqlQuery. If you pass a query that uses incompatible features
 (like an INSERT statement with a SELECT mode) then you'll get a weird
 result.
Since: 3.1.1
Arguments
| :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) | |
| => SqlQuery a | The SQL query you want to render. | 
| -> ReaderT backend m (Text, [PersistValue]) | 
Renders a SqlQuery into a Text value along with the list of
 PersistValues that would be supplied to the database for ? placeholders.
Since: 3.1.1
Arguments
| :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) | |
| => SqlQuery a | The SQL query you want to render. | 
| -> ReaderT backend m (Text, [PersistValue]) | 
Renders a SqlQuery into a Text value along with the list of
 PersistValues that would be supplied to the database for ? placeholders.
Since: 3.1.1
Arguments
| :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) | |
| => SqlQuery a | The SQL query you want to render. | 
| -> ReaderT backend m (Text, [PersistValue]) | 
Renders a SqlQuery into a Text value along with the list of
 PersistValues that would be supplied to the database for ? placeholders.
Since: 3.1.1
renderQueryInsertInto Source #
Arguments
| :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) | |
| => SqlQuery a | The SQL query you want to render. | 
| -> ReaderT backend m (Text, [PersistValue]) | 
Renders a SqlQuery into a Text value along with the list of
 PersistValues that would be supplied to the database for ? placeholders.
Since: 3.1.1
Internal.Language
RDBMS-specific modules
Helpers
valkey :: (ToBackendKey SqlBackend entity, PersistField (Key entity)) => Int64 -> SqlExpr (Value (Key entity)) Source #
valkey i = 
 (https://github.com/prowdsponsor/esqueleto/issues/9).val . toSqlKey
valJ :: PersistField (Key entity) => Value (Key entity) -> SqlExpr (Value (Key entity)) Source #
valJ is like val but for something that is already a Value. The use
 case it was written for was, given a Value lift the Key for that Value
 into the query expression in a type safe way. However, the implementation is
 more generic than that so we call it valJ.
Its important to note that the input entity and the output entity are constrained to be the same by the type signature on the function (https://github.com/prowdsponsor/esqueleto/pull/69).
Since: 1.4.2
associateJoin :: forall e1 e0. Ord (Key e0) => [(Entity e0, e1)] -> Map (Key e0) (e0, [e1]) Source #
Avoid N+1 queries and join entities into a map structure
 
 getFoosAndNestedBarsFromParent :: ParentId -> (Map (Key Foo) (Foo, [Maybe (Entity Bar)]))
 getFoosAndNestedBarsFromParent parentId = fmap associateJoin $ select $
 from $ \(foo `LeftOuterJoin` bar) -> do
   on (bar ?. BarFooId ==. foo ^. FooId)
   where_ (foo ^. FooParentId ==. val parentId)
   pure (foo, bar)
 
Since: 3.1.2
Re-exports
deleteKey :: (PersistStore backend, BaseBackend backend ~ PersistEntityBackend val, MonadIO m, PersistEntity val) => Key val -> ReaderT backend m () Source #
toJsonText :: ToJSON j => j -> Text #
entityIdFromJSON :: (PersistEntity record, FromJSON record) => Value -> Parser (Entity record) #
Predefined parseJSON. The input JSON looks like
 {"id": 1, "name": ...}.
The typical usage is:
instance FromJSON (Entity User) where
    parseJSON = entityIdFromJSON
entityIdToJSON :: (PersistEntity record, ToJSON record) => Entity record -> Value #
Predefined toJSON. The resulting JSON looks like
 {"id": 1, "name": ...}.
The typical usage is:
instance ToJSON (Entity User) where
    toJSON = entityIdToJSON
entityValues :: PersistEntity record => Entity record -> [PersistValue] #
Get list of values corresponding to given entity.
fromPersistValueJSON :: FromJSON a => PersistValue -> Either Text a #
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
keyValueEntityFromJSON :: (PersistEntity record, FromJSON record) => Value -> Parser (Entity record) #
Predefined parseJSON. The input JSON looks like
 {"key": 1, "value": {"name": ...}}.
The typical usage is:
instance FromJSON (Entity User) where
    parseJSON = keyValueEntityFromJSON
keyValueEntityToJSON :: (PersistEntity record, ToJSON record) => Entity record -> Value #
Predefined toJSON. The resulting JSON looks like
 {"key": 1, "value": {"name": ...}}.
The typical usage is:
instance ToJSON (Entity User) where
    toJSON = keyValueEntityToJSON
toPersistValueJSON :: ToJSON a => a -> PersistValue #
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
selectKeys :: forall record backend (m :: Type -> Type). (PersistQueryRead backend, MonadResource m, PersistRecordBackend record backend, MonadReader backend m) => [Filter record] -> [SelectOpt record] -> ConduitM () (Key record) m () #
Get the Keys of all records matching the given criterion.
belongsTo :: forall ent1 ent2 backend (m :: Type -> Type). (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Maybe (Key ent2)) -> ent1 -> ReaderT backend m (Maybe ent2) #
Curry this to make a convenience function that loads an associated model.
foreign = belongsTo foreignId
belongsToJust :: forall ent1 ent2 backend (m :: Type -> Type). (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Key ent2) -> ent1 -> ReaderT backend m ent2 #
Same as belongsTo, but uses getJust and therefore is similarly unsafe.
getEntity :: forall e backend (m :: Type -> Type). (PersistStoreRead backend, PersistRecordBackend e backend, MonadIO m) => Key e -> ReaderT backend m (Maybe (Entity e)) #
Like get, but returns the complete Entity.
Example usage
getSpjEntity :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User)) getSpjEntity = getEntity spjId
mSpjEnt <- getSpjEntity
The above query when applied on dataset-1, will get this entity:
+----+------+-----+ | id | name | age | +----+------+-----+ | 1 | SPJ | 40 | +----+------+-----+
getJust :: forall record backend (m :: Type -> Type). (PersistStoreRead backend, PersistRecordBackend record backend, MonadIO m) => Key record -> ReaderT backend m record #
Same as get, but for a non-null (not Maybe) foreign key.
 Unsafe unless your database is enforcing that the foreign key is valid.
Example usage
getJustSpj :: MonadIO m => ReaderT SqlBackend m User getJustSpj = getJust spjId
spj <- getJust spjId
The 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 unknownId
mrx <- getJustUnknown
This just throws an error.
getJustEntity :: forall record backend (m :: Type -> Type). (PersistEntityBackend record ~ BaseBackend backend, MonadIO m, PersistEntity record, PersistStoreRead backend) => Key record -> ReaderT backend m (Entity record) #
Same as getJust, but returns an Entity instead of just the record.
Example usage
getJustEntitySpj :: MonadIO m => ReaderT SqlBackend m (Entity User) getJustEntitySpj = getJustEntity spjId
spjEnt <- getJustEntitySpj
The above query when applied on dataset-1, will get this entity:
+----+------+-----+ | id | name | age | +----+------+-----+ | 1 | SPJ | 40 | +----+------+-----+
Since: persistent-2.6.1
insertEntity :: forall e backend (m :: Type -> Type). (PersistStoreWrite backend, PersistRecordBackend e backend, MonadIO m) => e -> ReaderT backend m (Entity e) #
Like insert, but returns the complete Entity.
Example usage
insertHaskellEntity :: MonadIO m => ReaderT SqlBackend m (Entity User) insertHaskellEntity = insertEntity $ User "Haskell" 81
haskellEnt <- insertHaskellEntity
The above query when applied on dataset-1, will produce this:
+----+---------+-----+ | id | name | age | +----+---------+-----+ | 1 | SPJ | 40 | +----+---------+-----+ | 2 | Simon | 41 | +----+---------+-----+ | 3 | Haskell | 81 | +----+---------+-----+
insertRecord :: forall record backend (m :: Type -> Type). (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStoreWrite backend) => record -> ReaderT backend m record #
Like insertEntity but just returns the record instead of Entity.
Example usage
insertDaveRecord :: MonadIO m => ReaderT SqlBackend m User insertDaveRecord = insertRecord $ User "Dave" 50
dave <- insertDaveRecord
The above query when applied on dataset-1, will produce this:
+-----+------+-----+ |id |name |age | +-----+------+-----+ |1 |SPJ |40 | +-----+------+-----+ |2 |Simon |41 | +-----+------+-----+ |3 |Dave |50 | +-----+------+-----+
Since: persistent-2.6.1
liftPersist :: (MonadIO m, MonadReader backend m) => ReaderT backend IO b -> m b #
checkUnique :: forall record backend (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, PersistUniqueRead backend) => record -> ReaderT backend m (Maybe (Unique record)) #
Check 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
Example usage
getByValue :: forall record (m :: Type -> Type) backend. (MonadIO m, PersistUniqueRead backend, PersistRecordBackend record backend, AtLeastOneUniqueKey record) => record -> ReaderT backend m (Maybe (Entity record)) #
A 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.
Example usage
insertBy :: forall record backend (m :: Type -> Type). (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend, AtLeastOneUniqueKey record) => record -> ReaderT backend m (Either (Entity record) (Key record)) #
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.
Example usage
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" 100
First three lines return Left because there're duplicates in given record's uniqueness constraints. While the last line returns a new key as Right.
insertUniqueEntity :: forall record backend (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, PersistUniqueWrite backend) => record -> ReaderT backend m (Maybe (Entity record)) #
Like insertEntity, but returns Nothing when the record
 couldn't be inserted because of a uniqueness constraint.
Example usage
We use schema-2 and dataset-1 here.
insertUniqueSpjEntity :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User)) insertUniqueSpjEntity = insertUniqueEntity $ User "SPJ" 50
mSpjEnt <- insertUniqueSpjEntity
The above query results Nothing as SPJ already exists.
insertUniqueAlexaEntity :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User)) insertUniqueAlexaEntity = insertUniqueEntity $ User "Alexa" 3
mAlexaEnt <- insertUniqueSpjEntity
Because 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 | +----+-------+-----+
Since: persistent-2.7.1
onlyUnique :: forall record backend (m :: Type -> Type). (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend, OnlyOneUniqueKey record) => record -> ReaderT backend m (Unique record) #
Return the single unique key for a record.
Example usage
We use shcema-1 and dataset-1 here.
onlySimonConst :: MonadIO m => ReaderT SqlBackend m (Unique User) onlySimonConst = onlyUnique $ User "Simon" 999
mSimonConst <- onlySimonConst
mSimonConst 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.
replaceUnique :: forall record backend (m :: Type -> Type). (MonadIO m, Eq (Unique record), PersistRecordBackend record backend, PersistUniqueWrite backend) => Key record -> record -> ReaderT backend m (Maybe (Unique record)) #
Attempt to replace the record of the given key with the given new record. First query the unique fields to make sure the replacement maintains uniqueness constraints.
Return Nothing if the replacement was made.
 If uniqueness is violated, return a Just with the Unique violation
Since: persistent-1.2.2.0
transactionSave :: forall (m :: Type -> Type). MonadIO m => ReaderT SqlBackend m () #
Commit 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).
Since: persistent-1.2.0
transactionUndo :: forall (m :: Type -> Type). MonadIO m => ReaderT SqlBackend m () #
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.
Since: persistent-1.2.0
defaultAttribute :: [FieldAttr] -> Maybe Text #
mkColumns :: [EntityDef] -> EntityDef -> BackendSpecificOverrides -> ([Column], [UniqueDef], [ForeignDef]) #
Create the list of columns for the given entity.
getMigration :: forall (m :: Type -> Type). (MonadIO m, HasCallStack) => Migration -> ReaderT SqlBackend m [Sql] #
parseMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m (Either [Text] CautiousMigration) #
Given a Migration, this parses it and returns either a list of
 errors associated with the migration or a list of migrations to do.
parseMigration' :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m CautiousMigration #
Like parseMigration, but instead of returning the value in an
 Either value, it calls error on the error values.
printMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m () #
Prints a migration.
runMigration :: forall (m :: Type -> Type). MonadIO m => Migration -> ReaderT SqlBackend m () #
Runs a migration. If the migration fails to parse or if any of the
 migrations are unsafe, then this throws a PersistUnsafeMigrationException.
runMigrationSilent :: forall (m :: Type -> Type). MonadUnliftIO m => Migration -> ReaderT SqlBackend m [Text] #
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!
runMigrationUnsafe :: forall (m :: Type -> Type). MonadIO m => Migration -> ReaderT SqlBackend m () #
Like runMigration, but this will perform the unsafe database
 migrations instead of erroring out.
showMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m [Text] #
decorateSQLWithLimitOffset :: Text -> (Int, Int) -> Text -> Text #
Generates sql for limit and offset for postgres, sqlite and mysql.
fieldDBName :: PersistEntity record => EntityField record typ -> FieldNameDB #
useful for a backend to implement fieldName by adding escaping
fromSqlKey :: ToBackendKey SqlBackend record => Key record -> Int64 #
getFieldName :: forall record typ (m :: Type -> Type) backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, BackendCompatible SqlBackend backend, Monad m) => EntityField record typ -> ReaderT backend m Text #
get the SQL string for the field that an EntityField represents Useful for raw SQL queries
Your backend may provide a more convenient fieldName function which does not operate in a Monad
getTableName :: forall record (m :: Type -> Type) backend. (PersistEntity record, BackendCompatible SqlBackend backend, Monad m) => record -> ReaderT backend m Text #
get the SQL string for the table that a PeristEntity represents Useful for raw SQL queries
Your backend may provide a more convenient tableName function which does not operate in a Monad
tableDBName :: PersistEntity record => record -> EntityNameDB #
useful for a backend to implement tableName by adding escaping
toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record #
withRawQuery :: forall (m :: Type -> Type) a. MonadIO m => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> ReaderT SqlBackend m a #
getStmtConn :: SqlBackend -> Text -> IO Statement #
Arguments
| :: forall (m :: Type -> Type) backend. (MonadIO m, BackendCompatible SqlBackend backend) | |
| => Text | SQL statement, possibly with placeholders. | 
| -> [PersistValue] | Values to fill the placeholders. | 
| -> ReaderT backend m () | 
Execute a raw SQL statement
Arguments
| :: forall (m :: Type -> Type) backend. (MonadIO m, BackendCompatible SqlBackend backend) | |
| => Text | SQL statement, possibly with placeholders. | 
| -> [PersistValue] | Values to fill the placeholders. | 
| -> ReaderT backend m Int64 | 
Execute a raw SQL statement and return the number of rows it has modified.
rawQuery :: forall (m :: Type -> Type) env. (MonadResource m, MonadReader env m, BackendCompatible SqlBackend env) => Text -> [PersistValue] -> ConduitM () [PersistValue] m () #
rawQueryRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) env. (MonadIO m1, MonadIO m2, BackendCompatible SqlBackend env) => Text -> [PersistValue] -> ReaderT env m1 (Acquire (ConduitM () [PersistValue] m2 ())) #
Arguments
| :: forall a (m :: Type -> Type) backend. (RawSql a, MonadIO m, BackendCompatible SqlBackend backend) | |
| => Text | SQL 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)
close' :: BackendCompatible SqlBackend backend => backend -> IO () #
createSqlPool :: forall backend m. (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> Int -> m (Pool backend) #
liftSqlPersistMPool :: forall backend m a. (MonadIO m, BackendCompatible SqlBackend backend) => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> m a #
runSqlConn :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> backend -> m a #
runSqlPersistM :: BackendCompatible SqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> backend -> IO a #
runSqlPersistMPool :: BackendCompatible SqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> IO a #
runSqlPool :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> Pool backend -> m a #
Get a connection from the pool, run the given action, and then return the connection to the pool.
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.
withSqlConn :: forall backend m a. (MonadUnliftIO m, MonadLoggerIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> (backend -> m a) -> m a #
Create a connection and run sql queries within it. This function automatically closes the connection on it's completion.
Example usage
{-# 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}}]Arguments
| :: forall backend m a. (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend) | |
| => (LogFunc -> IO backend) | create a new connection | 
| -> Int | connection count | 
| -> (Pool backend -> m a) | |
| -> m a | 
readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a #
Useful for running a read query against a backend with unknown capabilities.
readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a #
Useful for running a read query against a backend with read and write capabilities.
writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a #
Useful for running a write query against an untagged backend with unknown capabilities.
getEntityKeyFields :: EntityDef -> NonEmpty FieldDef #
Since: persistent-2.13.0.0
entityPrimary :: EntityDef -> Maybe CompositeDef #
type PersistStore a = PersistStoreWrite a #
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.
type PersistUnique a = PersistUniqueWrite a #
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.
class (PersistStoreWrite backend, PersistEntity record, BaseBackend backend ~ PersistEntityBackend record) => DeleteCascade record backend where #
For combinations of backends and entities that support cascade-deletion. “Cascade-deletion” means that entries that depend on other entries to be deleted will be deleted as well.
class PersistConfig c where #
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.
Minimal complete definition
Associated Types
type PersistConfigBackend c :: (Type -> Type) -> Type -> Type #
type PersistConfigPool c #
Methods
loadConfig :: Value -> Parser c #
Load the config settings from a Value, most likely taken from a YAML
 config file.
Modify 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 a #
Run a database action by taking a connection from the pool.
Instances
| (PersistConfig c1, PersistConfig c2, PersistConfigPool c1 ~ PersistConfigPool c2, PersistConfigBackend c1 ~ PersistConfigBackend c2) => PersistConfig (Either c1 c2) | |
| Defined in Database.Persist.Class.PersistConfig Associated Types type PersistConfigBackend (Either c1 c2) :: (Type -> Type) -> Type -> Type # type PersistConfigPool (Either c1 c2) # Methods loadConfig :: Value -> Parser (Either c1 c2) # applyEnv :: Either c1 c2 -> IO (Either c1 c2) # createPoolConfig :: Either c1 c2 -> IO (PersistConfigPool (Either c1 c2)) # runPool :: MonadUnliftIO m => Either c1 c2 -> PersistConfigBackend (Either c1 c2) m a -> PersistConfigPool (Either c1 c2) -> m a # | |
type family BackendSpecificUpdate backend 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.GenericSql 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.
Instances
class (PersistField (Key record), ToJSON (Key record), FromJSON (Key record), Show (Key record), Read (Key record), Eq (Key record), Ord (Key record)) => PersistEntity record where #
Persistent 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.
Minimal complete definition
keyToValues, keyFromValues, persistIdField, entityDef, persistFieldDef, toPersistFields, fromPersistValues, persistUniqueKeys, persistUniqueToFieldNames, persistUniqueToValues, fieldLens
Associated Types
type PersistEntityBackend record #
Persistent allows multiple different backends (databases).
By default, a backend will automatically generate the key Instead you can specify a Primary key made up of unique values.
data EntityField record :: Type -> Type #
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.
Unique keys besides the Key.
Methods
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 -> EntityDef #
Retrieve the EntityDef meta-data for the record.
persistFieldDef :: EntityField record typ -> FieldDef #
Return meta-data for a given EntityField.
toPersistFields :: record -> [SomePersistField] #
A meta-operation to get the database fields of a record.
fromPersistValues :: [PersistValue] -> Either Text record #
A lower-level operation to convert from database values to a Haskell record.
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 recordrecord 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.
Since: persistent-2.11.0.0
class PersistField a where #
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.
Examples
Simple Newtype
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)
Smart Constructor Newtype
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 PersistFieldinstances you can look at for examples.
- Typically custom PersistFieldinstances will only accept a singlePersistValueconstructor infromPersistValue.
- Internal PersistFieldinstances accept a wide variety ofPersistValues 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 PersistFieldSqlto specify the type of the database column.
Instances
data SomePersistField #
Constructors
| PersistField a => SomePersistField a | 
Instances
| PersistField SomePersistField | |
| Defined in Database.Persist.Class.PersistField Methods toPersistValue :: SomePersistField -> PersistValue # fromPersistValue :: PersistValue -> Either Text SomePersistField # | |
class (PersistCore backend, PersistStoreRead backend) => PersistQueryRead backend where #
Backends supporting conditional read operations.
Minimal complete definition
Methods
selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (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.
selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m (Maybe (Entity record)) #
Get just the first record for the criterion.
selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (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.
class (PersistQueryRead backend, PersistStoreWrite backend) => PersistQueryWrite backend where #
Backends supporting conditional write operations
Methods
updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [Update record] -> ReaderT backend m () #
Update individual fields on any record matching the given criterion.
deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m () #
Delete all records matching the given criterion.
class BackendCompatible sup sub where #
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 :: (PersistEntityrecord ,PeristEntityBackendrecord ~BaseBackendbackend ,IsSqlBackendbackend )
this can be replaced with:
foo :: (PersistEntityrecord, ,PersistEntityBackendrecord ~ backend ,BackendCompatibleSqlBackendbackend )
This works for SqlReadBackend because of the instance , without needing to go through the BackendCompatible SqlBackend SqlReadBackendBaseBackend type family.
Likewise, functions that are currently hardcoded to use SqlBackend can be generalized:
-- before: asdf ::ReaderTSqlBackendm () asdf = pure () -- after: asdf' ::BackendCompatibleSqlBackend backend => ReaderT backend m () asdf' =withCompatibleBackendasdf
Since: persistent-2.7.1
Methods
projectBackend :: sub -> sup #
data family BackendKey backend #
Instances
class HasPersistBackend backend where #
Class which allows the plucking of a BaseBackend backend from some larger type.
 For example,
 
 instance HasPersistBackend (SqlReadBackend, Int) where
   type BaseBackend (SqlReadBackend, Int) = SqlBackend
   persistBackend = unSqlReadBackend . fst
 
Associated Types
type BaseBackend backend #
Methods
persistBackend :: backend -> BaseBackend backend #
Instances
| HasPersistBackend SqlReadBackend | |
| Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlReadBackend # Methods persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend # | |
| HasPersistBackend SqlWriteBackend | |
| Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlWriteBackend # Methods persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend # | |
| HasPersistBackend SqlBackend | |
| Defined in Database.Persist.SqlBackend.Internal Associated Types type BaseBackend SqlBackend # Methods | |
class HasPersistBackend backend => IsPersistBackend backend #
Class which witnesses that backend is essentially the same as BaseBackend backend.
 That is, they're isomorphic and backend is just some wrapper over BaseBackend backend.
Minimal complete definition
Instances
| IsPersistBackend SqlReadBackend | |
| Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend # | |
| IsPersistBackend SqlWriteBackend | |
| Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend # | |
| IsPersistBackend SqlBackend | |
| Defined in Database.Persist.SqlBackend.Internal Methods | |
class PersistCore backend #
Associated Types
data BackendKey backend #
type 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 where #
Minimal complete definition
Methods
get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> ReaderT backend m (Maybe record) #
Get a record by identifier, if available.
Example usage
getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [Key record] -> ReaderT backend m (Map (Key record) record) #
Get many records by their respective identifiers, if available.
Example usage
getUsers :: MonadIO m => ReaderT SqlBackend m (Map (Key User) User) getUsers = getMany allkeys
musers <- getUsers
The above query when applied on dataset-1, will get these records:
+----+-------+-----+ | id | name | age | +----+-------+-----+ | 1 | SPJ | 40 | +----+-------+-----+ | 2 | Simon | 41 | +----+-------+-----+
Since: persistent-2.8.1
class (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 where #
Methods
insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Key record) #
Create a new record in the database, returning an automatically created key (in SQL an auto-increment id).
Example usage
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" 30
johnId <- insertJohn
The above query when applied on dataset-1, will produce this:
+-----+------+-----+ |id |name |age | +-----+------+-----+ |1 |SPJ |40 | +-----+------+-----+ |2 |Simon |41 | +-----+------+-----+ |3 |John |30 | +-----+------+-----+
insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m () #
Same as insert, but doesn't return a Key.
Example usage
insertJohn :: MonadIO m => ReaderT SqlBackend m (Key User) insertJohn = insert_ $ User "John" 30
The above query when applied on dataset-1, will produce this:
+-----+------+-----+ |id |name |age | +-----+------+-----+ |1 |SPJ |40 | +-----+------+-----+ |2 |Simon |41 | +-----+------+-----+ |3 |John |30 | +-----+------+-----+
insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [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.
Example usage
insertUsers :: MonadIO m => ReaderT SqlBackend m [Key User] insertUsers = insertMany [User "John" 30, User "Nick" 32, User "Jane" 20]
userIds <- insertUsers
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 | +-----+------+-----+
insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => [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.
Example usage
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 :: forall record (m :: Type -> Type). (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.
Example usage
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 :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m () #
Create a new record in the database using the given key.
Example usage
insertAliceKey :: MonadIO m => Key User -> ReaderT SqlBackend m () insertAliceKey key = insertKey key $ User "Alice" 20
insertAliceKey $ 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 :: forall record (m :: Type -> Type). (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.
Example usage
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" 42
philipId <- insertPhilip
This 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" 81
repsertHaskell philipId
This 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" 999
For example, applying the above query to dataset-1 will produce this:
+-----+------+-----+ |id |name |age | +-----+------+-----+ |1 |SPJ |40 | +-----+------+-----+ |2 |Simon |41 | +-----+------+-----+ |3 |X |999 | +-----+------+-----+
repsertMany :: forall record (m :: Type -> Type). (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.
Example usage
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 | +-----+----------------+---------+
Since: persistent-2.8.1
replace :: forall record (m :: Type -> Type). (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.
Example usage
With schema-1 schama-1 and dataset-1,
replaceSpj :: MonadIO m => User -> ReaderT SqlBackend m () replaceSpj record = replace spjId record
The above query when applied on dataset-1, will produce this:
+-----+------+-----+ |id |name |age | +-----+------+-----+ |1 |Mike |45 | +-----+------+-----+ |2 |Simon |41 | +-----+------+-----+
updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m record #
Update 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.
Example usage
updateGetSpj :: MonadIO m => [Update User] -> ReaderT SqlBackend m User updateGetSpj updates = updateGet spjId updates
spj <- updateGetSpj [UserAge +=. 100]
The above query when applied on dataset-1, will produce this:
+-----+------+-----+ |id |name |age | +-----+------+-----+ |1 |SPJ |140 | +-----+------+-----+ |2 |Simon |41 | +-----+------+-----+
class (PersistEntity record, PersistEntityBackend record ~ backend, PersistCore backend) => ToBackendKey backend record where #
ToBackendKey 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.
Methods
toBackendKey :: Key record -> BackendKey backend #
fromBackendKey :: BackendKey backend -> Key record #
class PersistStoreRead backend => PersistUniqueRead backend where #
Queries 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.
Methods
getBy :: forall record (m :: Type -> Type). (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.
Example usage
getBySpjName :: MonadIO m => ReaderT SqlBackend m (Maybe (Entity User)) getBySpjName = getBy $ UniqueUserName "SPJ"
mSpjEnt <- getBySpjName
The above query when applied on dataset-1, will get this entity:
+----+------+-----+ | id | name | age | +----+------+-----+ | 1 | SPJ | 40 | +----+------+-----+
class (PersistUniqueRead backend, PersistStoreWrite backend) => PersistUniqueWrite backend where #
Some 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.
Minimal complete definition
Methods
deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m () #
Delete a specific record by unique key. Does nothing if no record matches.
Example usage
insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Maybe (Key record)) #
Like insert, but returns Nothing when the record
 couldn't be inserted because of a uniqueness constraint.
Example usage
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.
Arguments
| :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, OnlyOneUniqueKey record) | |
| => record | new record to insert | 
| -> [Update record] | updates to perform if the record already exists | 
| -> ReaderT backend m (Entity record) | the record in the database after the operation | 
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.
Example usage
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) upadtes
mSpjEnt <- 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) updates
mXEnt <- 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.
Arguments
| :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) | |
| => Unique record | uniqueness constraint to find by | 
| -> record | new record to insert | 
| -> [Update record] | updates to perform if the record already exists | 
| -> ReaderT backend m (Entity record) | the record in the database after the operation | 
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.
Example usage
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 updates
mSpjEnt <- 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 updates
mPhilipEnt <- 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 updates
mXEnt <- 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 | +-----+-----+-----+
Arguments
| :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend) | |
| => [record] | A list of the records you want to insert or replace. | 
| -> 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)
Since: persistent-2.8.1
class PersistField a => PersistFieldSql a where #
Tells Persistent what database column type should be used to store a Haskell type.
Examples
Simple Boolean Alternative
data Switch = On | Off deriving (Show, Eq) instancePersistFieldSwitch wheretoPersistValues = case s of On ->PersistBoolTrue Off ->PersistBoolFalsefromPersistValue(PersistBoolb) = if b thenRightOn elseRightOfffromPersistValuex = Left $ "File.hs: When trying to deserialize a Switch: expected PersistBool, received: " <> T.pack (show x) instancePersistFieldSqlSwitch wheresqlType_ =SqlBool
Non-Standard Database Types
If your database supports non-standard types, such as Postgres' uuid, you can use SqlOther to use them:
import qualified Data.UUID as UUID instancePersistFieldUUID wheretoPersistValue=PersistLiteralEncoded. toASCIIBytesfromPersistValue(PersistLiteralEncodeduuid) = case fromASCIIBytes uuid ofNothing->Left$ "Model/CustomTypes.hs: Failed to deserialize a UUID; received: " <> T.pack (show uuid)Justuuid' ->Rightuuid'fromPersistValuex = Left $ "File.hs: When trying to deserialize a UUID: expected PersistLiteralEncoded, received: "-- > <> T.pack (show x) instancePersistFieldSqlUUID wheresqlType_ =SqlOther"uuid"
User Created Database Types
Similarly, some databases support creating custom types, e.g. Postgres' DOMAIN and ENUM features. You can use SqlOther to specify a custom type:
CREATE DOMAIN ssn AS text
      CHECK ( value ~ '^[0-9]{9}$');instancePersistFieldSQLSSN wheresqlType_ =SqlOther"ssn"
CREATE TYPE rainbow_color AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet');instancePersistFieldSQLRainbowColor wheresqlType_ =SqlOther"rainbow_color"
Instances
Class for data types that may be retrived from a rawSql
 query.
Methods
rawSqlCols :: (Text -> Text) -> a -> (Int, [Text]) #
Number of columns that this data type needs and the list
 of substitutions for SELECT placeholders ??.
rawSqlColCountReason :: a -> String #
A string telling the user why the column count is what it is.
rawSqlProcessRow :: [PersistValue] -> Either Text a #
Transform a row of the result into the data type.
Instances
| RawSql a => RawSql (Maybe a) | Since: persistent-1.0.1 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> Maybe a -> (Int, [Text]) # rawSqlColCountReason :: Maybe a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Maybe a) # | |
| PersistField a => RawSql (Single a) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> Single a -> (Int, [Text]) # rawSqlColCountReason :: Single a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Single a) # | |
| (PersistEntity a, PersistEntityBackend a ~ backend, IsPersistBackend backend) => RawSql (Key a) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> Key a -> (Int, [Text]) # rawSqlColCountReason :: Key a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Key a) # | |
| (PersistEntity record, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (Entity record) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> Entity record -> (Int, [Text]) # rawSqlColCountReason :: Entity record -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Entity record) # | |
| (RawSql a, RawSql b) => RawSql (a, b) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b) -> (Int, [Text]) # rawSqlColCountReason :: (a, b) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b) # | |
| (PersistEntity record, KnownSymbol prefix, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (EntityWithPrefix prefix record) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> EntityWithPrefix prefix record -> (Int, [Text]) # rawSqlColCountReason :: EntityWithPrefix prefix record -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (EntityWithPrefix prefix record) # | |
| (RawSql a, RawSql b, RawSql c) => RawSql (a, b, c) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c) # | |
| (RawSql a, RawSql b, RawSql c, RawSql d) => RawSql (a, b, c, d) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d) # | |
| (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e) => RawSql (a, b, c, d, e) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e) # | |
| (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f) => RawSql (a, b, c, d, e, f) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f) # | |
| (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g) => RawSql (a, b, c, d, e, f, g) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g) # | |
| (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h) => RawSql (a, b, c, d, e, f, g, h) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h) # | |
| (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) | Since: persistent-2.10.2 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i) # | |
| (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) | Since: persistent-2.10.2 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j) # | |
| (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) | Since: persistent-2.10.2 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k) # | |
| (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) | Since: persistent-2.10.2 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) -> (Int, [Text]) # rawSqlColCountReason :: (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
| (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) | Since: persistent-2.11.0 | 
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> (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) -> (Int, [Text]) # rawSqlColCountReason :: (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) -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (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) # | |
type CautiousMigration = [(Bool, Sql)] #
Constructors
| Column | |
| Fields 
 | |
type ConnectionPool = Pool SqlBackend #
type Migration = WriterT [Text] (WriterT CautiousMigration (ReaderT SqlBackend IO)) () #
A Migration is a four level monad stack consisting of:
- WriterT[- Text]
- WriterT- CautiousMigration
- ReaderT- SqlBackend- SqlPersistTtransformer for database interop.
- IO
data PersistentSqlException #
Constructors
| StatementAlreadyFinalized Text | |
| Couldn'tGetSQLConnection | 
Instances
| Show PersistentSqlException | |
| Defined in Database.Persist.Sql.Types Methods showsPrec :: Int -> PersistentSqlException -> ShowS # show :: PersistentSqlException -> String # showList :: [PersistentSqlException] -> ShowS # | |
| Exception PersistentSqlException | |
| Defined in Database.Persist.Sql.Types | |
A single column (see rawSql).  Any PersistField may be
 used here, including PersistValue (which does not do any
 processing).
Instances
| Eq a => Eq (Single a) | |
| Ord a => Ord (Single a) | |
| Defined in Database.Persist.Sql.Types | |
| Read a => Read (Single a) | |
| Show a => Show (Single a) | |
| PersistField a => RawSql (Single a) | |
| Defined in Database.Persist.Sql.Class Methods rawSqlCols :: (Text -> Text) -> Single a -> (Int, [Text]) # rawSqlColCountReason :: Single a -> String # rawSqlProcessRow :: [PersistValue] -> Either Text (Single a) # | |
type SqlPersistM = SqlPersistT (NoLoggingT (ResourceT IO)) #
type SqlPersistT = ReaderT SqlBackend #
data InsertSqlResult #
Constructors
| ISRSingle Text | |
| ISRInsertGet Text Text | |
| ISRManyKeys Text [PersistValue] | 
type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend) #
A backend which is a wrapper around SqlBackend.
data SqlBackend #
A SqlBackend represents a handle or connection to a database. It
 contains functions and values that allow databases to have more
 optimized implementations, as well as references that benefit
 performance and sharing.
Instead of using the SqlBackend constructor directly, use the
 mkSqlBackend function.
A SqlBackend is *not* thread-safe. You should not assume that
 a SqlBackend can be shared among threads and run concurrent queries.
 This *will* result in problems. Instead, you should create a Pool
 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.
Instances
| HasPersistBackend SqlBackend | |
| Defined in Database.Persist.SqlBackend.Internal Associated Types type BaseBackend SqlBackend # Methods | |
| IsPersistBackend SqlBackend | |
| Defined in Database.Persist.SqlBackend.Internal Methods | |
| type BaseBackend SqlBackend | |
| Defined in Database.Persist.SqlBackend.Internal | |
| newtype BackendKey SqlBackend | |
| Defined in Database.Persist.Sql.Orphan.PersistStore | |
| type Rep (BackendKey SqlBackend) | |
| Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.13.0.1-FuUhVMOPfWy9muK0uhAert" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64))) | |
type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend) #
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.
newtype SqlReadBackend #
An SQL backend which can only handle read queries
The constructor was exposed in 2.10.0.
Constructors
| SqlReadBackend | |
| Fields | |
Instances
| HasPersistBackend SqlReadBackend | |
| Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlReadBackend # Methods persistBackend :: SqlReadBackend -> BaseBackend SqlReadBackend # | |
| IsPersistBackend SqlReadBackend | |
| Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlReadBackend -> SqlReadBackend # | |
| type BaseBackend SqlReadBackend | |
| Defined in Database.Persist.Sql.Types.Internal | |
| newtype BackendKey SqlReadBackend | |
| Defined in Database.Persist.Sql.Orphan.PersistStore | |
| type Rep (BackendKey SqlReadBackend) | |
| Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.13.0.1-FuUhVMOPfWy9muK0uhAert" 'True) (C1 ('MetaCons "SqlReadBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64))) | |
type SqlReadT (m :: Type -> Type) a = forall backend. SqlBackendCanRead backend => ReaderT backend m a #
Like SqlPersistT but compatible with any SQL backend which can handle read queries.
newtype SqlWriteBackend #
An SQL backend which can handle read or write queries
The constructor was exposed in 2.10.0
Constructors
| SqlWriteBackend | |
| Fields | |
Instances
| HasPersistBackend SqlWriteBackend | |
| Defined in Database.Persist.Sql.Types.Internal Associated Types type BaseBackend SqlWriteBackend # Methods persistBackend :: SqlWriteBackend -> BaseBackend SqlWriteBackend # | |
| IsPersistBackend SqlWriteBackend | |
| Defined in Database.Persist.Sql.Types.Internal Methods mkPersistBackend :: BaseBackend SqlWriteBackend -> SqlWriteBackend # | |
| type BaseBackend SqlWriteBackend | |
| Defined in Database.Persist.Sql.Types.Internal | |
| newtype BackendKey SqlWriteBackend | |
| Defined in Database.Persist.Sql.Orphan.PersistStore | |
| type Rep (BackendKey SqlWriteBackend) | |
| Defined in Database.Persist.Sql.Orphan.PersistStore type Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.13.0.1-FuUhVMOPfWy9muK0uhAert" 'True) (C1 ('MetaCons "SqlWriteBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64))) | |
type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a #
Like SqlPersistT but compatible with any SQL backend which can handle read and write queries.
A Statement is a representation of a database query that has been
 prepared and stored on the server side.
Constructors
| Statement | |
| Fields 
 | |
A 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.
Constructors
| Active | When used on a uniqueness constraint, there
 may be at most one  | 
| Inactive | When used on a uniqueness constraint, there
 may be any number of  | 
Instances
data CompositeDef #
Constructors
| CompositeDef | |
| Fields 
 | |
Instances
| Eq CompositeDef | |
| Defined in Database.Persist.Types.Base | |
| Ord CompositeDef | |
| Defined in Database.Persist.Types.Base Methods compare :: CompositeDef -> CompositeDef -> Ordering # (<) :: CompositeDef -> CompositeDef -> Bool # (<=) :: CompositeDef -> CompositeDef -> Bool # (>) :: CompositeDef -> CompositeDef -> Bool # (>=) :: CompositeDef -> CompositeDef -> Bool # max :: CompositeDef -> CompositeDef -> CompositeDef # min :: CompositeDef -> CompositeDef -> CompositeDef # | |
| Read CompositeDef | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS CompositeDef # readList :: ReadS [CompositeDef] # | |
| Show CompositeDef | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> CompositeDef -> ShowS # show :: CompositeDef -> String # showList :: [CompositeDef] -> ShowS # | |
| Lift CompositeDef | |
| Defined in Database.Persist.Types.Base | |
data EmbedEntityDef #
An EmbedEntityDef is the same as an EntityDef But it is only used for fieldReference so it only has data needed for embedding
Constructors
| EmbedEntityDef | |
| Fields | |
Instances
| Eq EmbedEntityDef | |
| Defined in Database.Persist.Types.Base Methods (==) :: EmbedEntityDef -> EmbedEntityDef -> Bool # (/=) :: EmbedEntityDef -> EmbedEntityDef -> Bool # | |
| Ord EmbedEntityDef | |
| Defined in Database.Persist.Types.Base Methods compare :: EmbedEntityDef -> EmbedEntityDef -> Ordering # (<) :: EmbedEntityDef -> EmbedEntityDef -> Bool # (<=) :: EmbedEntityDef -> EmbedEntityDef -> Bool # (>) :: EmbedEntityDef -> EmbedEntityDef -> Bool # (>=) :: EmbedEntityDef -> EmbedEntityDef -> Bool # max :: EmbedEntityDef -> EmbedEntityDef -> EmbedEntityDef # min :: EmbedEntityDef -> EmbedEntityDef -> EmbedEntityDef # | |
| Read EmbedEntityDef | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS EmbedEntityDef # readList :: ReadS [EmbedEntityDef] # | |
| Show EmbedEntityDef | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> EmbedEntityDef -> ShowS # show :: EmbedEntityDef -> String # showList :: [EmbedEntityDef] -> ShowS # | |
| Lift EmbedEntityDef | |
| Defined in Database.Persist.Types.Base | |
data EmbedFieldDef #
An EmbedFieldDef is the same as a FieldDef But it is only used for embeddedFields so it only has data needed for embedding
Constructors
| EmbedFieldDef | |
| Fields 
 | |
Instances
| Eq EmbedFieldDef | |
| Defined in Database.Persist.Types.Base Methods (==) :: EmbedFieldDef -> EmbedFieldDef -> Bool # (/=) :: EmbedFieldDef -> EmbedFieldDef -> Bool # | |
| Ord EmbedFieldDef | |
| Defined in Database.Persist.Types.Base Methods compare :: EmbedFieldDef -> EmbedFieldDef -> Ordering # (<) :: EmbedFieldDef -> EmbedFieldDef -> Bool # (<=) :: EmbedFieldDef -> EmbedFieldDef -> Bool # (>) :: EmbedFieldDef -> EmbedFieldDef -> Bool # (>=) :: EmbedFieldDef -> EmbedFieldDef -> Bool # max :: EmbedFieldDef -> EmbedFieldDef -> EmbedFieldDef # min :: EmbedFieldDef -> EmbedFieldDef -> EmbedFieldDef # | |
| Read EmbedFieldDef | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS EmbedFieldDef # readList :: ReadS [EmbedFieldDef] # | |
| Show EmbedFieldDef | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> EmbedFieldDef -> ShowS # show :: EmbedFieldDef -> String # showList :: [EmbedFieldDef] -> ShowS # | |
| Lift EmbedFieldDef | |
| Defined in Database.Persist.Types.Base | |
An 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.
Instances
| Eq EntityDef | |
| Ord EntityDef | |
| Read EntityDef | |
| Show EntityDef | |
| Lift EntityDef | |
data EntityIdDef #
The definition for the entity's primary key ID.
Since: persistent-2.13.0.0
Constructors
| EntityIdField !FieldDef | The entity has a single key column, and it is a surrogate key - that
 is, you can't go from  Since: persistent-2.13.0.0 | 
| EntityIdNaturalKey !CompositeDef | The entity has a natural key. This means you can write  A natural key can have one or more columns. Since: persistent-2.13.0.0 | 
Instances
| Eq EntityIdDef | |
| Defined in Database.Persist.Types.Base | |
| Ord EntityIdDef | |
| Defined in Database.Persist.Types.Base Methods compare :: EntityIdDef -> EntityIdDef -> Ordering # (<) :: EntityIdDef -> EntityIdDef -> Bool # (<=) :: EntityIdDef -> EntityIdDef -> Bool # (>) :: EntityIdDef -> EntityIdDef -> Bool # (>=) :: EntityIdDef -> EntityIdDef -> Bool # max :: EntityIdDef -> EntityIdDef -> EntityIdDef # min :: EntityIdDef -> EntityIdDef -> EntityIdDef # | |
| Read EntityIdDef | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS EntityIdDef # readList :: ReadS [EntityIdDef] # readPrec :: ReadPrec EntityIdDef # readListPrec :: ReadPrec [EntityIdDef] # | |
| Show EntityIdDef | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> EntityIdDef -> ShowS # show :: EntityIdDef -> String # showList :: [EntityIdDef] -> ShowS # | |
| Lift EntityIdDef | |
| Defined in Database.Persist.Types.Base | |
A 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.
Constructors
| FieldDef | |
| Fields 
 | |
A 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)
Constructors
| FTTypeCon (Maybe Text) Text | Optional module and name. | 
| FTTypePromoted Text | |
| FTApp FieldType FieldType | |
| FTList FieldType | 
Instances
| Eq FieldType | |
| Ord FieldType | |
| Read FieldType | |
| Show FieldType | |
| Lift FieldType | |
data ForeignDef #
Constructors
| ForeignDef | |
| Fields 
 | |
Instances
| Eq ForeignDef | |
| Defined in Database.Persist.Types.Base | |
| Ord ForeignDef | |
| Defined in Database.Persist.Types.Base Methods compare :: ForeignDef -> ForeignDef -> Ordering # (<) :: ForeignDef -> ForeignDef -> Bool # (<=) :: ForeignDef -> ForeignDef -> Bool # (>) :: ForeignDef -> ForeignDef -> Bool # (>=) :: ForeignDef -> ForeignDef -> Bool # max :: ForeignDef -> ForeignDef -> ForeignDef # min :: ForeignDef -> ForeignDef -> ForeignDef # | |
| Read ForeignDef | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS ForeignDef # readList :: ReadS [ForeignDef] # readPrec :: ReadPrec ForeignDef # readListPrec :: ReadPrec [ForeignDef] # | |
| Show ForeignDef | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> ForeignDef -> ShowS # show :: ForeignDef -> String # showList :: [ForeignDef] -> ShowS # | |
| Lift ForeignDef | |
| Defined in Database.Persist.Types.Base | |
type ForeignFieldDef = (FieldNameHS, FieldNameDB) #
Used instead of FieldDef to generate a smaller amount of code
data IsNullable #
Constructors
| Nullable !WhyNullable | |
| NotNullable | 
Instances
| Eq IsNullable | |
| Defined in Database.Persist.Types.Base | |
| Show IsNullable | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> IsNullable -> ShowS # show :: IsNullable -> String # showList :: [IsNullable] -> ShowS # | |
data PersistException #
Constructors
| PersistError Text | Generic Exception | 
| PersistMarshalError Text | |
| PersistInvalidField Text | |
| PersistForeignConstraintUnmet Text | |
| PersistMongoDBError Text | |
| PersistMongoDBUnsupported Text | 
Instances
| Show PersistException | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> PersistException -> ShowS # show :: PersistException -> String # showList :: [PersistException] -> ShowS # | |
| Exception PersistException | |
| Defined in Database.Persist.Types.Base Methods toException :: PersistException -> SomeException # | |
data PersistFilter #
Instances
| Read PersistFilter | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS PersistFilter # readList :: ReadS [PersistFilter] # | |
| Show PersistFilter | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> PersistFilter -> ShowS # show :: PersistFilter -> String # showList :: [PersistFilter] -> ShowS # | |
| Lift PersistFilter | |
| Defined in Database.Persist.Types.Base | |
data PersistUpdate #
Instances
| Read PersistUpdate | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS PersistUpdate # readList :: ReadS [PersistUpdate] # | |
| Show PersistUpdate | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> PersistUpdate -> ShowS # show :: PersistUpdate -> String # showList :: [PersistUpdate] -> ShowS # | |
| Lift PersistUpdate | |
| Defined in Database.Persist.Types.Base | |
data PersistValue #
A raw value which can be stored in any backend and can be marshalled to
 and from a PersistField.
Constructors
| PersistText Text | |
| PersistByteString ByteString | |
| PersistInt64 Int64 | |
| PersistDouble Double | |
| PersistRational Rational | |
| PersistBool Bool | |
| PersistDay Day | |
| PersistTimeOfDay TimeOfDay | |
| PersistUTCTime UTCTime | |
| PersistNull | |
| PersistList [PersistValue] | |
| PersistMap [(Text, PersistValue)] | |
| PersistObjectId ByteString | Intended especially for MongoDB backend | 
| PersistArray [PersistValue] | Intended especially for PostgreSQL backend for text arrays | 
| PersistLiteral_ LiteralType ByteString | This constructor is used to specify some raw literal value for the
 backend. The  Since: persistent-2.12.0.0 | 
Bundled Patterns
| pattern PersistLiteral :: ByteString -> PersistValue | This pattern synonym used to be a data constructor on  Since: persistent-2.12.0.0 | 
| pattern PersistLiteralEscaped :: ByteString -> PersistValue | This pattern synonym used to be a data constructor on  Since: persistent-2.12.0.0 | 
| pattern PersistDbSpecific :: ByteString -> PersistValue | This pattern synonym used to be a data constructor for the
  If you use this, it will overlap a patern match on the 'PersistLiteral_,
  Since: persistent-2.12.0.0 | 
Instances
data ReferenceDef #
There are 3 kinds of references 1) composite (to fields that exist in the record) 2) single field 3) embedded
Constructors
| NoReference | |
| ForeignRef !EntityNameHS | A 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 EntityNameHS | |
| CompositeRef CompositeDef | |
| SelfReference | A SelfReference stops an immediate cycle which causes non-termination at compile-time (issue #311). | 
Instances
| Eq ReferenceDef | |
| Defined in Database.Persist.Types.Base | |
| Ord ReferenceDef | |
| Defined in Database.Persist.Types.Base Methods compare :: ReferenceDef -> ReferenceDef -> Ordering # (<) :: ReferenceDef -> ReferenceDef -> Bool # (<=) :: ReferenceDef -> ReferenceDef -> Bool # (>) :: ReferenceDef -> ReferenceDef -> Bool # (>=) :: ReferenceDef -> ReferenceDef -> Bool # max :: ReferenceDef -> ReferenceDef -> ReferenceDef # min :: ReferenceDef -> ReferenceDef -> ReferenceDef # | |
| Read ReferenceDef | |
| Defined in Database.Persist.Types.Base Methods readsPrec :: Int -> ReadS ReferenceDef # readList :: ReadS [ReferenceDef] # | |
| Show ReferenceDef | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> ReferenceDef -> ShowS # show :: ReferenceDef -> String # showList :: [ReferenceDef] -> ShowS # | |
| Lift ReferenceDef | |
| Defined in Database.Persist.Types.Base | |
A 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.
Constructors
| SqlString | |
| SqlInt32 | |
| SqlInt64 | |
| SqlReal | |
| SqlNumeric Word32 Word32 | |
| SqlBool | |
| SqlDay | |
| SqlTime | |
| SqlDayTime | Always uses UTC timezone | 
| SqlBlob | |
| SqlOther Text | a backend-specific name | 
Type 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 = []
    }
Constructors
| UniqueDef | |
| Fields 
 | |
Instances
| Eq UniqueDef | |
| Ord UniqueDef | |
| Read UniqueDef | |
| Show UniqueDef | |
| Lift UniqueDef | |
data UpdateException #
Constructors
| KeyNotFound String | |
| UpsertError String | 
Instances
| Show UpdateException | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> UpdateException -> ShowS # show :: UpdateException -> String # showList :: [UpdateException] -> ShowS # | |
| Exception UpdateException | |
| Defined in Database.Persist.Types.Base Methods toException :: UpdateException -> SomeException # | |
data WhyNullable #
The 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.
Constructors
| ByMaybeAttr | |
| ByNullableAttr | 
Instances
| Eq WhyNullable | |
| Defined in Database.Persist.Types.Base | |
| Show WhyNullable | |
| Defined in Database.Persist.Types.Base Methods showsPrec :: Int -> WhyNullable -> ShowS # show :: WhyNullable -> String # showList :: [WhyNullable] -> ShowS # | |
getEntityFields :: EntityDef -> [FieldDef] #
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.
Since: persistent-2.13.0.0
getEntityId :: EntityDef -> EntityIdDef #
Since: persistent-2.13.0.0
getEntityDBName :: EntityDef -> EntityNameDB #
Return the database name for the given entity.
Since: persistent-2.13.0.0
getEntityUniques :: EntityDef -> [UniqueDef] #
getEntityDBName :: EntityDef -> EntityNameDB #
Return the database name for the given entity.
Since: persistent-2.13.0.0