WIP: converting app request handlers
This commit is contained in:
+10
-10
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user