Fix M2M resource embedding on RPC and mutations
This commit is contained in:
committed by
Steve Chávez
parent
d71d3450af
commit
75a42b77ea
@@ -644,3 +644,23 @@ spec actualPgVersion = do
|
||||
{ matchStatus = 200,
|
||||
matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
|
||||
it "embeds an M2M relationship plus parent after update" $
|
||||
request methodPatch "/users?id=eq.1&select=name,tasks(name,project:projects(name))"
|
||||
[("Prefer", "return=representation")]
|
||||
[json|{"name": "Kevin Malone"}|]
|
||||
`shouldRespondWith`
|
||||
[json|[
|
||||
{
|
||||
"name": "Kevin Malone",
|
||||
"tasks": [
|
||||
{ "name": "Design w7", "project": { "name": "Windows 7" } },
|
||||
{ "name": "Code w7", "project": { "name": "Windows 7" } },
|
||||
{ "name": "Design w10", "project": { "name": "Windows 10" } },
|
||||
{ "name": "Code w10", "project": { "name": "Windows 10" } }
|
||||
]
|
||||
}
|
||||
]|]
|
||||
{ matchStatus = 200,
|
||||
matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
|
||||
@@ -179,6 +179,29 @@ spec actualPgVersion =
|
||||
`shouldRespondWith` [json|[{"id": 2, "articleStars": [{"userId": 3}]}]|]
|
||||
{ matchHeaders = [matchContentTypeJson] }
|
||||
|
||||
it "can embed an M2M relationship table" $
|
||||
get "/rpc/getallusers?select=name,tasks(name)&id=gt.1"
|
||||
`shouldRespondWith` [json|[
|
||||
{"name":"Michael Scott", "tasks":[{"name":"Design IOS"}, {"name":"Code IOS"}, {"name":"Design OSX"}]},
|
||||
{"name":"Dwight Schrute","tasks":[{"name":"Design w7"}, {"name":"Design IOS"}]}
|
||||
]|]
|
||||
{ matchHeaders = [matchContentTypeJson] }
|
||||
|
||||
it "can embed an M2M relationship table that has a parent relationship table" $
|
||||
get "/rpc/getallusers?select=name,tasks(name,project:projects(name))&id=gt.1"
|
||||
`shouldRespondWith` [json|[
|
||||
{"name":"Michael Scott","tasks":[
|
||||
{"name":"Design IOS","project":{"name":"IOS"}},
|
||||
{"name":"Code IOS","project":{"name":"IOS"}},
|
||||
{"name":"Design OSX","project":{"name":"OSX"}}
|
||||
]},
|
||||
{"name":"Dwight Schrute","tasks":[
|
||||
{"name":"Design w7","project":{"name":"Windows 7"}},
|
||||
{"name":"Design IOS","project":{"name":"IOS"}}
|
||||
]}
|
||||
]|]
|
||||
{ matchHeaders = [matchContentTypeJson] }
|
||||
|
||||
context "a proc that returns an empty rowset" $
|
||||
it "returns empty json array" $ do
|
||||
post "/rpc/test_empty_rowset" [json| {} |] `shouldRespondWith`
|
||||
|
||||
Vendored
+4
@@ -1749,3 +1749,7 @@ CREATE TABLE web_content (
|
||||
p_web_id integer references web_content(id),
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
CREATE FUNCTION getallusers() RETURNS SETOF users AS $$
|
||||
SELECT * FROM test.users;
|
||||
$$ LANGUAGE sql;
|
||||
|
||||
Reference in New Issue
Block a user