Copyright | 2015 Dylan Simon |
---|---|
Safe Haskell | None |
Language | Haskell98 |
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.
- class PGType t => PGRep t a | a -> t where
- pgTypeOf :: a -> PGTypeName t
- pgEncodeRep :: a -> PGValue
- pgLiteralRep :: a -> String
- pgDecodeRep :: PGValue -> a
- pgSafeLiteral :: PGRep t a => a -> String
- pgSubstituteLiterals :: String -> ExpQ
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.
Nothing
pgTypeOf :: a -> PGTypeName t Source
pgEncodeRep :: a -> PGValue Source
pgLiteralRep :: a -> String Source
pgDecodeRep :: PGValue -> a Source
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.