| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hasql.Class.Encodable
Documentation
class Encodable a where Source
Datatypes that can be encoded as hasql PostgreSQL parameters.
Note that the number of parameters is not necessarily the number of Haskell values. For example
data MyData = MyData { aChar :: Char, aText :: Text }
deriving (Eq, Show, Generic, Encodable)
aData :: MyData
aData = MyDate 'a' "ha!"
-- Will only insert the char, and a NULL for the text value
wrong = query aData stmtUnit "INSERT INTO myTable ($1)" True
-- Will insert both the char and the text values
right = query aData stmtUnit "INSERT INTO myTable ($1, $2)" TrueMinimal complete definition
Nothing
Instances