Going green: prevent TypeError for empty tables/results

This is the intial step to fix https://github.com/CartoDB/carto-vl/issues/1049.
This commit is contained in:
Raul Ochoa 2018-10-23 15:50:42 +02:00
parent 3e261fb353
commit 26e4a05276

View File

@ -71,7 +71,7 @@ function _geometryType(ctx) {
const geometryColumn = AggregationMapConfig.getAggregationGeometryColumn();
const sqlQuery = _getSQL(ctx, sql => queryUtils.getQueryGeometryType(sql, geometryColumn));
return queryUtils.queryPromise(ctx.dbConnection, sqlQuery)
.then(res => ({ geometryType: res.rows[0].geom_type }));
.then(res => ({ geometryType: (res.rows[0] || {}).geom_type }));
}
return Promise.resolve();
}