test: spread embed disambiguates recursive m2m
This commit is contained in:
committed by
Steve Chavez
parent
60c0c11c1d
commit
25f65065f4
@@ -109,6 +109,18 @@ spec =
|
||||
get "/whatev_sites?select=*,whatev_jobs!site_id_2(..whatev_projects!project_id_1(*))" `shouldRespondWith` [json|[]|]
|
||||
get "/whatev_sites?select=*,whatev_jobs!site_id_2(..whatev_projects!project_id_2(*))" `shouldRespondWith` [json|[]|]
|
||||
|
||||
it "can disambiguate a recursive m2m with spread embeds" $ do
|
||||
get "/posters?select=*,subscribers:subscriptions!subscribed(..posters!subscriber(*))&limit=1" `shouldRespondWith`
|
||||
[json| [ {"id":1,"name":"Mark","subscribers":[{"id":3,"name":"Bill"}, {"id":4,"name":"Jeff"}]}]|]
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
get "/posters?select=*,subscriptions!subscriber(..posters!subscribed(*))&limit=1" `shouldRespondWith`
|
||||
[json| [{"id":1,"name":"Mark","subscriptions":[{"id":2,"name":"Elon"}]}]|]
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
|
||||
it "errs on an ambiguous embed that has two one-to-one relationships" $
|
||||
get "/first?select=second(*)" `shouldRespondWith`
|
||||
[json| {
|
||||
|
||||
Vendored
+6
@@ -832,3 +832,9 @@ INSERT INTO trash(id) VALUES (1), (2), (3);
|
||||
|
||||
TRUNCATE TABLE trash_details CASCADE;
|
||||
INSERT INTO trash_details(id,jsonb_col) VALUES (1,'{"key": 10}'), (2,'{"key": 6}'), (3,'{"key": 8}');
|
||||
|
||||
TRUNCATE TABLE posters CASCADE;
|
||||
INSERT INTO posters(id,name) VALUES (1,'Mark'), (2,'Elon'), (3,'Bill'), (4,'Jeff');
|
||||
|
||||
TRUNCATE TABLE subscriptions CASCADE;
|
||||
INSERT INTO subscriptions(subscriber,subscribed) VALUES (3,1), (4,1), (1,2);
|
||||
|
||||
Vendored
+11
@@ -3026,3 +3026,14 @@ LANGUAGE sql
|
||||
AS $$
|
||||
select * from test.yards;
|
||||
$$;
|
||||
|
||||
create table test.posters(
|
||||
id int primary key,
|
||||
name text
|
||||
);
|
||||
|
||||
create table test.subscriptions(
|
||||
subscriber int references test.posters(id),
|
||||
subscribed int references test.posters(id),
|
||||
primary key(subscriber, subscribed)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user