Hoogle Search

Within LTS Haskell 24.40 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. class PersistField a => PersistFieldSql a

    esqueleto Database.Esqueleto.Legacy

    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)
    
    instance PersistField Switch where
    toPersistValue s = case s of
    On -> PersistBool True
    Off -> PersistBool False
    fromPersistValue (PersistBool b) = if b then Right On else Right Off
    fromPersistValue x = Left $ "File.hs: When trying to deserialize a Switch: expected PersistBool, received: " <> T.pack (show x)
    
    instance PersistFieldSql Switch where
    sqlType _ = SqlBool
    
    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
    instance PersistField UUID where
    toPersistValue = PersistLiteralEncoded . toASCIIBytes
    fromPersistValue (PersistLiteralEncoded uuid) =
    case fromASCIIBytes uuid of
    Nothing -> Left $ "Model/CustomTypes.hs: Failed to deserialize a UUID; received: " <> T.pack (show uuid)
    Just uuid' -> Right uuid'
    fromPersistValue x = Left $ "File.hs: When trying to deserialize a UUID: expected PersistLiteralEncoded, received: "-- >  <> T.pack (show x)
    
    instance PersistFieldSql UUID where
    sqlType _ = SqlOther "uuid"
    
    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}$');
    
    instance PersistFieldSQL SSN where
    sqlType _ = SqlOther "ssn"
    
    CREATE TYPE rainbow_color AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet');
    
    instance PersistFieldSQL RainbowColor where
    sqlType _ = SqlOther "rainbow_color"
    

  2. data PersistFilter

    esqueleto Database.Esqueleto.Legacy

    No documentation available.

  3. PersistForeignConstraintUnmet :: Text -> PersistException

    esqueleto Database.Esqueleto.Legacy

    No documentation available.

  4. PersistInt64 :: Int64 -> PersistValue

    esqueleto Database.Esqueleto.Legacy

    No documentation available.

  5. PersistInvalidField :: Text -> PersistException

    esqueleto Database.Esqueleto.Legacy

    No documentation available.

  6. PersistList :: [PersistValue] -> PersistValue

    esqueleto Database.Esqueleto.Legacy

    No documentation available.

  7. pattern PersistLiteral :: ByteString -> PersistValue

    esqueleto Database.Esqueleto.Legacy

    This pattern synonym used to be a data constructor on PersistValue, but was changed into a catch-all pattern synonym to allow backwards compatiblity with database types. See the documentation on PersistDbSpecific for more details.

  8. pattern PersistLiteralEscaped :: ByteString -> PersistValue

    esqueleto Database.Esqueleto.Legacy

    This pattern synonym used to be a data constructor on PersistValue, but was changed into a catch-all pattern synonym to allow backwards compatiblity with database types. See the documentation on PersistDbSpecific for more details.

  9. PersistLiteral_ :: LiteralType -> ByteString -> PersistValue

    esqueleto Database.Esqueleto.Legacy

    This constructor is used to specify some raw literal value for the backend. The LiteralType value specifies how the value should be escaped. This can be used to make special, custom types avaialable in the back end.

  10. PersistMap :: [(Text, PersistValue)] -> PersistValue

    esqueleto Database.Esqueleto.Legacy

    No documentation available.

Page 494 of many | Previous | Next