cast return value of obs_getboundaryid to text

This commit is contained in:
Andy Eschbacher 2016-05-13 06:51:13 -04:00
parent 8696037dd6
commit 2c10e75af6
2 changed files with 12 additions and 6 deletions

View File

@ -47,6 +47,7 @@ fixtures = [
('us.census.spielman_singleton_segments.X10', 'us.census.tiger.census_tract', '2009 - 2013'),
('us.zillow.AllHomes_Zhvi', 'us.census.tiger.zcta5', '2014-01'),
('us.zillow.AllHomes_Zhvi', 'us.census.tiger.zcta5', '2016-03'),
('whosonfirst.wof_country_geom', 'whosonfirst.wof_country_geom', '2016'),
]
unique_tables = set()
@ -75,10 +76,15 @@ with open('src/pg/test/fixtures/load_fixtures.sql', 'w') as outfile:
for tablename, colname, boundary_id in unique_tables:
if 'zcta5' in boundary_id:
where = '11%'
where = '\'11%\''
compare = 'LIKE'
elif 'whosonfirst' in boundary_id:
where = '(\'85632785\',\'85633051\',\'85633111\',\'85633147\',\'85633253\',\'85633267\')'
compare = 'IN'
else:
where = '36047%'
print ' '.join([select_star(tablename), "WHERE {} LIKE '{}'".format(colname, where)])
cdb.dump(' '.join([select_star(tablename), "WHERE {} LIKE '{}'".format(colname, where)]),
where = '\'36047%\''
compare = 'LIKE'
print ' '.join([select_star(tablename), "WHERE {}::text {} {}".format(colname, compare, where)])
cdb.dump(' '.join([select_star(tablename), "WHERE {}::text {} {}".format(colname, compare, where)]),
tablename, outfile, schema='observatory')
dropfiles.write('DROP TABLE IF EXISTS observatory.{};\n'.format(tablename))

View File

@ -161,9 +161,9 @@ BEGIN
RAISE NOTICE 'target_table: %, geoid_colname: %', target_table, geoid_colname;
-- return name of geometry id column
-- return geometry id column value
EXECUTE format(
'SELECT %I
'SELECT %I::text
FROM observatory.%I
WHERE ST_Intersects($1, the_geom)
LIMIT 1', geoid_colname, target_table)