Close #1145, OpenAPI materialized view columns
This commit is contained in:
committed by
Steve Chávez
parent
105671e51a
commit
69a76a627f
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
- #1099, Add support for getting json/jsonb by array index - @steve-chavez
|
- #1099, Add support for getting json/jsonb by array index - @steve-chavez
|
||||||
|
- #1145, Add materialized view columns to OpenAPI output - @steve-chavez
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ allColumns tabs =
|
|||||||
pg_catalog.pg_namespace n
|
pg_catalog.pg_namespace n
|
||||||
WHERE
|
WHERE
|
||||||
r.contype IN ('f', 'p')
|
r.contype IN ('f', 'p')
|
||||||
AND c.relkind IN ('r', 'v', 'f', 'mv')
|
AND c.relkind IN ('r', 'v', 'f', 'm')
|
||||||
AND r.conrelid = c.oid
|
AND r.conrelid = c.oid
|
||||||
AND c.relnamespace = n.oid
|
AND c.relnamespace = n.oid
|
||||||
AND n.nspname NOT IN ('pg_catalog', 'information_schema', $1)
|
AND n.nspname NOT IN ('pg_catalog', 'information_schema', $1)
|
||||||
@@ -492,7 +492,7 @@ allColumns tabs =
|
|||||||
NOT pg_is_other_temp_schema(nc.oid)
|
NOT pg_is_other_temp_schema(nc.oid)
|
||||||
AND a.attnum > 0
|
AND a.attnum > 0
|
||||||
AND NOT a.attisdropped
|
AND NOT a.attisdropped
|
||||||
AND (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char"]))
|
AND (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char", 'm'::"char"]))
|
||||||
AND (nc.nspname = $1 OR kc.r_oid IS NOT NULL) /*--filter only columns that are FK/PK or in the api schema */
|
AND (nc.nspname = $1 OR kc.r_oid IS NOT NULL) /*--filter only columns that are FK/PK or in the api schema */
|
||||||
/*--AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_column_privilege(c.oid, a.attnum, 'SELECT, INSERT, UPDATE, REFERENCES'::text))*/
|
/*--AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_column_privilege(c.oid, a.attnum, 'SELECT, INSERT, UPDATE, REFERENCES'::text))*/
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -163,6 +163,38 @@ spec = do
|
|||||||
]
|
]
|
||||||
|]
|
|]
|
||||||
|
|
||||||
|
describe "Materialized view" $
|
||||||
|
|
||||||
|
it "includes materialized view properties" $ do
|
||||||
|
r <- simpleBody <$> get "/"
|
||||||
|
|
||||||
|
let method s = key "paths" . key "/materialized_projects" . key s
|
||||||
|
summary = r ^? method "get" . key "summary"
|
||||||
|
description = r ^? method "get" . key "description"
|
||||||
|
parameters = r ^? method "get" . key "parameters"
|
||||||
|
|
||||||
|
liftIO $ do
|
||||||
|
|
||||||
|
summary `shouldBe` Just "A materialized view for projects"
|
||||||
|
|
||||||
|
description `shouldBe` Just "Just a test for materialized views"
|
||||||
|
|
||||||
|
parameters `shouldBe` Just
|
||||||
|
[aesonQQ|
|
||||||
|
[
|
||||||
|
{ "$ref": "#/parameters/rowFilter.materialized_projects.id" },
|
||||||
|
{ "$ref": "#/parameters/rowFilter.materialized_projects.name" },
|
||||||
|
{ "$ref": "#/parameters/rowFilter.materialized_projects.client_id" },
|
||||||
|
{ "$ref": "#/parameters/select" },
|
||||||
|
{ "$ref": "#/parameters/order" },
|
||||||
|
{ "$ref": "#/parameters/range" },
|
||||||
|
{ "$ref": "#/parameters/rangeUnit" },
|
||||||
|
{ "$ref": "#/parameters/offset" },
|
||||||
|
{ "$ref": "#/parameters/limit" },
|
||||||
|
{ "$ref": "#/parameters/preferCount" }
|
||||||
|
]
|
||||||
|
|]
|
||||||
|
|
||||||
describe "RPC" $ do
|
describe "RPC" $ do
|
||||||
|
|
||||||
it "includes body schema for arguments" $ do
|
it "includes body schema for arguments" $ do
|
||||||
|
|||||||
Vendored
+1
@@ -86,6 +86,7 @@ GRANT ALL ON TABLE
|
|||||||
, authors_have_book_in_decade
|
, authors_have_book_in_decade
|
||||||
, foos
|
, foos
|
||||||
, bars
|
, bars
|
||||||
|
, materialized_projects
|
||||||
TO postgrest_test_anonymous;
|
TO postgrest_test_anonymous;
|
||||||
|
|
||||||
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||||
|
|||||||
Vendored
+8
@@ -1536,3 +1536,11 @@ CREATE TABLE test.bar(
|
|||||||
|
|
||||||
CREATE VIEW test.foos as select id,name from "Foo";
|
CREATE VIEW test.foos as select id,name from "Foo";
|
||||||
CREATE VIEW test.bars as select id, "fooId", name from bar;
|
CREATE VIEW test.bars as select id, "fooId", name from bar;
|
||||||
|
|
||||||
|
create materialized view materialized_projects as
|
||||||
|
select id, name, client_id from projects;
|
||||||
|
|
||||||
|
comment on materialized view materialized_projects is
|
||||||
|
$$A materialized view for projects
|
||||||
|
|
||||||
|
Just a test for materialized views$$;
|
||||||
|
|||||||
Reference in New Issue
Block a user