From 07396036e29507dc217a8b91350bc9498abbda3b Mon Sep 17 00:00:00 2001 From: David Bitner Date: Mon, 30 Oct 2023 13:53:02 -0500 Subject: [PATCH] fix for pg_temp function includes/excludes --- tests/routes/test_collections.py | 2 +- tipg/sql/dbcatalog.sql | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/routes/test_collections.py b/tests/routes/test_collections.py index 74c037e9..4d631c67 100644 --- a/tests/routes/test_collections.py +++ b/tests/routes/test_collections.py @@ -272,7 +272,7 @@ def test_collections_include_functions(app_includes_function): assert response.status_code == 200 body = response.json() ids = [x["id"] for x in body["collections"]] - assert ["pg_temp.hexagons", "pg_temp.squares"] == ids + assert ["pg_temp.hexagons"] == ids def test_collections_empty(app_empty): diff --git a/tipg/sql/dbcatalog.sql b/tipg/sql/dbcatalog.sql index bf230312..a0f7a814 100644 --- a/tipg/sql/dbcatalog.sql +++ b/tipg/sql/dbcatalog.sql @@ -246,8 +246,8 @@ CREATE OR REPLACE FUNCTION pg_temp.tipg_catalog( AND relkind IN ('r','v', 'm', 'f', 'p') AND has_table_privilege(c.oid, 'SELECT') AND c.relname::text NOT IN ('spatial_ref_sys','geometry_columns','geography_columns') - AND (exclude_tables IS NULL OR concat(c.relnamespace::regnamespace::text,'.',c.relname::text) <> ALL (exclude_tables)) - AND (tables IS NULL OR concat(c.relnamespace::regnamespace::text,'.',c.relname::text) = ANY (tables)) + AND (exclude_tables IS NULL OR concat(pg_temp.nspname(relnamespace),'.',c.relname::text) <> ALL (exclude_tables)) + AND (tables IS NULL OR concat(pg_temp.nspname(relnamespace),'.',c.relname::text) = ANY (tables)) UNION ALL @@ -263,8 +263,8 @@ CREATE OR REPLACE FUNCTION pg_temp.tipg_catalog( AND '' != ANY(proargnames) AND has_function_privilege(oid, 'execute') AND provariadic=0 - AND (exclude_functions IS NULL OR concat(p.pronamespace::regnamespace::text,'.',proname::text) <> ALL (exclude_functions)) - AND (functions IS NULL OR concat(p.pronamespace::regnamespace::text,'.',proname::text) = ANY (functions)) + AND (exclude_functions IS NULL OR concat(pg_temp.nspname(pronamespace),'.', proname::text) <> ALL (exclude_functions)) + AND (functions IS NULL OR concat(pg_temp.nspname(pronamespace),'.', proname::text) = ANY (functions)) AND p.proname::text NOT ILIKE 'tipg_%' ) SELECT meta FROM a