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.

  1. iidMaxLen :: ImplicitIdDef -> Maybe Integer

    persistent 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.

  2. iidType :: ImplicitIdDef -> Bool -> Type -> Type

    persistent 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).

  3. mkImplicitIdDef :: (Typeable t, PersistFieldSql t) => Text -> ImplicitIdDef

    persistent 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.

  4. setImplicitIdDefMaxLen :: Integer -> ImplicitIdDef -> ImplicitIdDef

    persistent 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.

  5. unsafeClearDefaultImplicitId :: ImplicitIdDef -> ImplicitIdDef

    persistent 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.

  6. PersistObjectId :: ByteString -> PersistValue

    persistent Database.Persist.PersistValue

    Intended especially for MongoDB backend

  7. getPsIdName :: PersistSettings -> Text

    persistent Database.Persist.Quasi

    Retrieve the default name of the id column.

  8. setPsIdName :: Text -> PersistSettings -> PersistSettings

    persistent Database.Persist.Quasi

    Set the default name of the id column.

  9. FieldListImpliedId :: NonEmpty FieldNameHS -> UnboundForeignFieldList

    persistent 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.

  10. data UnboundIdDef

    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.

Page 597 of many | Previous | Next