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

michaelsmolina 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 0dc9215c89 fix(Explore): Keep necessary form data to allow query mode 
switching (#29234)
0dc9215c89 is described below

commit 0dc9215c899076b89766ea120caca3419704c708
Author: Ross Mabbett <[email protected]>
AuthorDate: Thu Jun 13 13:30:49 2024 -0400

    fix(Explore): Keep necessary form data to allow query mode switching 
(#29234)
---
 .../explore/components/ExploreViewContainer/index.jsx    | 16 ++++++++++++----
 superset-frontend/src/explore/constants.ts               |  8 ++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git 
a/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx 
b/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
index d723bfbb39..c79ccda832 100644
--- a/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
+++ b/superset-frontend/src/explore/components/ExploreViewContainer/index.jsx
@@ -43,6 +43,7 @@ import {
   LocalStorageKeys,
 } from 'src/utils/localStorageHelpers';
 import { RESERVED_CHART_URL_PARAMS, URL_PARAMS } from 'src/constants';
+import { QUERY_MODE_REQUISITES } from 'src/explore/constants';
 import { areObjectsEqual } from 'src/reduxUtils';
 import * as logActions from 'src/logger/actions';
 import {
@@ -710,6 +711,12 @@ function ExploreViewContainer(props) {
 
 ExploreViewContainer.propTypes = propTypes;
 
+const retainQueryModeRequirements = hiddenFormData => {
+  Object.keys(hiddenFormData ?? {}).filter(
+    key => !QUERY_MODE_REQUISITES.has(key),
+  );
+};
+
 function mapStateToProps(state) {
   const {
     explore,
@@ -722,10 +729,11 @@ function mapStateToProps(state) {
     saveModal,
   } = state;
   const { controls, slice, datasource, metadata, hiddenFormData } = explore;
-  const form_data = omit(
-    getFormDataFromControls(controls),
-    Object.keys(hiddenFormData ?? {}),
-  );
+  const hasQueryMode = !!controls.query_mode?.value;
+  const fieldsToOmit = hasQueryMode
+    ? retainQueryModeRequirements(hiddenFormData)
+    : hiddenFormData;
+  const form_data = omit(getFormDataFromControls(controls), fieldsToOmit);
   const slice_id = form_data.slice_id ?? slice?.slice_id ?? 0; // 0 - unsaved 
chart
   form_data.extra_form_data = mergeExtraFormData(
     { ...form_data.extra_form_data },
diff --git a/superset-frontend/src/explore/constants.ts 
b/superset-frontend/src/explore/constants.ts
index e2bc7ea04a..cb56e31393 100644
--- a/superset-frontend/src/explore/constants.ts
+++ b/superset-frontend/src/explore/constants.ts
@@ -158,3 +158,11 @@ export const TIME_FILTER_MAP = {
 export const POPOVER_INITIAL_HEIGHT = 240;
 export const POPOVER_INITIAL_WIDTH = 320;
 export const UNSAVED_CHART_ID = 0;
+
+export const QUERY_MODE_REQUISITES = new Set([
+  'all_columns',
+  'groupby',
+  'metrics',
+  'percent_metrics',
+  'order_by_cols',
+]);

Reply via email to