-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `helpText` to `layer.requires` like discussed in openmaptiles/openmaptiles#1220 I had to change from `SELECT 'osm_ocean_polygon'::regclass;` to `PERFORM 'osm_ocean_polygon'::regclass;` because plpgsql needs a return value if `SELECT` is used. Also added an error if a function has no arguments: ``` when invalid_text_representation then RAISE EXCEPTION '%! The arguments of the required function "osmFunc" of the layer "water" are missing. Example: "osmFunc(text)"', SQLERRM; ``` Example: ``` layer: id: "water" requires: helpText: 'This is a text with "quotes"' functions: "osmFunc" tables: "osm_ocean_polygon" ``` SQL: ``` -- Assert osm_ocean_polygon exists do $$ begin PERFORM 'osm_ocean_polygon'::regclass; exception when undefined_table then RAISE EXCEPTION '%! This is error text with "quotes"', SQLERRM; end; $$ language 'plpgsql'; -- Assert osmFunc exists do $$ begin PERFORM 'osmFunc'::regprocedure; exception when undefined_function then RAISE EXCEPTION '%! This is a text with "quotes"', SQLERRM; when invalid_text_representation then RAISE EXCEPTION '%! The arguments of the required function "osmFunc" of the layer "water" are missing. Example: "osmFunc(text)"', SQLERRM; end; $$ language 'plpgsql'; ``` Result of `make import-sql`: > psql:/sql/parallel/water__waterway.sql:10: ERROR: relation "osm_ocean_polygon2" does not exist! This is a text with "quotes" Co-authored-by: Yuri Astrakhan <[email protected]>
- Loading branch information
1 parent
0493b77
commit 208dd6a
Showing
7 changed files
with
124 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
DO $$ BEGIN RAISE NOTICE 'Processing layer mountain_peak'; END$$; | ||
|
||
-- Assert my_magic_table exists | ||
SELECT 'my_magic_table'::regclass; | ||
DO $$ BEGIN | ||
PERFORM 'my_magic_table'::regclass; | ||
EXCEPTION | ||
WHEN undefined_table THEN | ||
RAISE EXCEPTION '%', SQLERRM | ||
USING DETAIL = 'this table or view is required for layer "mountain_peak"'; | ||
END; | ||
$$ LANGUAGE 'plpgsql'; | ||
|
||
-- Assert my_magic_func(TEXT, TEXT) exists | ||
SELECT 'my_magic_func(TEXT, TEXT)'::regprocedure; | ||
DO $$ BEGIN | ||
PERFORM 'my_magic_func(TEXT, TEXT)'::regprocedure; | ||
EXCEPTION | ||
WHEN undefined_function THEN | ||
RAISE EXCEPTION '%', SQLERRM | ||
USING DETAIL = 'this function is required for layer "mountain_peak"'; | ||
WHEN invalid_text_representation THEN | ||
RAISE EXCEPTION '%', SQLERRM | ||
USING DETAIL = 'Required function "my_magic_func(TEXT, TEXT)" in layer "mountain_peak" is incorrectly declared. Use full function signature with parameter types, e.g. "my_magic_func(TEXT, TEXT)"'; | ||
END; | ||
$$ LANGUAGE 'plpgsql'; | ||
|
||
DO $$ BEGIN RAISE NOTICE 'Finished layer mountain_peak'; END$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
DO $$ BEGIN RAISE NOTICE 'Processing layer mountain_peak'; END$$; | ||
|
||
-- Assert my_magic_table exists | ||
SELECT 'my_magic_table'::regclass; | ||
DO $$ BEGIN | ||
PERFORM 'my_magic_table'::regclass; | ||
EXCEPTION | ||
WHEN undefined_table THEN | ||
RAISE EXCEPTION '%', SQLERRM | ||
USING DETAIL = 'this table or view is required for layer "mountain_peak"'; | ||
END; | ||
$$ LANGUAGE 'plpgsql'; | ||
|
||
-- Assert my_magic_func(TEXT, TEXT) exists | ||
SELECT 'my_magic_func(TEXT, TEXT)'::regprocedure; | ||
DO $$ BEGIN | ||
PERFORM 'my_magic_func(TEXT, TEXT)'::regprocedure; | ||
EXCEPTION | ||
WHEN undefined_function THEN | ||
RAISE EXCEPTION '%', SQLERRM | ||
USING DETAIL = 'this function is required for layer "mountain_peak"'; | ||
WHEN invalid_text_representation THEN | ||
RAISE EXCEPTION '%', SQLERRM | ||
USING DETAIL = 'Required function "my_magic_func(TEXT, TEXT)" in layer "mountain_peak" is incorrectly declared. Use full function signature with parameter types, e.g. "my_magic_func(TEXT, TEXT)"'; | ||
END; | ||
$$ LANGUAGE 'plpgsql'; | ||
|
||
DO $$ BEGIN RAISE NOTICE 'Finished layer mountain_peak'; END$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters