Allow filtering by values inside json columns

This commit is contained in:
Joe Nelson
2015-04-04 17:38:54 -07:00
parent ca1c524ede
commit 9792b9b46a
6 changed files with 72 additions and 372 deletions
+12 -1
View File
@@ -10,7 +10,11 @@ import SpecHelper
spec :: Spec
spec =
beforeAll (clearTable "items" >> createItems 15)
. beforeAll (clearTable "no_pk" >> createNulls 2 >> createLikableStrings)
. beforeAll (
clearTable "no_pk" >>
createNulls 2 >>
createLikableStrings >>
createJsonData)
. afterAll_ (clearTable "items" >> clearTable "no_pk" >> clearTable "simple_pk")
. around withApp $ do
describe "Querying a nonexistent table" $
@@ -116,3 +120,10 @@ spec =
let respHeaders = simpleHeaders r
respHeaders `shouldSatisfy` matchHeader
"Content-Location" "/simple_pk"
describe "jsonb" $
it "can filter by properties inside json column" $ do
get "/json?data->foo->>bar=eq.baz" `shouldRespondWith`
[json| [{"data": {"foo": {"bar": "baz"}}}] |]
get "/json?data->foo->>bar=eq.fake" `shouldRespondWith`
[json| [] |]