Use original query from source nodes

Doing a st_transform doesn't make sense as we already should have
the_geom_webmercator column available
This commit is contained in:
Raul Ochoa 2016-05-10 17:09:36 +02:00
parent b3b3abcdb8
commit 4570d17ce1

View File

@ -26,9 +26,12 @@ var layerQueryTemplate = dot.template([
'FROM ({{=it._query}}) _cdb_analysis_query'
].join('\n'));
function layerQuery(query, columnNames) {
var _columns = ['ST_Transform(the_geom, 3857) the_geom_webmercator'].concat(skipColumns(columnNames));
return layerQueryTemplate({ _query: query, _columns: _columns.join(', ') });
function layerQuery(node) {
if (node.type === 'source') {
return node.getQuery();
}
var _columns = ['ST_Transform(the_geom, 3857) the_geom_webmercator'].concat(skipColumns(node.getColumns()));
return layerQueryTemplate({ _query: node.getQuery(), _columns: _columns.join(', ') });
}
function appendFiltersToNodes(requestMapConfig, dataviewsFiltersBySourceId) {
@ -139,7 +142,7 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(analysisConfiguration
var layerSourceId = getLayerSourceId(layer);
var layerNode = sourceId2Node[layerSourceId];
if (layerNode) {
var analysisSql = layerQuery(layerNode.getQuery(), layerNode.getColumns());
var analysisSql = layerQuery(layerNode);
var sqlQueryWrap = layer.options.sql_wrap;
if (sqlQueryWrap) {
analysisSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, analysisSql);