Add test for #996 embed bug when table name = column name
This commit is contained in:
committed by
Steve Chávez
parent
8f49f731d0
commit
e1cab584a3
@@ -768,3 +768,13 @@ spec = do
|
||||
it "works with brackets" $
|
||||
get "/entities?id=eq.2&select=id,child_entities{id}" `shouldRespondWith`
|
||||
[json| [{"id": 2, "child_entities": [{"id": 3}]}] |] { matchHeaders = [matchContentTypeJson] }
|
||||
|
||||
context "Embedding when column name = table name" $ do
|
||||
it "works with child embeds" $
|
||||
get "/being?select=*,descendant(*)&limit=1" `shouldRespondWith`
|
||||
[json|[{"being":1,"descendant":[{"descendant":1,"being":1},{"descendant":2,"being":1},{"descendant":3,"being":1}]}]|]
|
||||
{ matchHeaders = [matchContentTypeJson] }
|
||||
it "works with many to many embeds" $
|
||||
get "/being?select=*,part(*)&limit=1" `shouldRespondWith`
|
||||
[json|[{"being":1,"part":[{"part":1}]}]|]
|
||||
{ matchHeaders = [matchContentTypeJson] }
|
||||
|
||||
Vendored
+11
@@ -323,6 +323,17 @@ INSERT INTO ranges VALUES (2, '[3,6]');
|
||||
INSERT INTO ranges VALUES (3, '[6,9]');
|
||||
INSERT INTO ranges VALUES (4, '[9,12]');
|
||||
|
||||
TRUNCATE TABLE being CASCADE;
|
||||
INSERT INTO being VALUES (1), (2), (3), (4);
|
||||
|
||||
TRUNCATE TABLE descendant CASCADE;
|
||||
INSERT INTO descendant VALUES (1,1), (2,1), (3,1), (4,2);
|
||||
|
||||
TRUNCATE TABLE part CASCADE;
|
||||
INSERT INTO part VALUES (1), (2), (3), (4);
|
||||
|
||||
TRUNCATE TABLE being_part CASCADE;
|
||||
INSERT INTO being_part VALUES (1,1), (2,1), (3,2), (4,3);
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
Vendored
+4
@@ -57,6 +57,10 @@ GRANT ALL ON TABLE
|
||||
, child_entities
|
||||
, grandchild_entities
|
||||
, ranges
|
||||
, being
|
||||
, descendant
|
||||
, being_part
|
||||
, part
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||
|
||||
Vendored
+18
@@ -1254,6 +1254,24 @@ $$ language sql;
|
||||
create function test.get_tsearch() returns setof test.tsearch AS $$
|
||||
SELECT * FROM test.tsearch;
|
||||
$$ language sql;
|
||||
|
||||
create table test.being (
|
||||
being int primary key not null
|
||||
);
|
||||
|
||||
create table test.descendant (
|
||||
descendant int primary key not null,
|
||||
being int references test.being(being)
|
||||
);
|
||||
|
||||
create table test.part (
|
||||
part int primary key not null
|
||||
);
|
||||
|
||||
create table test.being_part (
|
||||
being int not null references test.being(being),
|
||||
part int not null references test.part(part)
|
||||
);
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user