-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Type-safe, multi-backend data serialization. -- -- Type-safe, data serialization. You must use a specific backend in -- order to make this useful. @package persistent @version 1.2.2.0 module Database.Persist.Types -- | 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. data Checkmark -- | When used on a uniqueness constraint, there may be at most one -- Active record. Active :: Checkmark -- | When used on a uniqueness constraint, there may be any number of -- Inactive records. Inactive :: Checkmark data IsNullable Nullable :: !WhyNullable -> IsNullable NotNullable :: IsNullable -- | 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. data WhyNullable ByMaybeAttr :: WhyNullable ByNullableAttr :: WhyNullable data EntityDef sqlType EntityDef :: !HaskellName -> !DBName -> !DBName -> ![Attr] -> ![FieldDef sqlType] -> ![UniqueDef] -> ![Text] -> !(Map Text [ExtraLine]) -> !Bool -> EntityDef sqlType entityHaskell :: EntityDef sqlType -> !HaskellName entityDB :: EntityDef sqlType -> !DBName entityID :: EntityDef sqlType -> !DBName entityAttrs :: EntityDef sqlType -> ![Attr] entityFields :: EntityDef sqlType -> ![FieldDef sqlType] entityUniques :: EntityDef sqlType -> ![UniqueDef] entityDerives :: EntityDef sqlType -> ![Text] entityExtra :: EntityDef sqlType -> !(Map Text [ExtraLine]) entitySum :: EntityDef sqlType -> !Bool type ExtraLine = [Text] newtype HaskellName HaskellName :: Text -> HaskellName unHaskellName :: HaskellName -> Text newtype DBName DBName :: Text -> DBName unDBName :: DBName -> Text type Attr = Text data FieldType -- | Optional module and name. FTTypeCon :: (Maybe Text) -> Text -> FieldType FTApp :: FieldType -> FieldType -> FieldType FTList :: FieldType -> FieldType data FieldDef sqlType FieldDef :: !HaskellName -> !DBName -> !FieldType -> !sqlType -> ![Attr] -> !Bool -> Maybe (EntityDef ()) -> FieldDef sqlType -- | name of the field fieldHaskell :: FieldDef sqlType -> !HaskellName fieldDB :: FieldDef sqlType -> !DBName fieldType :: FieldDef sqlType -> !FieldType fieldSqlType :: FieldDef sqlType -> !sqlType -- | user annotations for a field fieldAttrs :: FieldDef sqlType -> ![Attr] -- | a strict field in the data type. Default: true fieldStrict :: FieldDef sqlType -> !Bool -- | indicates that the field uses an embedded entity fieldEmbedded :: FieldDef sqlType -> Maybe (EntityDef ()) data UniqueDef UniqueDef :: !HaskellName -> !DBName -> ![(HaskellName, DBName)] -> ![Attr] -> UniqueDef uniqueHaskell :: UniqueDef -> !HaskellName uniqueDBName :: UniqueDef -> !DBName uniqueFields :: UniqueDef -> ![(HaskellName, DBName)] uniqueAttrs :: UniqueDef -> ![Attr] data PersistException -- | Generic Exception PersistError :: Text -> PersistException PersistMarshalError :: Text -> PersistException PersistInvalidField :: Text -> PersistException PersistForeignConstraintUnmet :: Text -> PersistException PersistMongoDBError :: Text -> PersistException PersistMongoDBUnsupported :: Text -> PersistException -- | Avoid orphan instances. newtype ZT ZT :: ZonedTime -> ZT -- | A raw value which can be stored in any backend and can be marshalled -- to and from a PersistField. data PersistValue PersistText :: Text -> PersistValue PersistByteString :: ByteString -> PersistValue PersistInt64 :: Int64 -> PersistValue PersistDouble :: Double -> PersistValue PersistRational :: Rational -> PersistValue PersistBool :: Bool -> PersistValue PersistDay :: Day -> PersistValue PersistTimeOfDay :: TimeOfDay -> PersistValue PersistUTCTime :: UTCTime -> PersistValue PersistZonedTime :: ZT -> PersistValue PersistNull :: PersistValue PersistList :: [PersistValue] -> PersistValue PersistMap :: [(Text, PersistValue)] -> PersistValue -- | intended especially for MongoDB backend PersistObjectId :: ByteString -> PersistValue fromPersistValueText :: PersistValue -> Either String Text -- | 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. data SqlType SqlString :: SqlType SqlInt32 :: SqlType SqlInt64 :: SqlType SqlReal :: SqlType SqlNumeric :: Word32 -> Word32 -> SqlType SqlBool :: SqlType SqlDay :: SqlType SqlTime :: SqlType SqlDayTime :: SqlType SqlDayTimeZoned :: SqlType SqlBlob :: SqlType -- | a backend-specific name SqlOther :: Text -> SqlType newtype KeyBackend backend entity Key :: PersistValue -> KeyBackend backend entity unKey :: KeyBackend backend entity -> PersistValue data PersistFilter Eq :: PersistFilter Ne :: PersistFilter Gt :: PersistFilter Lt :: PersistFilter Ge :: PersistFilter Le :: PersistFilter In :: PersistFilter NotIn :: PersistFilter BackendSpecificFilter :: Text -> PersistFilter data UpdateGetException KeyNotFound :: String -> UpdateGetException data PersistUpdate Assign :: PersistUpdate Add :: PersistUpdate Subtract :: PersistUpdate Multiply :: PersistUpdate Divide :: PersistUpdate data SomePersistField SomePersistField :: a -> SomePersistField data Update v Update :: EntityField v typ -> typ -> PersistUpdate -> Update v updateField :: Update v -> EntityField v typ updateValue :: Update v -> typ updateUpdate :: Update v -> PersistUpdate data SelectOpt v Asc :: (EntityField v typ) -> SelectOpt v Desc :: (EntityField v typ) -> SelectOpt v OffsetBy :: Int -> SelectOpt v LimitTo :: Int -> SelectOpt v -- | Filters which are available for select, updateWhere -- and deleteWhere. Each filter constructor specifies the field -- being filtered on, the type of comparison applied (equals, not equals, -- etc) and the argument for the comparison. data Filter v Filter :: EntityField v typ -> Either typ [typ] -> PersistFilter -> Filter v filterField :: Filter v -> EntityField v typ filterValue :: Filter v -> Either typ [typ] filterFilter :: Filter v -> PersistFilter -- | convenient for internal use, not needed for the API FilterAnd :: [Filter v] -> Filter v FilterOr :: [Filter v] -> Filter v BackendFilter :: (BackendSpecificFilter (PersistEntityBackend v) v) -> Filter v -- | Helper wrapper, equivalent to Key (PersistEntityBackend val) -- val. -- -- Since 1.1.0 type Key val = KeyBackend (PersistEntityBackend val) val -- | Datatype that represents an entity, with both its key and its Haskell -- representation. -- -- When using the an 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. data Entity entity Entity :: Key entity -> entity -> Entity entity entityKey :: Entity entity -> Key entity entityVal :: Entity entity -> entity module Database.Persist.Quasi -- | Parses a quasi-quoted syntax into a list of entity definitions. parse :: PersistSettings -> Text -> [EntityDef ()] data PersistSettings PersistSettings :: !(Text -> Text) -> !Bool -> PersistSettings psToDBName :: PersistSettings -> !(Text -> Text) -- | Whether fields are by default strict. Default value: True. -- -- Since 1.2 psStrictFields :: PersistSettings -> !Bool upperCaseSettings :: PersistSettings lowerCaseSettings :: PersistSettings stripId :: FieldType -> Maybe Text nullable :: [Text] -> IsNullable instance Show Token instance Eq Token module Database.Persist.Class class MonadIO m => PersistStore m where type family PersistMonadBackend m insert_ val = insert val >> return () insertMany = mapM insert get :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> m (Maybe val) insert :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => val -> m (Key val) insert_ :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => val -> m () insertMany :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => [val] -> m [Key val] insertKey :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m () repsert :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m () replace :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m () delete :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> m () -- | Same as get, but for a non-null (not Maybe) foreign key Unsafe unless -- your database is enforcing that the foreign key is valid getJust :: (PersistStore m, PersistEntity val, Show (Key val), PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> m val belongsTo :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Maybe (Key ent2)) -> ent1 -> m (Maybe ent2) -- | same as belongsTo, but uses getJust and therefore is -- similarly unsafe belongsToJust :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Key ent2) -> ent1 -> m ent2 -- | Queries against unique keys (other than the id). -- -- Please read the general Persistent documentation to learn how to -- create Unique keys. SQL backends automatically create uniqueness -- constraints, but for MongoDB you must manually place a unique index on -- the field. -- -- 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 tryting to catch the correct exception and determing the -- column of failure. * an exception will automatically abort the current -- SQL transaction class PersistStore m => PersistUnique m where insertUnique datum = do { conflict <- checkUnique datum; case conflict of { Nothing -> Just `liftM` insert datum Just _ -> return Nothing } } getBy :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => Unique val -> m (Maybe (Entity val)) deleteBy :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => Unique val -> m () insertUnique :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => val -> m (Maybe (Key val)) -- | A modification of getBy, which takes the PersistEntity -- itself instead of a Unique value. Returns a value matching -- one of the unique keys. This function makes the most sense on -- entities with a single Unique constructor. getByValue :: (PersistEntity value, PersistUnique m, PersistEntityBackend value ~ PersistMonadBackend m) => value -> m (Maybe (Entity value)) -- | 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. insertBy :: (PersistEntity val, PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m) => val -> m (Either (Entity val) (Key val)) -- | 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 Unque -- violation -- -- Since 1.2.2.0 replaceUnique :: (Eq record, Eq (Unique record), PersistEntityBackend record ~ PersistMonadBackend m, PersistEntity record, PersistStore m, PersistUnique m) => Key record -> record -> m (Maybe (Unique record)) class PersistStore m => PersistQuery m where updateGet key ups = do { update key ups; get key >>= maybe (liftIO $ throwIO $ KeyNotFound $ show key) return } selectFirst filts opts = selectSource filts ((LimitTo 1) : opts) $$ head update :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => Key val -> [Update val] -> m () updateGet :: (PersistQuery m, PersistEntity val, PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> [Update val] -> m val updateWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [Update val] -> m () deleteWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m () selectSource :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Entity val) selectFirst :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m (Maybe (Entity val)) selectKeys :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Key val) count :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m Int -- | Call selectSource but return the result as a list. selectList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Entity val] -- | Call selectKeys but return the result as a list. selectKeysList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Key val] class (PersistStore m, PersistEntity a, PersistEntityBackend a ~ PersistMonadBackend m) => DeleteCascade a m deleteCascade :: DeleteCascade a m => Key a -> m () deleteCascadeWhere :: (DeleteCascade a m, PersistQuery m) => [Filter a] -> m () -- | A single database entity. For example, if writing a blog application, -- a blog entry would be an entry, containing fields such as title and -- content. class PersistEntity val where data family EntityField val :: * -> * type family PersistEntityBackend val data family Unique val persistFieldDef :: PersistEntity val => EntityField val typ -> FieldDef SqlType entityDef :: (PersistEntity val, Monad m) => m val -> EntityDef SqlType toPersistFields :: PersistEntity val => val -> [SomePersistField] fromPersistValues :: PersistEntity val => [PersistValue] -> Either Text val persistUniqueToFieldNames :: PersistEntity val => Unique val -> [(HaskellName, DBName)] persistUniqueToValues :: PersistEntity val => Unique val -> [PersistValue] persistUniqueKeys :: PersistEntity val => val -> [Unique val] persistIdField :: PersistEntity val => EntityField val (Key val) fieldLens :: PersistEntity val => EntityField val field -> (forall f. Functor f => (field -> f field) -> Entity val -> f (Entity val)) -- | A value which can be marshalled to and from a PersistValue. class PersistField a toPersistValue :: PersistField a => a -> PersistValue fromPersistValue :: PersistField a => PersistValue -> Either Text a -- | 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. class PersistConfig c where type family PersistConfigBackend c :: (* -> *) -> * -> * type family PersistConfigPool c applyEnv = return loadConfig :: PersistConfig c => Value -> Parser c applyEnv :: PersistConfig c => c -> IO c createPoolConfig :: PersistConfig c => c -> IO (PersistConfigPool c) runPool :: (PersistConfig c, MonadBaseControl IO m, MonadIO m) => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m a module Database.Persist -- | assign a field a value (=.) :: PersistField typ => EntityField v typ -> typ -> Update v -- | assign a field by addition (+=) (+=.) :: PersistField typ => EntityField v typ -> typ -> Update v -- | assign a field by subtraction (-=) (-=.) :: PersistField typ => EntityField v typ -> typ -> Update v -- | assign a field by multiplication (*=) (*=.) :: PersistField typ => EntityField v typ -> typ -> Update v -- | assign a field by division (/=) (/=.) :: PersistField typ => EntityField v typ -> typ -> Update v (==.) :: PersistField typ => EntityField v typ -> typ -> Filter v (!=.) :: PersistField typ => EntityField v typ -> typ -> Filter v (<.) :: PersistField typ => EntityField v typ -> typ -> Filter v (>.) :: PersistField typ => EntityField v typ -> typ -> Filter v (<=.) :: PersistField typ => EntityField v typ -> typ -> Filter v (>=.) :: PersistField typ => EntityField v typ -> typ -> Filter v -- | In (<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v -- | NotIn (/<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v -- | the OR of two lists of filters (||.) :: [Filter v] -> [Filter v] -> [Filter v] listToJSON :: [PersistValue] -> Text mapToJSON :: [(Text, PersistValue)] -> Text getPersistMap :: PersistValue -> Either Text [(Text, PersistValue)] limitOffsetOrder :: PersistEntity val => [SelectOpt val] -> (Int, Int, [SelectOpt val]) module Database.Persist.Sql data InsertSqlResult ISRSingle :: Text -> InsertSqlResult ISRInsertGet :: Text -> Text -> InsertSqlResult data Connection Connection :: (Text -> IO Statement) -> (DBName -> [DBName] -> DBName -> InsertSqlResult) -> IORef (Map Text Statement) -> IO () -> ([EntityDef SqlType] -> (Text -> IO Statement) -> EntityDef SqlType -> IO (Either [Text] [(Bool, Text)])) -> ((Text -> IO Statement) -> IO ()) -> ((Text -> IO Statement) -> IO ()) -> ((Text -> IO Statement) -> IO ()) -> (DBName -> Text) -> Text -> Text -> Connection connPrepare :: Connection -> Text -> IO Statement -- | table name, column names, id name, either 1 or 2 statements to run connInsertSql :: Connection -> DBName -> [DBName] -> DBName -> InsertSqlResult connStmtMap :: Connection -> IORef (Map Text Statement) connClose :: Connection -> IO () connMigrateSql :: Connection -> [EntityDef SqlType] -> (Text -> IO Statement) -> EntityDef SqlType -> IO (Either [Text] [(Bool, Text)]) connBegin :: Connection -> (Text -> IO Statement) -> IO () connCommit :: Connection -> (Text -> IO Statement) -> IO () connRollback :: Connection -> (Text -> IO Statement) -> IO () connEscapeName :: Connection -> DBName -> Text connNoLimit :: Connection -> Text connRDBMS :: Connection -> Text data Statement Statement :: IO () -> IO () -> ([PersistValue] -> IO Int64) -> (forall m. MonadResource m => [PersistValue] -> Source m [PersistValue]) -> Statement stmtFinalize :: Statement -> IO () stmtReset :: Statement -> IO () stmtExecute :: Statement -> [PersistValue] -> IO Int64 stmtQuery :: Statement -> forall m. MonadResource m => [PersistValue] -> Source m [PersistValue] data Column Column :: !DBName -> !Bool -> !SqlType -> !(Maybe Text) -> !(Maybe Integer) -> !(Maybe (DBName, DBName)) -> Column cName :: Column -> !DBName cNull :: Column -> !Bool cSqlType :: Column -> !SqlType cDefault :: Column -> !(Maybe Text) cMaxLen :: Column -> !(Maybe Integer) cReference :: Column -> !(Maybe (DBName, DBName)) data PersistentSqlException StatementAlreadyFinalized :: Text -> PersistentSqlException Couldn'tGetSQLConnection :: PersistentSqlException data SqlBackend newtype SqlPersistT m a SqlPersistT :: ReaderT Connection m a -> SqlPersistT m a unSqlPersistT :: SqlPersistT m a -> ReaderT Connection m a -- | Deprecated: Please use SqlPersistT instead type SqlPersist = SqlPersistT type SqlPersistM = SqlPersistT (NoLoggingT (ResourceT IO)) type Sql = Text type CautiousMigration = [(Bool, Sql)] type Migration m = WriterT [Text] (WriterT CautiousMigration m) () type ConnectionPool = Pool Connection -- | A single column (see rawSql). Any PersistField may -- be used here, including PersistValue (which does not do any -- processing). newtype Single a Single :: a -> Single a unSingle :: Single a -> a class (MonadIO m, MonadLogger m) => MonadSqlPersist m where askSqlConn = lift askSqlConn askSqlConn :: MonadSqlPersist m => m Connection -- | Class for data types that may be retrived from a rawSql -- query. class RawSql a rawSqlCols :: RawSql a => (DBName -> Text) -> a -> (Int, [Text]) rawSqlColCountReason :: RawSql a => a -> String rawSqlProcessRow :: RawSql a => [PersistValue] -> Either Text a class PersistField a => PersistFieldSql a sqlType :: (PersistFieldSql a, Monad m) => m a -> SqlType -- | Get a connection from the pool, run the given action, and then return -- the connection to the pool. runSqlPool :: MonadBaseControl IO m => SqlPersistT m a -> Pool Connection -> m a runSqlConn :: MonadBaseControl IO m => SqlPersistT m a -> Connection -> m a runSqlPersistM :: SqlPersistM a -> Connection -> IO a runSqlPersistMPool :: SqlPersistM a -> Pool Connection -> IO a withSqlPool :: MonadIO m => IO Connection -> Int -> (Pool Connection -> m a) -> m a createSqlPool :: MonadIO m => IO Connection -> Int -> m (Pool Connection) withSqlConn :: (MonadIO m, MonadBaseControl IO m) => IO Connection -> (Connection -> m a) -> m a close' :: Connection -> IO () parseMigration :: Monad m => Migration m -> m (Either [Text] CautiousMigration) parseMigration' :: Monad m => Migration m -> m (CautiousMigration) printMigration :: MonadIO m => Migration m -> m () getMigration :: (MonadBaseControl IO m, MonadIO m) => Migration m -> m [Sql] runMigration :: MonadSqlPersist m => Migration m -> m () -- | Same as runMigration, but returns a list of the SQL commands -- executed instead of printing them to stderr. runMigrationSilent :: (MonadBaseControl IO m, MonadSqlPersist m) => Migration m -> m [Text] runMigrationUnsafe :: MonadSqlPersist m => Migration m -> m () migrate :: MonadSqlPersist m => [EntityDef SqlType] -> EntityDef SqlType -> Migration m rawQuery :: (MonadSqlPersist m, MonadResource m) => Text -> [PersistValue] -> Source m [PersistValue] rawExecute :: MonadSqlPersist m => Text -> [PersistValue] -> m () rawExecuteCount :: MonadSqlPersist m => Text -> [PersistValue] -> m Int64 -- | Execute a raw SQL statement and return its results as a list. -- -- 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. rawSql :: (RawSql a, MonadSqlPersist m, MonadResource m) => Text -> [PersistValue] -> m [a] -- | Same as deleteWhere, but returns the number of rows affected. -- -- Since 1.1.5 deleteWhereCount :: (PersistEntity val, MonadSqlPersist m) => [Filter val] -> m Int64 -- | Same as updateWhere, but returns the number of rows affected. -- -- Since 1.1.5 updateWhereCount :: (PersistEntity val, MonadSqlPersist m) => [Filter val] -> [Update val] -> m Int64 -- | Commit the current transaction and begin a new one. -- -- Since 1.2.0 transactionSave :: MonadSqlPersist m => m () -- | Roll back the current transaction and begin a new one. -- -- Since 1.2.0 transactionUndo :: MonadSqlPersist m => m () getStmtConn :: Connection -> Text -> IO Statement -- | Create the list of columns for the given entity. mkColumns :: [EntityDef a] -> EntityDef SqlType -> ([Column], [UniqueDef])