From 98e8d745b11686e3d64fe5918b964fa9a5f02d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 13 Dec 2017 17:01:43 +0100 Subject: [PATCH] Support sql_wrap for aggregation --- .../adapter/aggregation-mapconfig-adapter.js | 5 ++-- test/acceptance/aggregation.js | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js index a663632f..a9a24c0e 100644 --- a/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/aggregation-mapconfig-adapter.js @@ -93,10 +93,11 @@ module.exports = class AggregationMapConfigAdapter { } if (shouldAdapt) { - const aggregation = new Aggregation(mapConfig, layer.options.sql, layer.options.aggregation); + const sql = layer.options.sql_raw ? layer.options.sql_raw : layer.options.sql; + const aggregation = new Aggregation(mapConfig, sql, layer.options.aggregation); const sqlQueryWrap = layer.options.sql_wrap; - let aggregationSql = aggregation.sql(layer.options); + let aggregationSql = aggregation.sql(); if (sqlQueryWrap) { layer.options.sql_raw = aggregationSql; diff --git a/test/acceptance/aggregation.js b/test/acceptance/aggregation.js index 04772f25..30f55888 100644 --- a/test/acceptance/aggregation.js +++ b/test/acceptance/aggregation.js @@ -482,6 +482,32 @@ describe('aggregation', function () { done(); }); }); + + it('when sql_wrap is provided should return a tile', function (done) { + this.mapConfig = createVectorMapConfig([ + { + type: 'cartodb', + options: { + sql_wrap: SQL_WRAP, + sql: POINTS_SQL_1, + aggregation: { + threshold: 1 + }, + cartocss: '#layer { marker-width: 1; }', + cartocss_version: '2.3.0' + } + } + ]); + this.testClient = new TestClient(this.mapConfig); + + this.testClient.getTile(0, 0, 0, {}, (err) => { + if (err) { + return done(err); + } + + done(); + }); + }); }); }); });