Adapt src for Postgis 3.0

This commit is contained in:
Raúl Marín 2020-04-02 13:13:38 +02:00
parent d6990134b6
commit ebf2c92f08
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,16 @@
-- In Postgis 3+, geomval is part of postgis_raster
-- Trying to workaround it by creating the type ourselves leads to other issues:
-- - If we create it under public, then if we try to create postgis_raster afterwards it will fail (ERROR: type "geomval" already exists).
-- - If we create it under cdb_observatory, then things work until we install postgis_raster. At that moment depending on how
-- the search_path is set (per call, function, user...) we start getting random errors since it's mixing public.geomval and
-- cdb_observatory.geomval (function cdb_observatory.obs_getdata(geomval[], json) does not exist)
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'geomval') THEN
RAISE EXCEPTION 'Missing `geomval` type. Use `CREATE EXTENSION postgis_raster` to enable it.';
END IF;
END$$;
-- Returns the table name with geoms for the given geometry_id -- Returns the table name with geoms for the given geometry_id
-- TODO probably needs to take in the column_id array to get the relevant -- TODO probably needs to take in the column_id array to get the relevant

View File

@ -516,8 +516,8 @@ BEGIN
WHEN numer_id IS NULL THEN WHEN numer_id IS NULL THEN
'''geomref'', ' || 'cdb_observatory.FIRST(' || geom_tablename || '''geomref'', ' || 'cdb_observatory.FIRST(' || geom_tablename ||
'.' || geom_geomref_colname || '), ' || '.' || geom_geomref_colname || '), ' ||
'''value'', ' || 'cdb_observatory.FIRST(' || geom_tablename || '''value'', ' || '(cdb_observatory.FIRST(' || geom_tablename ||
'.' || geom_colname || ')' '.' || geom_colname || '))::TEXT' -- Needed to force text output in Postgis 3+, later parsed automagically by ::Geometry. Otherwise we'd get geojson output
ELSE '' ELSE ''
END || ')', ', ') END || ')', ', ')
AS colspecs, AS colspecs,