Adds spec for @@ operator and implements it in PgQuery

This commit is contained in:
Diogo Biazus
2015-05-22 12:28:26 -04:00
parent 4277284a69
commit a980db6d2d
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -175,6 +175,7 @@ wherePred (col, predicate) =
"like" -> unknownLiteral $ T.map star value
"ilike" -> unknownLiteral $ T.map star value
"in" -> "(" <> T.intercalate ", " (map unknownLiteral $ T.split (==',') value) <> ") "
"@@" -> "to_tsquery(" <> unknownLiteral value <> ") "
_ -> unknownLiteral value
op = case opCode of
@@ -189,6 +190,7 @@ wherePred (col, predicate) =
"in" -> "in"
"is" -> "is"
"isnot" -> "is not"
"@@" -> "@@"
_ -> "="
orderParse :: Net.Query -> [OrderTerm]
+4
View File
@@ -56,6 +56,10 @@ spec =
get "/simple_pk?k=ilike.*YY*&order=extra.asc" `shouldRespondWith`
"[{\"k\":\"xyyx\",\"extra\":\"u\"},{\"k\":\"xYYx\",\"extra\":\"v\"}]"
it "matches with tsearch @@" $
get "/tsearch?text_search_vector=@@.foo" `shouldRespondWith`
"[{\"text_search_vector\":\"'bar':2 'foo':1\"}]"
describe "ordering response" $ do
it "by a column asc" $
get "/items?id=lte.2&order=id.asc"