Copyright | 2015 Dylan Simon |
---|---|
Safe Haskell | None |
Language | Haskell98 |
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.
- class PGType t => PGRep t a | a -> t where
- pgTypeOf :: a -> PGTypeName t
- pgEncodeRep :: a -> PGValue
- pgLiteralRep :: a -> ByteString
- pgDecodeRep :: PGValue -> a
- pgLiteralString :: PGRep t a => a -> String
- pgSafeLiteral :: PGRep t a => a -> ByteString
- pgSafeLiteralString :: 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.
Minimal complete definition
Nothing
Methods
pgTypeOf :: a -> PGTypeName t Source
pgEncodeRep :: a -> PGValue Source
pgLiteralRep :: a -> ByteString Source
pgDecodeRep :: PGValue -> a Source
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" ByteString | |
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) |
pgLiteralString :: PGRep t a => a -> String Source
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
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.