IS/IS NOT null, true, false

This commit is contained in:
João Cristóvão
2015-03-15 13:37:45 -07:00
committed by Joe Nelson
parent 8ed599a769
commit f4e0c12cba
+10 -3
View File
@@ -139,13 +139,18 @@ update t cols vals = B.Stmt
empty True empty True
wherePred :: Net.QueryItem -> PStmt wherePred :: Net.QueryItem -> PStmt
wherePred (col, predicate) = B.Stmt wherePred (col, predicate) =
(" " <> cs (pgFmtIdent $ cs col) <> " " <> op <> " " <> cs sqlValue) B.Stmt (" " <> cs (pgFmtIdent $ cs col) <> " " <> op <> " " <>
empty True if opCode `elem` ["is","isnot"] then whiteList value
else cs sqlValue)
empty True
where where
opCode:rest = T.split (=='.') $ cs $ fromMaybe "." predicate opCode:rest = T.split (=='.') $ cs $ fromMaybe "." predicate
value = T.intercalate "." rest value = T.intercalate "." rest
whiteList val = fromMaybe (cs (pgFmtLit val) <> "::unknown ")
(L.find ((==) . T.toLower $ val)
["null","true","false"])
star c = if c == '*' then '%' else c star c = if c == '*' then '%' else c
unknownLiteral = (<> "::unknown ") . pgFmtLit unknownLiteral = (<> "::unknown ") . pgFmtLit
@@ -166,6 +171,8 @@ wherePred (col, predicate) = B.Stmt
"like"-> "like" "like"-> "like"
"ilike"-> "ilike" "ilike"-> "ilike"
"in" -> "in" "in" -> "in"
"is" -> "is"
"isnot" -> "is not"
_ -> "=" _ -> "="
orderParse :: Net.Query -> [OrderTerm] orderParse :: Net.Query -> [OrderTerm]