diff --git a/src/pg/sql/42_observatory_exploration.sql b/src/pg/sql/42_observatory_exploration.sql index 338298e..9dfc866 100644 --- a/src/pg/sql/42_observatory_exploration.sql +++ b/src/pg/sql/42_observatory_exploration.sql @@ -89,14 +89,15 @@ DECLARE timespan_query TEXT DEFAULT ''; BEGIN - IF time_span != null THEN - timespan_query = format('AND timespan = %L', time_span); + IF timespan != NULL + THEN + timespan_query = format('AND timespan = %L', timespan); END IF; RETURN QUERY EXECUTE $string$ - select + SELECT column_id, obs_column.description, timespan, @@ -109,11 +110,11 @@ BEGIN observatory.OBS_column_table.column_id = observatory.obs_column.id AND observatory.OBS_column_table.table_id = observatory.obs_table.id AND - observatory.OBS_column.type='Geometry' + observatory.OBS_column.type = 'Geometry' AND $1 && bounds::box2d $string$ || timespan_query - USING geom + USING geom; RETURN; END $$ LANGUAGE plpgsql;