postgresql-typed-0.5.1: PostgreSQL interface with compile-time SQL type checking, optional HDBC backend

Copyright2015 Dylan Simon
Safe HaskellNone
LanguageHaskell98

Database.PostgreSQL.Typed.Dynamic

Description

Automatic (dynamic) marshalling of PostgreSQL values based on Haskell types (not SQL statements). This is intended for direct construction of queries and query data, bypassing the normal SQL type inference.

Synopsis

Documentation

class (PGParameter (PGRepType a) a, PGColumn (PGRepType a) a) => PGRep a #

Represents canonical/default PostgreSQL representation for various Haskell types, allowing convenient type-driven marshalling.

Associated Types

type PGRepType a :: Symbol #

The PostgreSOL type that this type should be converted to.

Instances

PGRep Bool # 

Associated Types

type PGRepType Bool :: Symbol #

PGRep Char # 

Associated Types

type PGRepType Char :: Symbol #

PGRep Double # 

Associated Types

type PGRepType Double :: Symbol #

PGRep Float # 

Associated Types

type PGRepType Float :: Symbol #

PGRep Int16 # 

Associated Types

type PGRepType Int16 :: Symbol #

PGRep Int32 # 

Associated Types

type PGRepType Int32 :: Symbol #

PGRep Int64 # 

Associated Types

type PGRepType Int64 :: Symbol #

PGRep Rational # 

Associated Types

type PGRepType Rational :: Symbol #

PGRep () # 

Associated Types

type PGRepType () :: Symbol #

PGRep String # 

Associated Types

type PGRepType String :: Symbol #

PGRep ByteString # 

Associated Types

type PGRepType ByteString :: Symbol #

PGRep Scientific # 

Associated Types

type PGRepType Scientific :: Symbol #

PGRep Text # 

Associated Types

type PGRepType Text :: Symbol #

PGRep UTCTime # 

Associated Types

type PGRepType UTCTime :: Symbol #

PGRep Value # 

Associated Types

type PGRepType Value :: Symbol #

PGRep UUID # 

Associated Types

type PGRepType UUID :: Symbol #

PGRep DiffTime # 

Associated Types

type PGRepType DiffTime :: Symbol #

PGRep Day # 

Associated Types

type PGRepType Day :: Symbol #

PGRep TimeOfDay # 

Associated Types

type PGRepType TimeOfDay :: Symbol #

PGRep LocalTime # 

Associated Types

type PGRepType LocalTime :: Symbol #

PGRep OID # 

Associated Types

type PGRepType OID :: Symbol #

PGRep PGName # 

Associated Types

type PGRepType PGName :: Symbol #

PGRep a => PGRep (Maybe a) # 

Associated Types

type PGRepType (Maybe a) :: Symbol #

PGRep (TimeOfDay, TimeZone) # 

Associated Types

type PGRepType (TimeOfDay, TimeZone) :: Symbol #

pgEncodeRep :: PGRep a => a -> PGValue #

Encode a value using pgEncodeValue.

pgDecodeRep :: forall a. PGRep a => PGValue -> a #

Decode a value using pgDecodeValue.

pgLiteralRep :: PGRep a => a -> ByteString #

Produce a literal value for interpolation in a SQL statement using pgLiteral. Using pgSafeLiteral is usually safer as it includes type cast.

pgLiteralString :: PGRep a => a -> String #

Produce a raw SQL literal from a value. Using pgSafeLiteral is usually safer when interpolating in a SQL statement.

pgSafeLiteral :: PGRep a => a -> ByteString #

Produce a safely type-cast literal value for interpolation in a SQL statement, e.g., "'123'::integer".

pgSafeLiteralString :: PGRep a => a -> String #

Identical to unpack . pgSafeLiteral but more efficient.

pgSubstituteLiterals :: String -> ExpQ #

Create an expression that literally substitutes each instance of ${expr} for the result of pgSafeLiteral expr, producing a lazy ByteString. This lets you do safe, type-driven literal substitution into SQL fragments without needing a full query, bypassing placeholder inference and any prepared queries, for example when using pgSimpleQuery or pgSimpleQueries_. Unlike most other TH functions, this does not require any database connection.