refactor: self relationship

* Add test for self relationship in view
This commit is contained in:
steve-chavez
2022-05-09 21:31:19 -05:00
committed by Steve Chavez
parent c60380b5fc
commit 2be63b36d6
7 changed files with 74 additions and 30 deletions
@@ -362,6 +362,21 @@ spec =
}
}]|] { matchHeaders = [matchContentTypeJson] }
it "embeds parent and then embeds children on a view" $
get "/job?select=id,parent_id(*),children:job!parent_id(id,parent_id)" `shouldRespondWith`
[json|[
{
"id": 1,
"parent_id": null,
"children": [ { "id": 2, "parent_id": 1 } ]
},
{
"id": 2,
"parent_id": { "id": 1, "parent_id": null },
"children": []
}
]|] { matchHeaders = [matchContentTypeJson] }
context "two self reference foreign keys" $ do
it "embeds parents" $
get "/organizations?select=id,name,referee(id,name),auditor(id,name)&id=eq.3" `shouldRespondWith`