Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use comment on view to generate TileJson #1507

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/pg/scripts/query_available_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ WITH
SELECT
pg_namespace.nspname AS schema_name,
relname AS table_name,
CAST(obj_description(relfilenode, 'pg_class') AS VARCHAR) AS description
pg_description.description AS description
FROM pg_class
JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid
LEFT JOIN pg_description ON pg_class.oid = pg_description.objoid
WHERE relkind = 'r' OR relkind = 'v'
)
SELECT schema,
Expand Down
7 changes: 4 additions & 3 deletions martin/tests/pg_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ postgres:
let response = assert_response(response).await;
let body = read_body(response).await;
let body: serde_json::Value = serde_json::from_slice(&body).unwrap();
assert_yaml_snapshot!(body, @r###"
assert_yaml_snapshot!(body, @r#"
---
fonts: {}
sprites: {}
Expand Down Expand Up @@ -111,8 +111,9 @@ postgres:
content_type: application/x-protobuf
description: public.points1.geom
points1_vw:
attribution: some attribution from SQL comment
content_type: application/x-protobuf
description: public.points1_vw.geom
description: description from SQL comment
points2:
content_type: application/x-protobuf
description: public.points2.geom
Expand All @@ -127,7 +128,7 @@ postgres:
table_source_multiple_geom.1:
content_type: application/x-protobuf
description: public.table_source_multiple_geom.geom2
"###);
"#);
}

#[actix_rt::test]
Expand Down
7 changes: 4 additions & 3 deletions martin/tests/pg_table_source_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn init() {
#[actix_rt::test]
async fn table_source() {
let mock = mock_sources(mock_pgcfg("connection_string: $DATABASE_URL")).await;
assert_yaml_snapshot!(mock.0.tiles.get_catalog(), @r###"
assert_yaml_snapshot!(mock.0.tiles.get_catalog(), @r#"
---
"-function.withweired---_-characters":
content_type: application/x-protobuf
Expand Down Expand Up @@ -72,7 +72,8 @@ async fn table_source() {
description: public.points1.geom
points1_vw:
content_type: application/x-protobuf
description: public.points1_vw.geom
description: description from SQL comment
attribution: some attribution from SQL comment
points2:
content_type: application/x-protobuf
description: public.points2.geom
Expand All @@ -87,7 +88,7 @@ async fn table_source() {
table_source_multiple_geom.1:
content_type: application/x-protobuf
description: public.table_source_multiple_geom.geom2
"###);
"#);

let source = table(&mock, "table_source");
assert_yaml_snapshot!(source, @r###"
Expand Down
3 changes: 2 additions & 1 deletion tests/expected/auto/catalog_auto.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
},
"points1_vw": {
"content_type": "application/x-protobuf",
"description": "public.points1_vw.geom"
"description": "description from SQL comment",
"attribution": "some attribution from SQL comment"
},
"points2": {
"content_type": "application/x-protobuf",
Expand Down
9 changes: 9 additions & 0 deletions tests/fixtures/tables/points1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,12 @@ values (1, '0101000020E6100000EC3A2806EDDA61401C2041E87DDA2740'),

CREATE INDEX ON points1 USING GIST (geom);
CLUSTER points1_geom_idx ON points1;

DO $do$ BEGIN
EXECUTE 'COMMENT ON VIEW points1_vw IS $tj$' || $$
{
"description": "description from SQL comment",
"attribution": "some attribution from SQL comment"
}
$$::json || '$tj$';
END $do$;
Loading