From 02ac25181e58084937bc46509f640775c8e6e97f Mon Sep 17 00:00:00 2001 From: Ivan Malagon Date: Wed, 13 Dec 2017 09:45:35 +0100 Subject: [PATCH] Return error if no_filters and own_filter are present --- lib/cartodb/backends/dataview.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/cartodb/backends/dataview.js b/lib/cartodb/backends/dataview.js index d398f913..c110f328 100644 --- a/lib/cartodb/backends/dataview.js +++ b/lib/cartodb/backends/dataview.js @@ -37,11 +37,19 @@ DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, param throw new Error("Dataview '" + dataviewName + "' does not exists"); } - var pg = new PSQL(dbParamsFromReqParams(params)); - var ownFilter = +params.own_filter; - var noFilters = !!params.no_filters; - var query = getDaviewQuery(dataviewDefinition, ownFilter, noFilters); + var noFilters = +params.no_filters; + if (Number.isFinite(ownFilter) && Number.isFinite(noFilters)) { + err = new Error(); + err.message = 'Both own_filter and no_filters cannot be sent in the same request'; + err.type = 'dataview'; + err.http_status = 400; + return callback(err); + } + + var pg = new PSQL(dbParamsFromReqParams(params)); + + var query = getDataviewQuery(dataviewDefinition, ownFilter, noFilters); if (params.bbox) { var bboxFilter = new BBoxFilter({column: 'the_geom_webmercator', srid: 3857}, {bbox: params.bbox}); query = bboxFilter.sql(query); @@ -62,7 +70,7 @@ DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, param ); }; -function getDaviewQuery(dataviewDefinition, ownFilter, noFilters) { +function getDataviewQuery(dataviewDefinition, ownFilter, noFilters) { if (noFilters) { return dataviewDefinition.sql.no_filters; } else if (ownFilter === 1) {