From 08c709c2ec5dc3e5ee9f7a82006a0816c2529a6e Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Wed, 28 Feb 2018 13:28:15 +0200 Subject: [PATCH] getredash/redash#1960 Cast column names to string; code style fixes --- client/app/services/query-result.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/client/app/services/query-result.js b/client/app/services/query-result.js index 1ebe00b3f2..4797aa9d95 100644 --- a/client/app/services/query-result.js +++ b/client/app/services/query-result.js @@ -31,8 +31,7 @@ function getColumnNameWithoutType(column) { } export function getColumnCleanName(column) { - const name = getColumnNameWithoutType(column); - return name; + return getColumnNameWithoutType(column); } function getColumnFriendlyName(column) { @@ -120,6 +119,7 @@ function QueryResultService($resource, $timeout, $q) { }); each(this.query_result.data.columns, (column) => { + column.name = '' + column.name; if (columnTypes[column.name]) { if (column.type == null || column.type === 'string') { column.type = columnTypes[column.name]; @@ -183,9 +183,7 @@ function QueryResultService($resource, $timeout, $q) { return null; } - const data = this.query_result.data.rows; - - return data; + return this.query_result.data.rows; } getData() { @@ -262,12 +260,11 @@ function QueryResultService($resource, $timeout, $q) { let sizeValue = null; each(row, (v, definition) => { - const name = definition.split('::')[0] || definition.split('__')[0]; + definition = '' + definition; + const definitionParts = definition.split('::') || definition.split('__'); + const name = definitionParts[0]; + const type = mapping ? mapping[definition] : definitionParts[1]; let value = v; - let type = definition.split('::')[1] || definition.split('__')[1]; - if (mapping) { - type = mapping[definition]; - } if (type === 'unused') { return;