Merge pull request #1048 from CartoDB/fix-uncaught-error
Prevent from uncaught exception
This commit is contained in:
commit
2ebb1728ee
3
NEWS.md
3
NEWS.md
@ -12,6 +12,9 @@ New features
|
|||||||
- `pg-mvt`: Accept trailing semicolon in input queries.
|
- `pg-mvt`: Accept trailing semicolon in input queries.
|
||||||
- `Renderer Cache Entry`: Do not throw errors for integrity checks.
|
- `Renderer Cache Entry`: Do not throw errors for integrity checks.
|
||||||
|
|
||||||
|
Bug Fixes:
|
||||||
|
- Prevent from uncaught exception: Range filter Error from camshaft when getting analysis query.
|
||||||
|
|
||||||
## 6.4.0
|
## 6.4.0
|
||||||
Released 2018-09-24
|
Released 2018-09-24
|
||||||
|
|
||||||
|
@ -107,24 +107,32 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
|
|||||||
return sourceId2Query;
|
return sourceId2Query;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
var missingNodesErrors = [];
|
var analysesErrors = [];
|
||||||
|
|
||||||
requestMapConfig.layers = requestMapConfig.layers.map(function(layer, layerIndex) {
|
requestMapConfig.layers = requestMapConfig.layers.map(function(layer, layerIndex) {
|
||||||
if (getLayerSourceId(layer)) {
|
if (getLayerSourceId(layer)) {
|
||||||
var layerSourceId = getLayerSourceId(layer);
|
var layerSourceId = getLayerSourceId(layer);
|
||||||
var layerNode = sourceId2Node[layerSourceId];
|
var layerNode = sourceId2Node[layerSourceId];
|
||||||
if (layerNode) {
|
if (layerNode) {
|
||||||
var analysisSql = layerQuery(layerNode);
|
try {
|
||||||
var sqlQueryWrap = layer.options.sql_wrap;
|
var analysisSql;
|
||||||
if (sqlQueryWrap) {
|
|
||||||
layer.options.sql_raw = analysisSql;
|
// it might throw error: Range filter from camshaft, for instance.
|
||||||
analysisSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, analysisSql);
|
analysisSql = layerQuery(layerNode);
|
||||||
|
|
||||||
|
var sqlQueryWrap = layer.options.sql_wrap;
|
||||||
|
if (sqlQueryWrap) {
|
||||||
|
layer.options.sql_raw = analysisSql;
|
||||||
|
analysisSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, analysisSql);
|
||||||
|
}
|
||||||
|
layer.options.sql = analysisSql;
|
||||||
|
layer.options.columns = getDataviewsColumns(getLayerDataviews(layer, dataviews));
|
||||||
|
layer.options.affected_tables = getAllAffectedTablesFromSourceNodes(layerNode);
|
||||||
|
} catch (error) {
|
||||||
|
analysesErrors.push(error);
|
||||||
}
|
}
|
||||||
layer.options.sql = analysisSql;
|
|
||||||
layer.options.columns = getDataviewsColumns(getLayerDataviews(layer, dataviews));
|
|
||||||
layer.options.affected_tables = getAllAffectedTablesFromSourceNodes(layerNode);
|
|
||||||
} else {
|
} else {
|
||||||
missingNodesErrors.push(
|
analysesErrors.push(
|
||||||
new Error('Missing analysis node.id="' + layerSourceId +'" for layer='+layerIndex)
|
new Error('Missing analysis node.id="' + layerSourceId +'" for layer='+layerIndex)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -133,8 +141,8 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
|
|||||||
});
|
});
|
||||||
|
|
||||||
var missingDataviewsNodesErrors = getMissingDataviewsSourceIds(dataviews, sourceId2Node);
|
var missingDataviewsNodesErrors = getMissingDataviewsSourceIds(dataviews, sourceId2Node);
|
||||||
if (missingNodesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) {
|
if (analysesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) {
|
||||||
return callback(missingNodesErrors.concat(missingDataviewsNodesErrors));
|
return callback(analysesErrors.concat(missingDataviewsNodesErrors));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Augment dataviews with sql from analyses
|
// Augment dataviews with sql from analyses
|
||||||
|
Loading…
Reference in New Issue
Block a user