Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion martin/src/config/file/postgres/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ fn warn_on_rename(old_id: &String, new_id: &String, typ: &str) {

fn summary(info: &TableInfo) -> String {
let relkind = match info.is_view {
Some(true) => "view",
Some('v') => "view",
Some('m') => "materialized view",
_ => "table",
};
// TODO: add column_id to the summary if it is set
Expand Down
4 changes: 2 additions & 2 deletions martin/src/config/file/postgres/config_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ pub struct TableInfo {
#[serde(skip)]
pub geometry_index: Option<bool>,

/// Flag indicating if table is actually a view (`PostgreSQL relkind = 'v'`)
/// Flag indicating if table is actually a view (`PostgreSQL relkind = 'v'`) or a Materialized View (`relkind = 'm'`)
#[serde(skip)]
pub is_view: Option<bool>,
pub is_view: Option<char>,

/// Feature id column name
pub id_column: Option<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ descriptions AS (
FROM pg_class AS cls
INNER JOIN pg_namespace ON cls.relnamespace = pg_namespace.oid
LEFT JOIN pg_description ON cls.oid = pg_description.objoid AND pg_description.objsubid = 0
WHERE cls.relkind = 'r' OR cls.relkind = 'v'
WHERE cls.relkind IN ('r', 'v', 'm')
)

SELECT
Expand Down
18 changes: 18 additions & 0 deletions tests/fixtures/tables/materialized_view.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE fixtures_comments (
id serial PRIMARY KEY,
txt text,
geom GEOMETRY (POINT, 4326)
);

INSERT INTO fixtures_comments (txt, geom) VALUES
('a', ST_GEOMFROMTEXT('POINT(-122.4194 37.7749)', 4326)),
('b', ST_GEOMFROMTEXT('POINT(-73.935242 40.730610)', 4326));

CREATE MATERIALIZED VIEW fixtures_mv_comments AS
SELECT
id,
txt,
geom
FROM fixtures_comments;

COMMENT ON MATERIALIZED VIEW fixtures_mv_comments IS 'fixture: materialized view comments';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make this into a proper json comment, just like other SQL, rather than ignoring this warning below

4 changes: 4 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ test_pbf antimeridian_4_0_5 antimeridian/4/0/5
test_jsn tbl_comment MixPoints
test_jsn fnc_comment function_Mixed_Name

>&2 echo "***** Test server response for materialized view *****"
test_jsn mv_comment fixtures_mv_comments
test_pbf mv_comment_0_0_0 fixtures_mv_comments/0/0/0

>&2 echo "***** Test server response for the same name in different schemas *****"
test_jsn same_name_different_schema_table1 table_name_existing_two_schemas
test_pbf same_name_different_schema_table1_0_0_0 table_name_existing_two_schemas/0/0/0
Expand Down
Loading