diff --git a/lib/cartodb/models/dataview/aggregation.js b/lib/cartodb/models/dataview/aggregation.js index 29eebe06..f621e536 100644 --- a/lib/cartodb/models/dataview/aggregation.js +++ b/lib/cartodb/models/dataview/aggregation.js @@ -205,7 +205,7 @@ module.exports = class Aggregation extends BaseDataview { this._isFloatColumn = null; } - _checkOptions () { + _checkOptions (options) { if (typeof options.column !== 'string') { throw new Error(`Aggregation expects 'column' in dataview options`); } @@ -294,7 +294,8 @@ module.exports = class Aggregation extends BaseDataview { const self = this; const escapedUserQuery = psql.escapeLiteral(`%${userQuery}%`); const value = this.aggregation !== 'count' && this.aggregationColumn ? - this.aggregation + '(' + this.aggregationColumn + ')' : 'count(1)'; + `${this.aggregation}(${this.aggregationColumn})` : + 'count(1)'; // TODO unfiltered will be wrong as filters are already applied at this point const query = searchQueryTpl({