| 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 (PGParameter (PGRepType a) a, PGColumn (PGRepType a) a) => PGRep a where
- pgTypeOf :: a -> PGTypeID (PGRepType a)
- pgTypeOfProxy :: Proxy a -> PGTypeID (PGRepType a)
- pgEncodeRep :: PGRep a => a -> PGValue
- pgDecodeRep :: forall a. PGRep a => PGValue -> a
- pgLiteralRep :: PGRep a => a -> ByteString
- pgLiteralString :: PGRep a => a -> String
- pgSafeLiteral :: PGRep a => a -> ByteString
- pgSafeLiteralString :: PGRep a => a -> String
- pgSubstituteLiterals :: String -> ExpQ
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
The PostgreSOL type that this type should be converted to.
Instances
| PGRep Bool # | |
| PGRep Char # | |
| PGRep Double # | |
| PGRep Float # | |
| PGRep Int16 # | |
| PGRep Int32 # | |
| PGRep Int64 # | |
| PGRep Rational # | |
| PGRep () # | |
| PGRep String # | |
| PGRep ByteString # | |
| PGRep Scientific # | |
| PGRep Text # | |
| PGRep UTCTime # | |
| PGRep Value # | |
| PGRep UUID # | |
| PGRep DiffTime # | |
| PGRep Day # | |
| PGRep TimeOfDay # | |
| PGRep LocalTime # | |
| PGRep OID # | |
| PGRep PGName # | |
| PGRep a => PGRep (Maybe a) # | |
| PGRep (TimeOfDay, TimeZone) # | |
pgTypeOfProxy :: Proxy a -> PGTypeID (PGRepType a) #
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 but more efficient.unpack . pgSafeLiteral
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.