Copyright | 2013 Kei Hibino |
---|---|
License | BSD3 |
Maintainer | ex8k.hibino@gmail.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
This module defines interfaces from Haskell type into list of SQL type.
- type ToSqlM q a = Writer (DList q) a
- data RecordToSql q a
- runFromRecord :: RecordToSql q a -> a -> [q]
- createRecordToSql :: (a -> [q]) -> RecordToSql q a
- (<&>) :: RecordToSql q a -> RecordToSql q b -> RecordToSql q (a, b)
- class ToSql q a where
- recordToSql :: RecordToSql q a
- putRecord :: ToSql q a => a -> ToSqlM q ()
- putEmpty :: () -> ToSqlM q ()
- fromRecord :: ToSql q a => a -> [q]
- wrapToSql :: (a -> ToSqlM q ()) -> RecordToSql q a
- valueToSql :: PersistableValue q a => RecordToSql q a
- updateValuesByUnique' :: RecordToSql q ra -> KeyConstraint Unique ra -> ra -> [q]
- updateValuesByUnique :: ToSql q ra => KeyConstraint Unique ra -> ra -> [q]
- updateValuesByPrimary :: (HasKeyConstraint Primary ra, ToSql q ra) => ra -> [q]
- untypedUpdateValuesIndex :: [Int] -> Int -> [Int]
- unsafeUpdateValuesWithIndexes :: RecordToSql q ra -> [Int] -> ra -> [q]
Conversion from record type into list of SQL type
data RecordToSql q a Source
Proof object type to convert from Haskell type a
into list of SQL type [q
].
:: RecordToSql q a | Proof object which has capability to convert |
-> a | Haskell type |
-> [q] | list of SQL type |
Run RecordToSql
proof object. Convert from Haskell type a
into list of SQL type [q
].
:: (a -> [q]) | Convert function body |
-> RecordToSql q a | Result proof object |
Axiom of RecordToSql
for SQL type q
and Haksell type a
.
(<&>) :: RecordToSql q a -> RecordToSql q b -> RecordToSql q (a, b) infixl 4 Source
Derivation rule of RecordToSql
proof object for Haskell tuple (,) type.
Inference rules of RecordToSql
conversion
Inference rule interface for RecordToSql
proof object.
recordToSql :: RecordToSql q a Source
Infer RecordToSql
proof object.
ToSql q () | Inference rule of |
(PersistableType q, PersistableWidth a, ToSql q a) => ToSql q (Maybe a) | Inference rule of |
(ToSql q a, ToSql q b) => ToSql q (a, b) | Inference rule of |
putRecord :: ToSql q a => a -> ToSqlM q () Source
Run inferred RecordToSql
proof object.
Context to convert haskell record type a
into SQL type q
list.
putEmpty :: () -> ToSqlM q () Source
Run RecordToSql
empty printer.
fromRecord :: ToSql q a => a -> [q] Source
Run inferred RecordToSql
proof object.
Convert from haskell type a
into list of SQL type [q
].
wrapToSql :: (a -> ToSqlM q ()) -> RecordToSql q a Source
Finalize RecordToSql
record printer.
valueToSql :: PersistableValue q a => RecordToSql q a Source
Derived RecordToSql
from persistable value.
Make parameter list for updating with key
:: RecordToSql q ra | |
-> KeyConstraint Unique ra | Unique key table constraint proof object. |
-> ra | |
-> [q] |
Convert from Haskell type ra
into SQL value q
list expected by update form like
UPDATE table SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ? AND key1 = ? AND key2 = ? ...
using RecordToSql
proof object.
:: ToSql q ra | |
=> KeyConstraint Unique ra | Unique key table constraint proof object. |
-> ra | |
-> [q] |
Convert like updateValuesByUnique'
using inferred RecordToSql
proof object.
updateValuesByPrimary :: (HasKeyConstraint Primary ra, ToSql q ra) => ra -> [q] Source
Convert like updateValuesByUnique'
using inferred RecordToSql
and ColumnConstraint
proof objects.
untypedUpdateValuesIndex Source
Make untyped indexes to update column from key indexes and record width. Expected by update form like
UPDATE table SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ? AND key1 = ? AND key2 = ? ...
unsafeUpdateValuesWithIndexes :: RecordToSql q ra -> [Int] -> ra -> [q] Source
Unsafely specify key indexes to convert from Haskell type ra
into SQL value q
list expected by update form like
UPDATE table SET c0 = ?, c1 = ?, ..., cn = ? WHERE key0 = ? AND key1 = ? AND key2 = ? ...
using RecordToSql
proof object.