Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalid float number format by json-bigint #21968

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions superset-frontend/package-lock.json

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

1 change: 1 addition & 0 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"js-levenshtein": "^1.1.6",
"js-yaml-loader": "^1.2.2",
"json-bigint": "^1.0.0",
"json-bigint-native": "^1.2.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If json-bigint is no longer maintained, can we remove that dep (on line 147)?

Copy link
Member

@zhaoyongjie zhaoyongjie Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the json-bigint-native says that added TypeScript types, the line 43 also need to be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will follow up with this

"json-stringify-pretty-compact": "^2.0.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/packages/superset-ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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