persistent-2.14.6.2: Type-safe, multi-backend data serialization.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.Persist.PersistValue

Description

This module contains an intermediate representation of values before the backends serialize them into explicit database types.

Since: 2.13.0.0

Synopsis

Documentation

data PersistValue Source #

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 LiteralType value specifies how the value should be escaped. This can be used to make special, custom types avaialable in the back end.

Since: 2.12.0.0

Bundled Patterns

pattern PersistLiteral :: ByteString -> PersistValue

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.

Since: 2.12.0.0

pattern PersistLiteralEscaped :: ByteString -> PersistValue

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.

Since: 2.12.0.0

pattern PersistDbSpecific :: ByteString -> PersistValue

Deprecated: Deprecated since 2.11 because of inconsistent escaping behavior across backends. The Postgres backend escapes these values, while the MySQL backend does not. If you are using this, please switch to PersistLiteral_ and provide a relevant LiteralType for your conversion.

This pattern synonym used to be a data constructor for the PersistValue type. It was changed to be a pattern so that JSON-encoded database values could be parsed into their corresponding values. You should not use this, and instead prefer to pattern match on PersistLiteral_ directly.

If you use this, it will overlap a patern match on the 'PersistLiteral_, PersistLiteral, and PersistLiteralEscaped patterns. If you need to disambiguate between these constructors, pattern match on PersistLiteral_ directly.

Since: 2.12.0.0

Instances

Instances details
FromJSON PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

ToJSON PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

Read PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

Show PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

NFData PersistValue Source #

Since: 2.14.4.0

Instance details

Defined in Database.Persist.PersistValue

Methods

rnf :: PersistValue -> () #

Eq PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

Ord PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

FromHttpApiData PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

ToHttpApiData PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

PathPiece PersistValue Source # 
Instance details

Defined in Database.Persist.PersistValue

PersistField PersistValue Source # 
Instance details

Defined in Database.Persist.Class.PersistField

PersistFieldSql PersistValue Source # 
Instance details

Defined in Database.Persist.Sql.Class

data LiteralType Source #

A type that determines how a backend should handle the literal.

Since: 2.12.0.0

Constructors

Escaped

The accompanying value will be escaped before inserting into the database. This is the correct default choice to use.

Since: 2.12.0.0

Unescaped

The accompanying value will not be escaped when inserting into the database. This is potentially dangerous - use this with care.

Since: 2.12.0.0

DbSpecific

The DbSpecific constructor corresponds to the legacy PersistDbSpecific constructor. We need to keep this around because old databases may have serialized JSON representations that reference this. We don't want to break the ability of a database to load rows.

Since: 2.12.0.0