This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new a1983e468b fix(frontend): allow "constructor" property in response 
data (#25407)
a1983e468b is described below

commit a1983e468ba1a1b0fdbef9d8d5206e61be0b7141
Author: Spencer Torres <[email protected]>
AuthorDate: Sat Apr 6 01:46:12 2024 -0400

    fix(frontend): allow "constructor" property in response data (#25407)
---
 .../superset-ui-core/src/connection/callApi/parseResponse.ts |  6 +++++-
 .../test/connection/callApi/parseResponse.test.ts            | 12 ++++++++++--
 superset-frontend/src/components/FilterableTable/index.tsx   |  7 ++++++-
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git 
a/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
 
b/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
index 82060d379b..52dc348084 100644
--- 
a/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
+++ 
b/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
@@ -16,11 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import JSONbig from 'json-bigint';
+import _JSONbig from 'json-bigint';
 import { cloneDeepWith } from 'lodash';
 
 import { ParseMethod, TextResponse, JsonResponse } from '../types';
 
+const JSONbig = _JSONbig({
+  constructorAction: 'preserve',
+});
+
 export default async function parseResponse<T extends ParseMethod = 'json'>(
   apiPromise: Promise<Response>,
   parseMethod?: T,
diff --git 
a/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
 
b/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
index e13964ecf7..b08b5b8cb8 100644
--- 
a/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
+++ 
b/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
@@ -139,8 +139,12 @@ describe('parseResponse()', () => {
 
   it('resolves to big number value if `parseMethod=json-bigint`', async () => {
     const mockBigIntUrl = '/mock/get/bigInt';
-    const mockGetBigIntPayload =
-      '{ "value": 9223372036854775807, "minus": { "value": 
-483729382918228373892, "str": "something" }, "number": 1234, "floatValue": { 
"plus": 0.3452211361231223, "minus": -0.3452211361231223 } }';
+    const mockGetBigIntPayload = `{
+      "value": 9223372036854775807, "minus": { "value": 
-483729382918228373892, "str": "something" },
+      "number": 1234, "floatValue": { "plus": 0.3452211361231223, "minus": 
-0.3452211361231223 },
+      "string.constructor": "data.constructor",
+      "constructor": "constructor"
+    }`;
     fetchMock.get(mockBigIntUrl, mockGetBigIntPayload);
     const responseBigNumber = await parseResponse(
       callApi({ url: mockBigIntUrl, method: 'GET' }),
@@ -167,6 +171,10 @@ describe('parseResponse()', () => {
     expect(Math.abs(responseBigNumber.json.floatValue.minus)).toEqual(
       responseBigNumber.json.floatValue.plus,
     );
+    expect(responseBigNumber.json['string.constructor']).toEqual(
+      'data.constructor',
+    );
+    expect(responseBigNumber.json.constructor).toEqual('constructor');
   });
 
   it('rejects if request.ok=false', async () => {
diff --git a/superset-frontend/src/components/FilterableTable/index.tsx 
b/superset-frontend/src/components/FilterableTable/index.tsx
index d731313bde..0ae4406de2 100644
--- a/superset-frontend/src/components/FilterableTable/index.tsx
+++ b/superset-frontend/src/components/FilterableTable/index.tsx
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import JSONbig from 'json-bigint';
+import _JSONbig from 'json-bigint';
 import React, { useEffect, useRef, useState, useMemo } from 'react';
 import { getMultipleTextDimensions, styled } from '@superset-ui/core';
 import { useDebounceValue } from 'src/hooks/useDebounceValue';
@@ -24,6 +24,11 @@ import { useCellContentParser } from 
'./useCellContentParser';
 import { renderResultCell } from './utils';
 import { Table, TableSize } from '../Table';
 
+const JSONbig = _JSONbig({
+  storeAsString: true,
+  constructorAction: 'preserve',
+});
+
 const SCROLL_BAR_HEIGHT = 15;
 // This regex handles all possible number formats in javascript, including 
ints, floats,
 // exponential notation, NaN, and Infinity.

Reply via email to