test: add test for duplicate entries in pg_description with same OID

This commit is contained in:
Taimoor Zaeem
2025-05-14 09:31:48 -05:00
committed by Steve Chavez
parent 8390df0fa5
commit 8b63ea82ec
3 changed files with 25 additions and 2 deletions
+2 -2
View File
@@ -42,10 +42,10 @@ pgErrorCodeMapping = do
it "works with SchemaCache error" $
get "/non_existent_table"
`shouldRespondWith`
[json| {"code":"PGRST205","details":null,"hint":"Perhaps you meant the table 'test.json_table'","message":"Could not find the table 'test.non_existent_table' in the schema cache"} |]
[json| {"code":"PGRST205","details":null,"hint":"Perhaps you meant the table 'test.collision_test_table'","message":"Could not find the table 'test.non_existent_table' in the schema cache"} |]
{ matchStatus = 404
, matchHeaders = [ "Proxy-Status" <:> "PostgREST; error=PGRST205"
, "Content-Length" <:> "172" ]
, "Content-Length" <:> "182" ]
}
it "works with Jwt error" $ do
+8
View File
@@ -1450,3 +1450,11 @@ spec =
{ matchStatus = 200
, matchHeaders = [matchContentTypeJson]
}
context "schema cache duplicate definitions when two entries in pg_description have the same OID" $
it "doesn't err with 300 Multiple Choices" $
request methodGet "/rpc/collision_test_func?id=1"
[] ""
`shouldRespondWith`
[json| 1 |]
{ matchStatus = 200 }
+15
View File
@@ -3800,3 +3800,18 @@ create table factory_buildings (
factory_id int references factories(id),
inspections jsonb
);
-- collision test as occured in https://github.com/PostgREST/postgrest/issues/4052
create table test.collision_test_table (id integer);
comment on table collision_test_table is 'foobarbaz';
create function test.collision_test_func(id integer)
returns int language sql as $$
select 1;
$$;
update pg_proc
set oid = 'test.collision_test_table'::regclass::oid
where oid = 'test.collision_test_func'::regproc::oid;
comment on function test.collision_test_func(id integer) is 'fizzbuzz';