fixes geom_ref in where condition

This commit is contained in:
Andy Eschbacher
2016-05-24 11:22:39 -04:00
parent 3f77a384c7
commit 2e312464aa

View File

@@ -393,6 +393,7 @@ DECLARE
colname TEXT;
measure_val NUMERIC;
data_geoid_colname TEXT;
test_query TEXT;
BEGIN
-- TODO look at how timespans are decided in other functions
SELECT x ->> 'colname', x ->> 'tablename' INTO colname, target_table
@@ -410,13 +411,18 @@ BEGIN
, target_table)
INTO data_geoid_colname;
EXECUTE format(
RAISE NOTICE 'target_table %, colname %', target_table, colname;
test_query := format(
'SELECT %I
FROM observatory.%I
WHERE %I.%I = %L',
colname,
target_table,
target_table, data_geoid_colname, measure_id)
target_table, data_geoid_colname, geom_ref);
RAISE NOTICE 'test_query: %', test_query;
EXECUTE test_query
INTO measure_val;
RETURN measure_val;