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

hugh pushed a commit to branch hugh/fix-params
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 7c9e71be048b642f2c00e10ed6a3727d4d70d0ad
Author: hughhhh <[email protected]>
AuthorDate: Mon Jun 14 11:14:03 2021 -0400

    working query params
---
 .../CRUD/data/database/DatabaseModal/index.tsx      | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git 
a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx 
b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
index e350200..32a96c8 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -169,10 +169,19 @@ function dbReducer(
         [action.payload.name]: action.payload.value,
       };
     case ActionType.fetched:
+      let query = '';
+      if (action.payload?.parameters?.query) {
+        // convert query into URI params string
+        query = new 
URLSearchParams(action.payload.parameters.query).toString();
+      }
       return {
         engine: trimmedState.engine,
         configuration_method: trimmedState.configuration_method,
         ...action.payload,
+        parameters: {
+          ...action.payload.parameters,
+          query,
+        },
       };
     case ActionType.dbSelected:
       return {
@@ -266,6 +275,18 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     const { id, ...update } = db || {};
     if (db?.id) {
+      if (update?.parameters?.query) {
+        // convert query params into dictionary
+        update.parameters.query = JSON.parse(
+          `{"${decodeURI(db.parameters?.query || '')
+            .replace(/"/g, '\\"')
+            .replace(/&/g, '","')
+            .replace(/=/g, '":"')}"}`,
+        );
+      } else {
+        update.parameters.query = {};
+      }
+
       const result = await updateResource(
         db.id as number,
         update as DatabaseObject,

Reply via email to