fix: Fix regression in openapi output with mode follow-privileges

This was introduced in d5b92a433a. Before
this change, the OpenApi output would have <pk/> annotations for views,
too. After this change, they got lost for mode follow-privileges, because
the pks are refined in haskell code, but the request only fetches all
the tables again, but not the view dependencies.

This fix changes follow-privileges to only fetch a list of accessible
tables, which is then used to filter the tables in the schema cache.

Fixes #2356

Signed-off-by: Wolfgang Walther <walther@technowledgy.de>
This commit is contained in:
Wolfgang Walther
2022-10-26 21:29:58 +02:00
parent 6fe1617348
commit 3bee6b1e27
6 changed files with 81 additions and 20 deletions
+33 -1
View File
@@ -157,6 +157,38 @@ spec actualPgVersion = describe "OpenAPI" $ do
}
|]
it "includes definitions to views" $ do
r <- simpleBody <$> get "/"
let def = r ^? key "definitions" . key "child_entities_view"
liftIO $
def `shouldBe` Just
[aesonQQ|
{
"type": "object",
"description": "child_entities_view comment",
"properties": {
"id": {
"description": "child_entities_view id comment\n\nNote:\nThis is a Primary Key.<pk/>",
"format": "integer",
"type": "integer"
},
"name": {
"description": "child_entities_view name comment. Can be longer than sixty-three characters long",
"format": "text",
"type": "string"
},
"parent_id": {
"description": "Note:\nThis is a Foreign Key to `entities.id`.<fk table='entities' column='id'/>",
"format": "integer",
"type": "integer"
}
}
}
|]
it "doesn't include privileged table for anonymous" $ do
r <- simpleBody <$> get "/"
let tablePath = r ^? key "paths" . key "/authors_only"
@@ -523,7 +555,7 @@ spec actualPgVersion = describe "OpenAPI" $ do
types `shouldBe` Just [aesonQQ|
{
"format": "enum_menagerie_type",
"format": "test.enum_menagerie_type",
"type": "string",
"enum": [
"foo",
+6
View File
@@ -1153,6 +1153,8 @@ create table child_entities (
parent_id integer references entities(id)
);
create view child_entities_view as table child_entities;
create table grandchild_entities (
id integer primary key,
name text,
@@ -1176,6 +1178,10 @@ comment on table child_entities is 'child_entities comment';
comment on column child_entities.id is 'child_entities id comment';
comment on column child_entities.name is 'child_entities name comment. Can be longer than sixty-three characters long';
comment on view child_entities_view is 'child_entities_view comment';
comment on column child_entities_view.id is 'child_entities_view id comment';
comment on column child_entities_view.name is 'child_entities_view name comment. Can be longer than sixty-three characters long';
comment on table grandchild_entities is
$$grandchild_entities summary