Adds spec for @@ operator and implements it in PgQuery
This commit is contained in:
@@ -175,6 +175,7 @@ wherePred (col, predicate) =
|
|||||||
"like" -> unknownLiteral $ T.map star value
|
"like" -> unknownLiteral $ T.map star value
|
||||||
"ilike" -> unknownLiteral $ T.map star value
|
"ilike" -> unknownLiteral $ T.map star value
|
||||||
"in" -> "(" <> T.intercalate ", " (map unknownLiteral $ T.split (==',') value) <> ") "
|
"in" -> "(" <> T.intercalate ", " (map unknownLiteral $ T.split (==',') value) <> ") "
|
||||||
|
"@@" -> "to_tsquery(" <> unknownLiteral value <> ") "
|
||||||
_ -> unknownLiteral value
|
_ -> unknownLiteral value
|
||||||
|
|
||||||
op = case opCode of
|
op = case opCode of
|
||||||
@@ -189,6 +190,7 @@ wherePred (col, predicate) =
|
|||||||
"in" -> "in"
|
"in" -> "in"
|
||||||
"is" -> "is"
|
"is" -> "is"
|
||||||
"isnot" -> "is not"
|
"isnot" -> "is not"
|
||||||
|
"@@" -> "@@"
|
||||||
_ -> "="
|
_ -> "="
|
||||||
|
|
||||||
orderParse :: Net.Query -> [OrderTerm]
|
orderParse :: Net.Query -> [OrderTerm]
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ spec =
|
|||||||
get "/simple_pk?k=ilike.*YY*&order=extra.asc" `shouldRespondWith`
|
get "/simple_pk?k=ilike.*YY*&order=extra.asc" `shouldRespondWith`
|
||||||
"[{\"k\":\"xyyx\",\"extra\":\"u\"},{\"k\":\"xYYx\",\"extra\":\"v\"}]"
|
"[{\"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
|
describe "ordering response" $ do
|
||||||
it "by a column asc" $
|
it "by a column asc" $
|
||||||
get "/items?id=lte.2&order=id.asc"
|
get "/items?id=lte.2&order=id.asc"
|
||||||
|
|||||||
Reference in New Issue
Block a user