martin/tests/fixtures/functions/function_Mixed_Name.sql
Yuri Astrakhan f88db05582
Fix SQL comments when func or table is pre-configured (#1045)
When a SQL comment is set on a table or a function to customize
tilejson, and that tbl/func is pre-configured as part of the config
file, the comment was silently ignored. Now both table and function
cases are handled correctly.

Also, update docs to not include function parameters - makes SQL example
a bit simpler.

Thanks @jjcfrancisco for reporting!

Fixes: #1044
2023-12-07 07:24:51 +00:00

33 lines
1.1 KiB
PL/PgSQL

DROP FUNCTION IF EXISTS "MixedCase"."function_Mixed_Name";
CREATE OR REPLACE FUNCTION "MixedCase"."function_Mixed_Name"("Z" integer, x integer, y integer)
RETURNS TABLE("mVt" bytea, key text) AS $$
SELECT mvt, md5(mvt) as key FROM (
SELECT ST_AsMVT(tile, 'MixedCase.function_Mixed_Name', 4096, 'geom') as mvt FROM (
SELECT
ST_AsMVTGeom(
ST_Transform(ST_CurveToLine("Geom"), 3857),
ST_TileEnvelope("Z", x, y),
4096, 64, true) AS geom
FROM "MixedCase"."MixPoints"
WHERE "Geom" && ST_Transform(ST_TileEnvelope("Z", x, y), 4326)
) as tile WHERE geom IS NOT NULL) src
$$ LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE;
DO $do$ BEGIN
EXECUTE 'COMMENT ON FUNCTION "MixedCase"."function_Mixed_Name" IS $tj$' || $$
{
"description": "a function source with MixedCase name",
"vector_layers": [
{
"id": "MixedCase.function_Mixed_Name",
"fields": {
"TABLE": "",
"Geom": ""
}
}
]
}
$$::json || '$tj$';
END $do$;