fix: bad M2M embed on RPC
This commit is contained in:
committed by
Steve Chavez
parent
cca0b5ae66
commit
cb99270a8f
@@ -246,13 +246,17 @@ spec actualPgVersion =
|
||||
`shouldRespondWith`
|
||||
[json|{"id": 2, "articleStars": [{"userId": 3}]}|]
|
||||
|
||||
it "can embed an M2M relationship table" $
|
||||
it "can embed an M2M relationship table" $ do
|
||||
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] }
|
||||
-- https://github.com/PostgREST/postgrest/issues/2565
|
||||
get "/rpc/get_yards?select=groups(*)"
|
||||
`shouldRespondWith` [json|[]|]
|
||||
{ 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"
|
||||
|
||||
Vendored
+21
@@ -3005,3 +3005,24 @@ create table test.trash_details(
|
||||
id int primary key references test.trash(id),
|
||||
jsonb_col jsonb
|
||||
);
|
||||
|
||||
CREATE TABLE test.groups (
|
||||
name text PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE test.yards (
|
||||
id bigint PRIMARY KEY
|
||||
);
|
||||
|
||||
CREATE TABLE test.group_yard (
|
||||
id bigint NOT NULL,
|
||||
group_id text NOT NULL REFERENCES test.groups(name),
|
||||
yard_id bigint NOT NULL REFERENCES test.yards(id),
|
||||
PRIMARY KEY (id, group_id, yard_id)
|
||||
);
|
||||
|
||||
CREATE FUNCTION test.get_yards() RETURNS SETOF test.yards
|
||||
LANGUAGE sql
|
||||
AS $$
|
||||
select * from test.yards;
|
||||
$$;
|
||||
|
||||
Reference in New Issue
Block a user