From e9aaf05335140cab756fc4db9c4a905db4590a3a Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Wed, 18 Apr 2018 14:03:39 -0500 Subject: [PATCH] Remove support for non url safe operators --- CHANGELOG.md | 1 + src/PostgREST/Types.hs | 6 +----- test/Feature/AndOrParamsSpec.hs | 23 ++++------------------- test/Feature/QuerySpec.hs | 29 ++--------------------------- test/Feature/RpcSpec.hs | 7 ------- 5 files changed, 8 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bb4dddf8..665780e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - #1098, Removed support for: + curly braces `{}` in embeds, i.e. `/clients?select=*,projects{*}` can no longer be used, from now on parens `()` should be used `/clients?select=*,projects(*)` - @steve-chavez + "in" operator without parens, i.e. `/clients?id=in.1,2,3` no longer supported, `/clients?id=in.(1,2,3)` should be used - @steve-chavez + + "@@", "@>" and "<@" operators, from now on their mnemonic equivalents should be used "fts", "cs" and "cd" respectively - @steve-chavez ## [0.4.4.0] - 2018-01-08 diff --git a/src/PostgREST/Types.hs b/src/PostgREST/Types.hs index 5dd3c6587..9ace5a020 100644 --- a/src/PostgREST/Types.hs +++ b/src/PostgREST/Types.hs @@ -202,14 +202,10 @@ operators = M.union (M.fromList [ ("sr", ">>"), ("nxr", "&<"), ("nxl", "&>"), - ("adj", "-|-"), - -- TODO: these are deprecated and should be removed in v0.5.0.0 - ("@>", "@>"), - ("<@", "<@")]) ftsOperators + ("adj", "-|-")]) ftsOperators ftsOperators :: M.HashMap Operator SqlFragment ftsOperators = M.fromList [ - ("@@", "@@ to_tsquery"), -- TODO: '@@' deprecated ("fts", "@@ to_tsquery"), ("plfts", "@@ plainto_tsquery"), ("phfts", "@@ phraseto_tsquery") diff --git a/test/Feature/AndOrParamsSpec.hs b/test/Feature/AndOrParamsSpec.hs index 681004a1c..b37ae8e8d 100644 --- a/test/Feature/AndOrParamsSpec.hs +++ b/test/Feature/AndOrParamsSpec.hs @@ -79,15 +79,9 @@ spec = {"text_search_vector": "'amus':5 'fair':7 'impossibl':9 'peu':4" }, {"text_search_vector": "'art':4 'spass':5 'unmog':7"} ]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/entities?or=(text_search_vector.@@.bar,text_search_vector.@@.baz)&select=id" `shouldRespondWith` - [json|[{ "id": 1 }, { "id": 2 }]|] { matchHeaders = [matchContentTypeJson] } - it "can handle cs and cd" $ do + it "can handle cs and cd" $ get "/entities?or=(arr.cs.{1,2,3},arr.cd.{1})&select=id" `shouldRespondWith` [json|[{ "id": 1 },{ "id": 3 }]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/entities?or=(arr.@>.{1,2,3},arr.<@.{1})&select=id" `shouldRespondWith` - [json|[{ "id": 1 },{ "id": 3 }]|] { matchHeaders = [matchContentTypeJson] } it "can handle range operators" $ do get "/ranges?range=eq.[1,3]&select=id" `shouldRespondWith` @@ -120,24 +114,15 @@ spec = [json|[{ "id": 1 }]|] { matchHeaders = [matchContentTypeJson] } context "operators with not" $ do - it "eq, cs, like can be negated" $ do + it "eq, cs, like can be negated" $ get "/entities?and=(arr.not.cs.{1,2,3},and(id.not.eq.2,name.not.like.*3))&select=id" `shouldRespondWith` [json|[{ "id": 1}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/entities?and=(arr.not.@>.{1,2,3},and(id.not.eq.2,name.not.like.*3))&select=id" `shouldRespondWith` - [json|[{ "id": 1}]|] { matchHeaders = [matchContentTypeJson] } - it "in, is, fts can be negated" $ do + it "in, is, fts can be negated" $ get "/entities?and=(id.not.in.(1,3),and(name.not.is.null,text_search_vector.not.fts.foo))&select=id" `shouldRespondWith` [json|[{ "id": 2}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/entities?and=(id.not.in.(1,3),and(name.not.is.null,text_search_vector.not.@@.foo))&select=id" `shouldRespondWith` - [json|[{ "id": 2}]|] { matchHeaders = [matchContentTypeJson] } - it "lt, gte, cd can be negated" $ do + it "lt, gte, cd can be negated" $ get "/entities?and=(arr.not.cd.{1},or(id.not.lt.1,id.not.gte.3))&select=id" `shouldRespondWith` [json|[{"id": 2}, {"id": 3}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/entities?and=(arr.not.<@.{1},or(id.not.lt.1,id.not.gte.3))&select=id" `shouldRespondWith` - [json|[{"id": 2}, {"id": 3}]|] { matchHeaders = [matchContentTypeJson] } it "gt, lte, ilike can be negated" $ get "/entities?and=(name.not.ilike.*ITY2,or(id.not.gt.4,id.not.lte.1))&select=id" `shouldRespondWith` [json|[{"id": 1}, {"id": 2}, {"id": 3}]|] { matchHeaders = [matchContentTypeJson] } diff --git a/test/Feature/QuerySpec.hs b/test/Feature/QuerySpec.hs index caefb77c2..2eb8833ea 100644 --- a/test/Feature/QuerySpec.hs +++ b/test/Feature/QuerySpec.hs @@ -145,22 +145,6 @@ spec = do {"text_search_vector": "'art':4 'spass':5 'unmog':7"}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - it "Deprecated @@ operator, pending to remove" $ do - get "/tsearch?text_search_vector=@@.impossible" `shouldRespondWith` - [json| [{"text_search_vector": "'fun':5 'imposs':9 'kind':3" }] |] - { matchHeaders = [matchContentTypeJson] } - get "/tsearch?text_search_vector=not.@@.impossible%7Cfat%7Cfun" `shouldRespondWith` - [json| [ - {"text_search_vector": "'amus':5 'fair':7 'impossibl':9 'peu':4"}, - {"text_search_vector": "'art':4 'spass':5 'unmog':7"}]|] - { matchHeaders = [matchContentTypeJson] } - get "/tsearch?text_search_vector=not.@@(english).impossible%7Cfat%7Cfun" `shouldRespondWith` - [json| [ - {"text_search_vector": "'amus':5 'fair':7 'impossibl':9 'peu':4"}, - {"text_search_vector": "'art':4 'spass':5 'unmog':7"}]|] - { matchHeaders = [matchContentTypeJson] } - it "matches with computed column" $ get "/items?always_true=eq.true&order=id.asc" `shouldRespondWith` [json| [{"id":1},{"id":2},{"id":3},{"id":4},{"id":5},{"id":6},{"id":7},{"id":8},{"id":9},{"id":10},{"id":11},{"id":12},{"id":13},{"id":14},{"id":15}] |] @@ -186,24 +170,15 @@ spec = do [json|[{"id":1,"projects":[{"id":1,"tasks":[{"id":1,"name":"Design w7"}]},{"id":2,"tasks":[{"id":3,"name":"Design w10"}]}]},{"id":2,"projects":[{"id":3,"tasks":[{"id":5,"name":"Design IOS"}]},{"id":4,"tasks":[{"id":7,"name":"Design OSX"}]}]}]|] { matchHeaders = [matchContentTypeJson] } - it "matches with cs operator" $ do + it "matches with cs operator" $ get "/complex_items?select=id&arr_data=cs.{2}" `shouldRespondWith` [json|[{"id":2},{"id":3}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/complex_items?select=id&arr_data=@>.{2}" `shouldRespondWith` - [json|[{"id":2},{"id":3}]|] - { matchHeaders = [matchContentTypeJson] } - it "matches with cd operator" $ do + it "matches with cd operator" $ get "/complex_items?select=id&arr_data=cd.{1,2,4}" `shouldRespondWith` [json|[{"id":1},{"id":2}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: remove in 0.5.0 as deprecated - get "/complex_items?select=id&arr_data=<@.{1,2,4}" `shouldRespondWith` - [json|[{"id":1},{"id":2}]|] - { matchHeaders = [matchContentTypeJson] } - describe "Shaping response with select parameter" $ do diff --git a/test/Feature/RpcSpec.hs b/test/Feature/RpcSpec.hs index 4bfbdbbac..d808115ee 100644 --- a/test/Feature/RpcSpec.hs +++ b/test/Feature/RpcSpec.hs @@ -361,10 +361,3 @@ spec = get "/rpc/get_tsearch?text_search_vector=not.fts(english).fun%7Crat" `shouldRespondWith` [json|[{"text_search_vector":"'amus':5 'fair':7 'impossibl':9 'peu':4"},{"text_search_vector":"'art':4 'spass':5 'unmog':7"}]|] { matchHeaders = [matchContentTypeJson] } - -- TODO: '@@' deprecated - get "/rpc/get_tsearch?text_search_vector=@@(english).impossible" `shouldRespondWith` - [json|[{"text_search_vector":"'fun':5 'imposs':9 'kind':3"}]|] - { matchHeaders = [matchContentTypeJson] } - get "/rpc/get_tsearch?text_search_vector=not.@@(english).fun%7Crat" `shouldRespondWith` - [json|[{"text_search_vector":"'amus':5 'fair':7 'impossibl':9 'peu':4"},{"text_search_vector":"'art':4 'spass':5 'unmog':7"}]|] - { matchHeaders = [matchContentTypeJson] }