postgresql-typed-0.3.1: 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 
PGRep "bigint" Int64 
PGRep "boolean" Bool 
PGRep "date" Day 
PGRep "double precision" Double 
PGRep "integer" Int32 
PGRep "interval" DiffTime 
PGRep "numeric" Rational 
PGRep "numeric" Scientific 
PGRep "oid" OID 
PGRep "real" Float 
PGRep "smallint" Int16 
PGRep "text" String 
PGRep "text" Text 
PGRep "time without time zone" TimeOfDay 
PGRep "timestamp with time zone" UTCTime 
PGRep "timestamp without time zone" LocalTime 
PGRep "uuid" UUID 
PGRep t a => PGRep t (Maybe a) 

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

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

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.