diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a4dbd048afb..e1575a30dd83 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 c7bbc232854c..9c843010a962 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 429723dc45c5..578bf4fb74ad 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 2d21b3f1453d..73a981241844 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 7953d636d9f9..f92a8221f8df 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 4f60cddab07a..852df7c6cdd1 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 084aaea80fa4..0a380eb36465 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 307d97c3d5eb..4105ff65b0d6 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;