Skip to content

Commit

Permalink
Add test for function with special character (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark authored Mar 9, 2024
1 parent 12d115b commit 656728c
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions martin/tests/pg_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ postgres:
fonts: {}
sprites: {}
tiles:
"-function.withweired---_-characters":
content_type: application/x-protobuf
description: a function source with special characters
".-Points---quote":
content_type: application/x-protobuf
description: Escaping test table
Expand Down
3 changes: 3 additions & 0 deletions martin/tests/pg_table_source_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ async fn table_source() {
let mock = mock_sources(mock_pgcfg("connection_string: $DATABASE_URL")).await;
assert_yaml_snapshot!(mock.0.tiles.get_catalog(), @r###"
---
"-function.withweired---_-characters":
content_type: application/x-protobuf
description: a function source with special characters
".-Points---quote":
content_type: application/x-protobuf
description: Escaping test table
Expand Down
4 changes: 4 additions & 0 deletions tests/expected/auto/catalog_auto.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"tiles": {
"-function.withweired---_-characters": {
"content_type": "application/x-protobuf",
"description": "a function source with special characters"
},
".-Points---quote": {
"content_type": "application/x-protobuf",
"description": "Escaping test table"
Expand Down
3 changes: 3 additions & 0 deletions tests/expected/auto/save_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ postgres:
properties:
gid: int4
functions:
-function.withweired---_-characters:
schema: public
function: '"function.withweired$*;_ characters'
function_Mixed_Name:
schema: MixedCase
function: function_Mixed_Name
Expand Down
3 changes: 3 additions & 0 deletions tests/expected/martin-cp/flat-with-hash_save_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ postgres:
properties:
gid: int4
functions:
-function.withweired---_-characters:
schema: public
function: '"function.withweired$*;_ characters'
function_Mixed_Name:
schema: MixedCase
function: function_Mixed_Name
Expand Down
3 changes: 3 additions & 0 deletions tests/expected/martin-cp/flat_save_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ postgres:
properties:
gid: int4
functions:
-function.withweired---_-characters:
schema: public
function: '"function.withweired$*;_ characters'
function_Mixed_Name:
schema: MixedCase
function: function_Mixed_Name
Expand Down
3 changes: 3 additions & 0 deletions tests/expected/martin-cp/normalized_save_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ postgres:
properties:
gid: int4
functions:
-function.withweired---_-characters:
schema: public
function: '"function.withweired$*;_ characters'
function_Mixed_Name:
schema: MixedCase
function: function_Mixed_Name
Expand Down
32 changes: 32 additions & 0 deletions tests/fixtures/functions/function_special_characters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
DROP FUNCTION IF EXISTS "public"."""function.withweired$*;_ characters";

CREATE OR REPLACE FUNCTION "public"."""function.withweired$*;_ characters"("Z" integer, x integer, y integer)
RETURNS TABLE("mVt" bytea, key text) AS $$
SELECT mvt, md5(mvt) as key FROM (
SELECT ST_AsMVT(tile, 'public."function.withweired$*;_ characters', 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 "public"."""function.withweired$*;_ characters" IS $tj$' || $$
{
"description": "a function source with special characters",
"vector_layers": [
{
"id": "public.\"function.withweired$*;_ characters",
"fields": {
"TABLE": "",
"Geom": ""
}
}
]
}
$$::json || '$tj$';
END $do$;

0 comments on commit 656728c

Please sign in to comment.