cast return value of obs_getboundaryid to text
This commit is contained in:
@@ -47,6 +47,7 @@ fixtures = [
|
|||||||
('us.census.spielman_singleton_segments.X10', 'us.census.tiger.census_tract', '2009 - 2013'),
|
('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', '2014-01'),
|
||||||
('us.zillow.AllHomes_Zhvi', 'us.census.tiger.zcta5', '2016-03'),
|
('us.zillow.AllHomes_Zhvi', 'us.census.tiger.zcta5', '2016-03'),
|
||||||
|
('whosonfirst.wof_country_geom', 'whosonfirst.wof_country_geom', '2016'),
|
||||||
]
|
]
|
||||||
|
|
||||||
unique_tables = set()
|
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:
|
for tablename, colname, boundary_id in unique_tables:
|
||||||
if 'zcta5' in boundary_id:
|
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:
|
else:
|
||||||
where = '36047%'
|
where = '\'36047%\''
|
||||||
print ' '.join([select_star(tablename), "WHERE {} LIKE '{}'".format(colname, where)])
|
compare = 'LIKE'
|
||||||
cdb.dump(' '.join([select_star(tablename), "WHERE {} LIKE '{}'".format(colname, where)]),
|
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')
|
tablename, outfile, schema='observatory')
|
||||||
dropfiles.write('DROP TABLE IF EXISTS observatory.{};\n'.format(tablename))
|
dropfiles.write('DROP TABLE IF EXISTS observatory.{};\n'.format(tablename))
|
||||||
|
|||||||
@@ -161,9 +161,9 @@ BEGIN
|
|||||||
|
|
||||||
RAISE NOTICE 'target_table: %, geoid_colname: %', target_table, geoid_colname;
|
RAISE NOTICE 'target_table: %, geoid_colname: %', target_table, geoid_colname;
|
||||||
|
|
||||||
-- return name of geometry id column
|
-- return geometry id column value
|
||||||
EXECUTE format(
|
EXECUTE format(
|
||||||
'SELECT %I
|
'SELECT %I::text
|
||||||
FROM observatory.%I
|
FROM observatory.%I
|
||||||
WHERE ST_Intersects($1, the_geom)
|
WHERE ST_Intersects($1, the_geom)
|
||||||
LIMIT 1', geoid_colname, target_table)
|
LIMIT 1', geoid_colname, target_table)
|
||||||
|
|||||||
Reference in New Issue
Block a user