Support sql_wrap for aggregation

This commit is contained in:
Daniel García Aubert 2017-12-13 17:01:43 +01:00
parent e8740af6ef
commit 98e8d745b1
2 changed files with 29 additions and 2 deletions

View File

@ -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;

View File

@ -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();
});
});
});
});
});