Check if query retrieves results

This commit is contained in:
Daniel García Aubert 2017-12-12 12:53:29 +01:00
parent 869f2ac322
commit 0b27d174ef

View File

@ -172,7 +172,8 @@ module.exports = class AggregationMapConfigAdapter {
return callback(null, shouldAdapt);
}
const estimatedFeatureCount = res.rows[0].count;
const result = res.rows[0] || {};
const estimatedFeatureCount = result.count;
const threshold = layer.options.aggregation && layer.options.aggregation.threshold ?
layer.options.aggregation.threshold :
@ -182,7 +183,7 @@ module.exports = class AggregationMapConfigAdapter {
return callback(null, shouldAdapt);
}
const geometryType = res.rows[0].type;
const geometryType = result.type;
if (geometryType !== 'ST_Point') {
return callback(new Error(unsupportedGeometryTypeErrorMessage({ geometryType })));