You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by va...@apache.org on 2025/06/18 19:13:50 UTC

(superset) 01/01: fix: Set time filter's isExtra to false when saving as new chart

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

vavila pushed a commit to branch fix/set-time-filter-isextra-to-false
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 3cdf7668173c4e79737a647dba07ce888c4d31c4
Author: Vitor Avila <vi...@preset.io>
AuthorDate: Wed Jun 18 16:13:34 2025 -0300

    fix: Set time filter's isExtra to false when saving as new chart
---
 .../src/explore/actions/saveModalActions.test.ts   | 36 ++++++++++++++++++++++
 .../src/explore/actions/saveModalActions.ts        |  1 +
 2 files changed, 37 insertions(+)

diff --git a/superset-frontend/src/explore/actions/saveModalActions.test.ts b/superset-frontend/src/explore/actions/saveModalActions.test.ts
index d7a9e3fb4a..b1adb19107 100644
--- a/superset-frontend/src/explore/actions/saveModalActions.test.ts
+++ b/superset-frontend/src/explore/actions/saveModalActions.test.ts
@@ -689,4 +689,40 @@ describe('getSlicePayload', () => {
 
     expect(hasTemporalRange).toBe(true);
   });
+
+  test('should reset isExtra flag to false for temporal filter when saving as a new chart', () => {
+    const formDataWithTemporalFilterWithExtra: QueryFormData = {
+      ...formDataWithNativeFilters,
+      adhoc_filters: [
+        {
+          clause: 'WHERE',
+          subject: 'year',
+          operator: 'TEMPORAL_RANGE',
+          comparator: '2004 : ',
+          expressionType: 'SIMPLE',
+          isExtra: true,
+        },
+      ],
+    };
+
+    const result = getSlicePayload(
+      sliceName,
+      formDataWithTemporalFilterWithExtra,
+      dashboards,
+      owners as [],
+      {} as QueryFormData,
+    );
+
+    const savedFilters = JSON.parse(result.params as string).adhoc_filters;
+
+    expect(savedFilters).toHaveLength(1);
+    expect(savedFilters[0]).toMatchObject({
+      clause: 'WHERE',
+      subject: 'year',
+      operator: 'TEMPORAL_RANGE',
+      comparator: 'No filter',
+      expressionType: 'SIMPLE',
+      isExtra: false,
+    });
+  });
 });
diff --git a/superset-frontend/src/explore/actions/saveModalActions.ts b/superset-frontend/src/explore/actions/saveModalActions.ts
index 42f2c0686c..967c10cf7c 100644
--- a/superset-frontend/src/explore/actions/saveModalActions.ts
+++ b/superset-frontend/src/explore/actions/saveModalActions.ts
@@ -132,6 +132,7 @@ export const getSlicePayload = (
             adhocFilters[filtersKey].push({
               ...filter,
               comparator: 'No filter',
+              isExtra: false,
             });
           }
         },