Skip to content

Commit

Permalink
fix: invalid float number format by json-bigint (#21968)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Oct 31, 2022
1 parent 7f78778 commit 3bb9187
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 47 deletions.
52 changes: 11 additions & 41 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/packages/superset-ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
Expand All @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/FilterableTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3bb9187

Please sign in to comment.