superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kri...@apache.org
Subject [incubator-superset] branch master updated: Fix for #6590: Numeric values in columns sometimes returned as quoted strings (#6591)
Date Mon, 14 Jan 2019 23:35:34 GMT
This is an automated email from the ASF dual-hosted git repository.

kristw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 207d952  Fix for #6590: Numeric values in columns sometimes returned as quoted strings
 (#6591)
207d952 is described below

commit 207d9529b2df0c6b6a2780f2a95a8d5651c41a05
Author: Christopher Council <soboko@users.noreply.github.com>
AuthorDate: Mon Jan 14 15:35:28 2019 -0800

    Fix for #6590: Numeric values in columns sometimes returned as quoted strings  (#6591)
    
    * Fix: https://github.com/apache/incubator-superset/issues/6590, also depends on https://github.com/apache-superset/superset-ui/pull/71
    
    * Bumped version of superset-ui-connector
    
    * Added @babel/polyfill import
    
    * Reset mock history before each test, not after each test
    
    * Update CONTRIBUTING.md
---
 CONTRIBUTING.md                                      |  2 +-
 superset/assets/package-lock.json                    |  9 +++++----
 superset/assets/package.json                         |  2 +-
 superset/assets/spec/helpers/shim.js                 |  1 +
 .../spec/javascripts/sqllab/actions/sqlLab_spec.js   | 20 ++++++++++++++++++--
 .../spec/javascripts/welcome/DashboardTable_spec.jsx |  2 +-
 superset/assets/src/SqlLab/actions/sqlLab.js         |  7 ++-----
 .../components/FilterableTable/FilterableTable.jsx   |  3 ++-
 8 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9f004c1..36cb65e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -202,7 +202,7 @@ Make sure your machine meets the [OS dependencies](https://superset.incubator.ap
 
 ```bash
 # Create a virtual environemnt and activate it (recommended)
-virtualenv -p python3 venv . # setup a python3.6 virtualenv
+virtualenv -p python3 venv # setup a python3.6 virtualenv
 source venv/bin/activate
 
 # Install external dependencies
diff --git a/superset/assets/package-lock.json b/superset/assets/package-lock.json
index c7bbc23..9c84301 100644
--- a/superset/assets/package-lock.json
+++ b/superset/assets/package-lock.json
@@ -2217,17 +2217,18 @@
       }
     },
     "@superset-ui/connection": {
-      "version": "0.5.0",
-      "resolved": "https://registry.npmjs.org/@superset-ui/connection/-/connection-0.5.0.tgz",
-      "integrity": "sha512-neac60ghZfDoDdOdNPbWO7D/xGhbkjHno9ii3HD2sgs/WQWLL25IzS/yPYVzQ7ZVrtPYPYxBiXizp/mFzqq2Yg==",
+      "version": "0.8.0",
+      "resolved": "https://registry.npmjs.org/@superset-ui/connection/-/connection-0.8.0.tgz",
+      "integrity": "sha512-wxKXvG38D4fTv+10693yPMQHsTA7Q+X4n8QHiai+3e2ka/bI72tv/wHSyc0MH1C5C/YVI1TNGfsg4qi6rlePIw==",
       "requires": {
         "@babel/runtime": "^7.1.2",
+        "json-bigint": "^0.3.0",
         "whatwg-fetch": "^2.0.4"
       },
       "dependencies": {
         "whatwg-fetch": {
           "version": "2.0.4",
-          "resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
+          "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
           "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
         }
       }
diff --git a/superset/assets/package.json b/superset/assets/package.json
index 429723d..578bf4f 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -53,7 +53,7 @@
     "@data-ui/xy-chart": "^0.0.61",
     "@superset-ui/chart": "^0.7.0",
     "@superset-ui/color": "^0.7.0",
-    "@superset-ui/connection": "^0.5.0",
+    "@superset-ui/connection": "^0.8.0",
     "@superset-ui/core": "^0.7.0",
     "@superset-ui/number-format": "^0.7.2",
     "@superset-ui/time-format": "^0.7.2",
diff --git a/superset/assets/spec/helpers/shim.js b/superset/assets/spec/helpers/shim.js
index 2d21b3f..73a9812 100644
--- a/superset/assets/spec/helpers/shim.js
+++ b/superset/assets/spec/helpers/shim.js
@@ -1,4 +1,5 @@
 /* eslint no-native-reassign: 0 */
+import '@babel/polyfill';
 import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
 import jsdom from 'jsdom';
 import { configure } from 'enzyme';
diff --git a/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js b/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
index 7953d63..f92a822 100644
--- a/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
+++ b/superset/assets/spec/javascripts/sqllab/actions/sqlLab_spec.js
@@ -6,6 +6,8 @@ import * as actions from '../../../../src/SqlLab/actions/sqlLab';
 import { query } from '../fixtures';
 
 describe('async actions', () => {
+  const mockBigNumber = '9223372036854775807';
+
   let dispatch;
 
   beforeEach(() => {
@@ -42,7 +44,7 @@ describe('async actions', () => {
 
   describe('fetchQueryResults', () => {
     const fetchQueryEndpoint = 'glob:*/superset/results/*';
-    fetchMock.get(fetchQueryEndpoint, '{ "data": "" }');
+    fetchMock.get(fetchQueryEndpoint, '{ "data": ' + mockBigNumber + ' }');
 
     const makeRequest = () => {
       const actionThunk = actions.fetchQueryResults(query);
@@ -65,6 +67,13 @@ describe('async actions', () => {
       });
     });
 
+    it('parses large number result without losing precision', () =>
+      makeRequest().then(() => {
+        expect(fetchMock.calls(fetchQueryEndpoint)).toHaveLength(1);
+        expect(dispatch.callCount).toBe(2);
+        expect(dispatch.getCall(1).lastArg.results.data.toString()).toBe(mockBigNumber);
+      }));
+
     it('calls querySuccess on fetch success', () =>
       makeRequest().then(() => {
         expect(dispatch.callCount).toBe(2);
@@ -88,7 +97,7 @@ describe('async actions', () => {
 
   describe('runQuery', () => {
     const runQueryEndpoint = 'glob:*/superset/sql_json/*';
-    fetchMock.post(runQueryEndpoint, { data: '' });
+    fetchMock.post(runQueryEndpoint, '{ "data": ' + mockBigNumber + ' }');
 
     const makeRequest = () => {
       const request = actions.runQuery(query);
@@ -111,6 +120,13 @@ describe('async actions', () => {
       });
     });
 
+    it('parses large number result without losing precision', () =>
+      makeRequest().then(() => {
+        expect(fetchMock.calls(runQueryEndpoint)).toHaveLength(1);
+        expect(dispatch.callCount).toBe(2);
+        expect(dispatch.getCall(1).lastArg.results.data.toString()).toBe(mockBigNumber);
+      }));
+
     it('calls querySuccess on fetch success', () => {
       expect.assertions(3);
 
diff --git a/superset/assets/spec/javascripts/welcome/DashboardTable_spec.jsx b/superset/assets/spec/javascripts/welcome/DashboardTable_spec.jsx
index 4f60cdd..852df7c 100644
--- a/superset/assets/spec/javascripts/welcome/DashboardTable_spec.jsx
+++ b/superset/assets/spec/javascripts/welcome/DashboardTable_spec.jsx
@@ -25,7 +25,7 @@ function setup() {
 }
 
 describe('DashboardTable', () => {
-  afterEach(fetchMock.resetHistory);
+  beforeEach(fetchMock.resetHistory);
 
   it('renders a Loading initially', () => {
     const wrapper = setup();
diff --git a/superset/assets/src/SqlLab/actions/sqlLab.js b/superset/assets/src/SqlLab/actions/sqlLab.js
index 084aaea..0a380eb 100644
--- a/superset/assets/src/SqlLab/actions/sqlLab.js
+++ b/superset/assets/src/SqlLab/actions/sqlLab.js
@@ -1,5 +1,4 @@
 import shortid from 'shortid';
-import JSONbig from 'json-bigint';
 import { t } from '@superset-ui/translation';
 import { SupersetClient } from '@superset-ui/connection';
 
@@ -111,11 +110,9 @@ export function fetchQueryResults(query) {
 
     return SupersetClient.get({
       endpoint: `/superset/results/${query.resultsKey}/`,
-      parseMethod: 'text',
     })
-      .then(({ text = '{}' }) => {
-        const bigIntJson = JSONbig.parse(text);
-        dispatch(querySuccess(query, bigIntJson));
+      .then(({ json = {} }) => {
+        dispatch(querySuccess(query, json));
       })
       .catch(response =>
         getClientErrorObject(response).then((error) => {
diff --git a/superset/assets/src/components/FilterableTable/FilterableTable.jsx b/superset/assets/src/components/FilterableTable/FilterableTable.jsx
index 307d97c..4105ff6 100644
--- a/superset/assets/src/components/FilterableTable/FilterableTable.jsx
+++ b/superset/assets/src/components/FilterableTable/FilterableTable.jsx
@@ -1,5 +1,6 @@
 import { List } from 'immutable';
 import PropTypes from 'prop-types';
+import JSONbig from 'json-bigint';
 import React, { PureComponent } from 'react';
 import {
   Column,
@@ -85,7 +86,7 @@ export default class FilterableTable extends PureComponent {
         if (['string', 'number'].indexOf(typeof (val)) >= 0) {
           newRow[k] = val;
         } else {
-          newRow[k] = JSON.stringify(val);
+          newRow[k] = JSONbig.stringify(val);
         }
       }
       return newRow;


Mime
View raw message