mirror of https://github.com/apache/superset.git
fix: invalid float number format by json-bigint (#21968)
This commit is contained in:
parent
7f78778792
commit
3bb9187797
|
@ -80,7 +80,7 @@
|
|||
"jquery": "^3.5.1",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
"json-bigint-native": "^1.2.0",
|
||||
"json-stringify-pretty-compact": "^2.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
@ -183,7 +183,6 @@
|
|||
"@types/jest": "^26.0.3",
|
||||
"@types/jquery": "^3.5.8",
|
||||
"@types/js-levenshtein": "^1.1.0",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/react": "^16.9.43",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/react-gravatar": "^2.6.8",
|
||||
|
@ -18197,11 +18196,6 @@
|
|||
"integrity": "sha512-14t0v1ICYRtRVcHASzes0v/O+TIeASb8aD55cWF1PidtInhFWSXcmhzhHqGjUWf9SUq1w70cvd1cWKUULubAfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/json-bigint": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz",
|
||||
"integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw=="
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz",
|
||||
|
@ -21829,14 +21823,6 @@
|
|||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/bignumber.js": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
|
||||
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/bin-links": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bin-links/-/bin-links-2.3.0.tgz",
|
||||
|
@ -37504,13 +37490,10 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/json-bigint": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
|
||||
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.0.0"
|
||||
}
|
||||
"node_modules/json-bigint-native": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/json-bigint-native/-/json-bigint-native-1.2.0.tgz",
|
||||
"integrity": "sha512-qC9EtJsyULhbwC2KEYoR8sRsC+PH7VwwPdxU6+CZTZxMtM23zlxCfhIa+6Sn74FQ4VqDqWUaHaBeU0bMUTU9jQ=="
|
||||
},
|
||||
"node_modules/json-bignum": {
|
||||
"version": "0.0.3",
|
||||
|
@ -54769,7 +54752,6 @@
|
|||
"@types/d3-time-format": "^2.1.0",
|
||||
"@types/enzyme": "^3.10.5",
|
||||
"@types/fetch-mock": "^7.3.3",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/lodash": "^4.14.149",
|
||||
"@types/math-expression-evaluator": "^1.2.1",
|
||||
"@types/node": "^18.0.0",
|
||||
|
@ -54785,6 +54767,7 @@
|
|||
"d3-time-format": "^2.2.0",
|
||||
"fetch-retry": "^4.0.1",
|
||||
"jed": "^1.1.1",
|
||||
"json-bigint-native": "^1.2.0",
|
||||
"lodash": "^4.17.11",
|
||||
"math-expression-evaluator": "^1.3.8",
|
||||
"pretty-ms": "^7.0.0",
|
||||
|
@ -69171,7 +69154,6 @@
|
|||
"@types/d3-time-format": "^2.1.0",
|
||||
"@types/enzyme": "^3.10.5",
|
||||
"@types/fetch-mock": "^7.3.3",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/lodash": "^4.14.149",
|
||||
"@types/math-expression-evaluator": "^1.2.1",
|
||||
"@types/node": "^18.0.0",
|
||||
|
@ -69189,6 +69171,7 @@
|
|||
"fetch-retry": "^4.0.1",
|
||||
"jed": "^1.1.1",
|
||||
"jest-mock-console": "^1.0.0",
|
||||
"json-bigint-native": "^1.2.0",
|
||||
"lodash": "^4.17.11",
|
||||
"math-expression-evaluator": "^1.3.8",
|
||||
"pretty-ms": "^7.0.0",
|
||||
|
@ -71050,11 +71033,6 @@
|
|||
"integrity": "sha512-14t0v1ICYRtRVcHASzes0v/O+TIeASb8aD55cWF1PidtInhFWSXcmhzhHqGjUWf9SUq1w70cvd1cWKUULubAfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/json-bigint": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz",
|
||||
"integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw=="
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz",
|
||||
|
@ -73980,11 +73958,6 @@
|
|||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ=="
|
||||
},
|
||||
"bignumber.js": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
|
||||
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A=="
|
||||
},
|
||||
"bin-links": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bin-links/-/bin-links-2.3.0.tgz",
|
||||
|
@ -86061,13 +86034,10 @@
|
|||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
|
||||
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
|
||||
},
|
||||
"json-bigint": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
|
||||
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
|
||||
"requires": {
|
||||
"bignumber.js": "^9.0.0"
|
||||
}
|
||||
"json-bigint-native": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/json-bigint-native/-/json-bigint-native-1.2.0.tgz",
|
||||
"integrity": "sha512-qC9EtJsyULhbwC2KEYoR8sRsC+PH7VwwPdxU6+CZTZxMtM23zlxCfhIa+6Sn74FQ4VqDqWUaHaBeU0bMUTU9jQ=="
|
||||
},
|
||||
"json-bignum": {
|
||||
"version": "0.0.3",
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
"jquery": "^3.5.1",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"json-bigint": "^1.0.0",
|
||||
"json-bigint-native": "^1.2.0",
|
||||
"json-stringify-pretty-compact": "^2.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
@ -247,7 +247,6 @@
|
|||
"@types/jest": "^26.0.3",
|
||||
"@types/jquery": "^3.5.8",
|
||||
"@types/js-levenshtein": "^1.1.0",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/react": "^16.9.43",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/react-gravatar": "^2.6.8",
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
"@types/d3-time-format": "^2.1.0",
|
||||
"@types/enzyme": "^3.10.5",
|
||||
"@types/fetch-mock": "^7.3.3",
|
||||
"@types/json-bigint": "^1.0.1",
|
||||
"@types/lodash": "^4.14.149",
|
||||
"@types/math-expression-evaluator": "^1.2.1",
|
||||
"@types/node": "^18.0.0",
|
||||
|
@ -56,6 +55,7 @@
|
|||
"d3-time-format": "^2.2.0",
|
||||
"fetch-retry": "^4.0.1",
|
||||
"jed": "^1.1.1",
|
||||
"json-bigint-native": "^1.2.0",
|
||||
"lodash": "^4.17.11",
|
||||
"math-expression-evaluator": "^1.3.8",
|
||||
"pretty-ms": "^7.0.0",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import JSONbig from 'json-bigint';
|
||||
import JSONbig from 'json-bigint-native';
|
||||
|
||||
import { ParseMethod, TextResponse, JsonResponse } from '../types';
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ describe('parseResponse()', () => {
|
|||
it('resolves to big number value if `parseMethod=json-bigint`', async () => {
|
||||
const mockBigIntUrl = '/mock/get/bigInt';
|
||||
const mockGetBigIntPayload =
|
||||
'{ "value": 9223372036854775807, "minusValue": -483729382918228373892 }';
|
||||
'{ "value": 9223372036854775807, "minusValue": -483729382918228373892, "number": 1234, "floatValue": 0.345221136, "minusFloatValue": -0.345221136 }';
|
||||
fetchMock.get(mockBigIntUrl, mockGetBigIntPayload);
|
||||
const responseBigNumber = await parseResponse(
|
||||
callApi({ url: mockBigIntUrl, method: 'GET' }),
|
||||
|
@ -150,6 +150,17 @@ describe('parseResponse()', () => {
|
|||
expect(`${responseBigNumber.json.minusValue}`).toEqual(
|
||||
'-483729382918228373892',
|
||||
);
|
||||
expect(responseBigNumber.json.number).toEqual(1234);
|
||||
expect(responseBigNumber.json.floatValue).toEqual(0.345221136);
|
||||
expect(responseBigNumber.json.minusFloatValue).toEqual(-0.345221136);
|
||||
expect(
|
||||
responseBigNumber.json.floatValue +
|
||||
responseBigNumber.json.minusFloatValue,
|
||||
).toEqual(0);
|
||||
expect(
|
||||
responseBigNumber.json.floatValue /
|
||||
responseBigNumber.json.minusFloatValue,
|
||||
).toEqual(-1);
|
||||
});
|
||||
|
||||
it('rejects if request.ok=false', async () => {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import JSONbig from 'json-bigint';
|
||||
import JSONbig from 'json-bigint-native';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import JSONTree from 'react-json-tree';
|
||||
import {
|
||||
|
|
Loading…
Reference in New Issue