fix: aggregates not working for all schemas
Closes https://github.com/PostgREST/postgrest/issues/3124
This commit is contained in:
committed by
Steve Chavez
parent
0b77098460
commit
1680a6eed3
@@ -150,6 +150,20 @@ spec =
|
||||
matchStatus = 406
|
||||
}
|
||||
|
||||
it "succeeds in calling handler with a domain on another schema" $
|
||||
request methodGet "/another_table" [("Accept-Profile", "v2"), (hAccept, "text/plain")] ""
|
||||
`shouldRespondWith` "plain"
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "text/plain; charset=utf-8", "Content-Profile" <:> "v2"]
|
||||
}
|
||||
|
||||
it "succeeds in calling handler with a domain on an exposed schema" $
|
||||
request methodGet "/another_table" [("Accept-Profile", "v2"), (hAccept, "text/special")] ""
|
||||
`shouldRespondWith` "special"
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "text/special", "Content-Profile" <:> "v2"]
|
||||
}
|
||||
|
||||
context "calling procs on different schemas" $ do
|
||||
it "succeeds in calling the default schema proc" $
|
||||
request methodGet "/rpc/get_parents_below?id=6" [] ""
|
||||
@@ -194,6 +208,20 @@ spec =
|
||||
, matchHeaders = [matchContentTypeJson, "Content-Profile" <:> "v2"]
|
||||
}
|
||||
|
||||
it "succeeds in calling handler with a domain on another schema" $
|
||||
request methodGet "/rpc/get_plain_text" [("Accept-Profile", "v2"), (hAccept, "text/plain")] ""
|
||||
`shouldRespondWith` "plain"
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "text/plain; charset=utf-8", "Content-Profile" <:> "v2"]
|
||||
}
|
||||
|
||||
it "succeeds in calling handler with a domain on an exposed schema" $
|
||||
request methodGet "/rpc/get_special_text" [("Accept-Profile", "v2"), (hAccept, "text/special")] ""
|
||||
`shouldRespondWith` "special"
|
||||
{ matchStatus = 200
|
||||
, matchHeaders = ["Content-Type" <:> "text/special", "Content-Profile" <:> "v2"]
|
||||
}
|
||||
|
||||
context "Modifying tables on different schemas" $ do
|
||||
it "succeeds in patching on the v1 schema and returning its parent" $
|
||||
request methodPatch "/children?select=name,parent(name)&id=eq.1" [("Content-Profile", "v1"), ("Prefer", "return=representation")]
|
||||
|
||||
Vendored
+36
@@ -2169,6 +2169,42 @@ returns setof v2.parents as $$
|
||||
select * from v2.parents where id < $1;
|
||||
$$ language sql;
|
||||
|
||||
create function v2.get_plain_text()
|
||||
returns test."text/plain" as $$
|
||||
select 'plain'::test."text/plain";
|
||||
$$ language sql;
|
||||
|
||||
create domain v2."text/special" as text;
|
||||
|
||||
create function v2.get_special_text()
|
||||
returns v2."text/special" as $$
|
||||
select 'special'::v2."text/special";
|
||||
$$ language sql;
|
||||
|
||||
create or replace function v2.special_trans (state v2."text/special", next v2.another_table)
|
||||
returns v2."text/special" as $$
|
||||
select 'special'::v2."text/special";
|
||||
$$ language sql;
|
||||
|
||||
drop aggregate if exists v2.special_agg(v2.another_table);
|
||||
create aggregate v2.special_agg (v2.another_table) (
|
||||
initcond = ''
|
||||
, stype = v2."text/special"
|
||||
, sfunc = v2.special_trans
|
||||
);
|
||||
|
||||
create or replace function v2.plain_trans (state test."text/plain", next v2.another_table)
|
||||
returns test."text/plain" as $$
|
||||
select 'plain'::test."text/plain";
|
||||
$$ language sql;
|
||||
|
||||
drop aggregate if exists v2.plain_agg(v2.another_table);
|
||||
create aggregate v2.plain_agg (v2.another_table) (
|
||||
initcond = ''
|
||||
, stype = test."text/plain"
|
||||
, sfunc = v2.plain_trans
|
||||
);
|
||||
|
||||
create table private.screens (
|
||||
id serial primary key,
|
||||
name text not null default 'new screen'
|
||||
|
||||
Reference in New Issue
Block a user