Safe Haskell | None |
---|---|
Language | Haskell2010 |
- buildFields :: [FN] -> SqlBuilder
- updateTable :: (ToSqlBuilder q, ToMarkedRow flds) => FN -> flds -> q -> SqlBuilder
- insertInto :: ToMarkedRow b => FN -> b -> SqlBuilder
Low level generators
buildFields :: [FN] -> SqlBuilder Source #
Generates comma separated list of field names
>>>
runSqlBuilder con $ buildFields ["u" <> "name", "u" <> "phone", "e" <> "email"]
"\"u\".\"name\", \"u\".\"phone\", \"e\".\"email\""
:: (ToSqlBuilder q, ToMarkedRow flds) | |
=> FN | table name |
-> flds | fields to update |
-> q | condition |
-> SqlBuilder |
generates UPDATE query
>>>
let name = "%vip%"
>>>
runSqlBuilder con $ updateTable "ships" (MR [("size", mkValue 15)]) [sqlExp|WHERE size > 15 AND name NOT LIKE #{name}|]
"UPDATE \"ships\" SET \"size\" = 15 WHERE size > 15 AND name NOT LIKE '%vip%'"
:: ToMarkedRow b | |
=> FN | table name |
-> b | list of pairs (name, value) to insert into |
-> SqlBuilder |
Generate INSERT INTO query for entity
>>>
runSqlBuilder con $ insertInto "foo" $ MR [("name", mkValue "vovka"), ("hobby", mkValue "president")]
"INSERT INTO \"foo\" (\"name\", \"hobby\") VALUES ('vovka', 'president')"