eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904058768


##########
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx:
##########
@@ -211,28 +219,30 @@ export const SaveDatasetModal: 
FunctionComponent<SaveDatasetModalProps> = ({
       return;
     }
 
-    const selectedColumns = query.results.selected_columns || [];
+    const selectedColumns =
+      query?.results?.selected_columns ?? query.columns ?? [];
 
     // The filters param is only used to test jinja templates.
     // Remove the special filters entry from the templateParams
     // before saving the dataset.
+    let templateParams;
     if (query.templateParams) {
       const p = JSON.parse(query.templateParams);
       /* eslint-disable-next-line no-underscore-dangle */
       if (p._filters) {
         /* eslint-disable-next-line no-underscore-dangle */
         delete p._filters;
         // eslint-disable-next-line no-param-reassign
-        query.templateParams = JSON.stringify(p);
+        templateParams = JSON.stringify(p);
       }
     }
 
     dispatch(
       createDatasource({
         schema: query.schema,
         sql: query.sql,
-        dbId: query.dbId,
-        templateParams: query.templateParams,
+        dbId: query?.dbId ?? query?.database?.id,

Review Comment:
   same here.. would 0 be a valid id?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to