postgresql-typed-0.4.3: A PostgreSQL access library with compile-time SQL type inference

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 PGType t => PGRep t a | a -> t where Source

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

Minimal complete definition

Nothing

Instances

PGRep "\"char\"" Char Source 
PGRep "bigint" Int64 Source 
PGRep "boolean" Bool Source 
PGRep "date" Day Source 
PGRep "double precision" Double Source 
PGRep "integer" Int32 Source 
PGRep "interval" DiffTime Source 
PGRep "numeric" Rational Source 
PGRep "numeric" Scientific Source 
PGRep "oid" OID Source 
PGRep "real" Float Source 
PGRep "smallint" Int16 Source 
PGRep "text" String Source 
PGRep "text" ByteString Source 
PGRep "text" Text Source 
PGRep "time without time zone" TimeOfDay Source 
PGRep "timestamp with time zone" UTCTime Source 
PGRep "timestamp without time zone" LocalTime Source 
PGRep "uuid" UUID Source 
PGRep t a => PGRep t (Maybe a) Source 

pgLiteralString :: PGRep t a => a -> String Source

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

pgSafeLiteral :: PGRep t a => a -> ByteString Source

Produce a safely type-cast literal value for interpolation in a SQL statement.

pgSafeLiteralString :: PGRep t a => a -> String Source

Identical to unpack . pgSafeLiteral but more efficient.

pgSubstituteLiterals :: String -> ExpQ Source

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