Merge pull request #1048 from CartoDB/fix-uncaught-error

Prevent from uncaught exception
This commit is contained in:
Daniel G. Aubert 2018-10-23 11:54:55 +02:00 committed by GitHub
commit 2ebb1728ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 12 deletions

View File

@ -12,6 +12,9 @@ New features
- `pg-mvt`: Accept trailing semicolon in input queries.
- `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
Released 2018-09-24

View File

@ -107,24 +107,32 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
return sourceId2Query;
}, {});
var missingNodesErrors = [];
var analysesErrors = [];
requestMapConfig.layers = requestMapConfig.layers.map(function(layer, layerIndex) {
if (getLayerSourceId(layer)) {
var layerSourceId = getLayerSourceId(layer);
var layerNode = sourceId2Node[layerSourceId];
if (layerNode) {
var analysisSql = layerQuery(layerNode);
var sqlQueryWrap = layer.options.sql_wrap;
if (sqlQueryWrap) {
layer.options.sql_raw = analysisSql;
analysisSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, analysisSql);
try {
var analysisSql;
// it might throw error: Range filter from camshaft, for instance.
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 {
missingNodesErrors.push(
analysesErrors.push(
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);
if (missingNodesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) {
return callback(missingNodesErrors.concat(missingDataviewsNodesErrors));
if (analysesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) {
return callback(analysesErrors.concat(missingDataviewsNodesErrors));
}
// Augment dataviews with sql from analyses