From ae7e7578dbb3e9268a35fc92f2f814fa304a0389 Mon Sep 17 00:00:00 2001 From: IagoLast Date: Wed, 13 Jun 2018 09:38:24 +0200 Subject: [PATCH] Use early return --- lib/cartodb/utils/date-wrapper.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/cartodb/utils/date-wrapper.js b/lib/cartodb/utils/date-wrapper.js index 895cb7c8..60e88001 100644 --- a/lib/cartodb/utils/date-wrapper.js +++ b/lib/cartodb/utils/date-wrapper.js @@ -35,19 +35,20 @@ function _castColumnToEpoch(columnName) { } function getColumnsWithWrappedDates(query) { - if (query) { - if (query.match(/\b_cdb_epoch_transformation\b/)) { - const columns = []; - const fieldMatcher = /\bdate_part\('epoch', "([^"]+)"\) as "([^"]+)"/gmi; - let match; - do { - match = fieldMatcher.exec(query); - if (match && match[1] === match[2]) { - columns.push(match[1]); - } - } while (match); - return columns; - } + if(!query){ + return; + } + if (query.match(/\b_cdb_epoch_transformation\b/)) { + const columns = []; + const fieldMatcher = /\bdate_part\('epoch', "([^"]+)"\) as "([^"]+)"/gmi; + let match; + do { + match = fieldMatcher.exec(query); + if (match && match[1] === match[2]) { + columns.push(match[1]); + } + } while (match); + return columns; } }