fix: handle tables with no properties

This commit is contained in:
Stepan Kuzmin 2018-06-04 17:46:48 +03:00
parent 241dda3184
commit d6aee81b1b
2 changed files with 11 additions and 13 deletions

View File

@ -1,14 +1,7 @@
WITH bounds AS (SELECT {mercator_bounds} as mercator, {original_bounds} as original)
SELECT ST_AsMVT(tile, '{id}', {extent}, 'geom') FROM (
SELECT
ST_AsMVTGeom(
{geometry_column_mercator},
bounds.mercator,
{extent},
{buffer},
{clip_geom}
) AS geom,
{properties}
ST_AsMVTGeom({geometry_column_mercator}, bounds.mercator, {extent}, {buffer}, {clip_geom}) AS geom {properties}
FROM {id}, bounds
WHERE {geometry_column} && bounds.original {condition}
) AS tile WHERE geom IS NOT NULL

View File

@ -41,12 +41,17 @@ impl Source {
)
};
let columns: Vec<String> = self.properties
.keys()
.map(|column| format!("\"{0}\"", column))
.collect();
let properties = if self.properties.is_empty() {
"".to_string()
} else {
let properties = self.properties
.keys()
.map(|column| format!("\"{0}\"", column))
.collect::<Vec<String>>()
.join(",");
let properties = columns.join(",");
format!(", {0}", properties)
};
let query = format!(
include_str!("scripts/get_tile.sql"),