Hoogle Search
Within LTS Haskell 24.41 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
iidMaxLen :: ImplicitIdDef -> Maybe Integerpersistent Database.Persist.ImplicitIdDef.Internal Specify the maximum length for a key column. This is necessary for VARCHAR columns, like UUID in MySQL. MySQL will throw a runtime error if a text or binary column is used in an index without a length specification.
iidType :: ImplicitIdDef -> Bool -> Type -> Typepersistent Database.Persist.ImplicitIdDef.Internal The Bool argument is whether or not the MkPersistBackend type has the mpsGeneric field set. The Type is the mpsBackend value. The default uses BackendKey SqlBackend (or a generic equivalent).
mkImplicitIdDef :: (Typeable t, PersistFieldSql t) => Text -> ImplicitIdDefpersistent Database.Persist.ImplicitIdDef.Internal Create an ImplicitIdDef based on the Typeable and PersistFieldSql constraints in scope. This function uses the TypeApplications syntax. Let's look at an example that works with Postgres UUIDs.
newtype UUID = UUID Text deriving newtype PersistField instance PersistFieldSql UUID where sqlType _ = SqlOther "UUID" idDef :: ImplicitIdDef idDef = mkImplicitIdDefTypeable @UUID "uuid_generate_v1mc()"
This ImplicitIdDef will generate default UUID columns, and the database will call the uuid_generate_v1mc() function to generate the value for new rows being inserted. If the type t is Text or String then a max_len attribute of 200 is set. To customize this, use setImplicitIdDefMaxLen.setImplicitIdDefMaxLen :: Integer -> ImplicitIdDef -> ImplicitIdDefpersistent Database.Persist.ImplicitIdDef.Internal Set the maximum length of the implied ID column. This is required for any type where the associated SqlType is a TEXT or VARCHAR sort of thing.
unsafeClearDefaultImplicitId :: ImplicitIdDef -> ImplicitIdDefpersistent Database.Persist.ImplicitIdDef.Internal Remove the default attribute of the ImplicitIdDef column. This will require you to provide an ID for the model with every insert, using insertKey instead of insert, unless the type has some means of getting around that in the migrations. As an example, the Postgresql SERIAL type expands to an autoincrementing integer. Postgres will implicitly create the relevant series and set the default to be NEXTVAL(series_name). A default is therefore unnecessary to use for this type. However, for a UUID, postgres *does not* have an implicit default. You must either specify a default UUID generation function, or insert them yourself (again, using insertKey). This function will be deprecated in the future when omiting the default implicit ID column is more fully supported.
PersistObjectId :: ByteString -> PersistValuepersistent Database.Persist.PersistValue Intended especially for MongoDB backend
getPsIdName :: PersistSettings -> Textpersistent Database.Persist.Quasi Retrieve the default name of the id column.
setPsIdName :: Text -> PersistSettings -> PersistSettingspersistent Database.Persist.Quasi Set the default name of the id column.
FieldListImpliedId :: NonEmpty FieldNameHS -> UnboundForeignFieldListpersistent Database.Persist.Quasi.Internal If no References keyword is supplied, then it is assumed that you are referring to the Primary key or Id of the target entity.
-
persistent Database.Persist.Quasi.Internal This type represents an Id declaration in the QuasiQuoted syntax.
Id
This uses the implied settings, and is equivalent to omitting the Id statement entirely.Id Text
This will set the field type of the ID to be Text.Id Text sql=foo_id
This will set the field type of the Id to be Text and the SQL DB name to be foo_id.Id FooId
This results in a shared primary key - the FooId refers to a Foo table.Id FooId OnDelete Cascade
You can set a cascade behavior on an ID column.