WIP: converting app request handlers

This commit is contained in:
Joe Nelson
2014-12-06 17:42:17 -08:00
parent 9b7af0296e
commit cb80dba234
6 changed files with 322 additions and 260 deletions
+10 -10
View File
@@ -1,13 +1,4 @@
module PgQuery (
CompleteQuery
, QualifiedTable(..)
, limitT
, whereT
, orderT
, countRows
, asJsonWithCount
, orderParse
) where
module PgQuery where
import RangeQuery
import Database.PostgreSQL.Simple
@@ -64,6 +55,10 @@ orderT ts q =
[EscapeIdentifier (otTerm t), Plain (fromByteString $ otDirection t)]
)
parentheticT :: CompleteQueryT
parentheticT (sql, params) =
(" (" <> sql <> ") ", params)
countRows :: QualifiedTable -> CompleteQuery
countRows t =
("select count(1) from ?.?",
@@ -75,6 +70,11 @@ asJsonWithCount (sql, params) = (
, params
)
selectStar :: QualifiedTable -> CompleteQuery
selectStar t =
("select count(1) from ?.?",
[EscapeIdentifier (qtSchema t), EscapeIdentifier (qtName t)])
wherePred :: Net.QueryItem -> CompleteQuery
wherePred (col, predicate) =
(" ? ? ? ", [EscapeIdentifier col, Plain op, toField value])