You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2019/10/04 23:43:26 UTC
[incubator-superset] branch master updated: fix saving new sql lab
queries (#8351)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new b093406 fix saving new sql lab queries (#8351)
b093406 is described below
commit b0934065365778f5989077a3b944ea6524c710ce
Author: David Aaron Suddjian <18...@users.noreply.github.com>
AuthorDate: Fri Oct 4 16:43:05 2019 -0700
fix saving new sql lab queries (#8351)
* fix saving new sql lab queries
* allow freshly saved queries to be updated immediately
---
superset/assets/src/SqlLab/actions/sqlLab.js | 10 +++++++++-
superset/assets/src/SqlLab/reducers/sqlLab.js | 5 +++++
superset/views/sql_lab.py | 12 ++----------
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/superset/assets/src/SqlLab/actions/sqlLab.js b/superset/assets/src/SqlLab/actions/sqlLab.js
index f4fcc8e..8f36eca 100644
--- a/superset/assets/src/SqlLab/actions/sqlLab.js
+++ b/superset/assets/src/SqlLab/actions/sqlLab.js
@@ -35,6 +35,7 @@ import COMMON_ERR_MESSAGES from '../../utils/errorMessages';
export const RESET_STATE = 'RESET_STATE';
export const ADD_QUERY_EDITOR = 'ADD_QUERY_EDITOR';
export const UPDATE_QUERY_EDITOR = 'UPDATE_QUERY_EDITOR';
+export const QUERY_EDITOR_SAVED = 'QUERY_EDITOR_SAVED';
export const CLONE_QUERY_TO_NEW_TAB = 'CLONE_QUERY_TO_NEW_TAB';
export const REMOVE_QUERY_EDITOR = 'REMOVE_QUERY_EDITOR';
export const MERGE_TABLE = 'MERGE_TABLE';
@@ -129,7 +130,14 @@ export function saveQuery(query) {
postPayload: convertQueryToServer(query),
stringify: false,
})
- .then(() => dispatch(addSuccessToast(t('Your query was saved'))))
+ .then((result) => {
+ dispatch({
+ type: QUERY_EDITOR_SAVED,
+ query,
+ result: convertQueryToClient(result.json.item),
+ });
+ dispatch(addSuccessToast(t('Your query was saved')));
+ })
.catch(() => dispatch(addDangerToast(t('Your query could not be saved'))));
}
diff --git a/superset/assets/src/SqlLab/reducers/sqlLab.js b/superset/assets/src/SqlLab/reducers/sqlLab.js
index aafc753..1d0715a 100644
--- a/superset/assets/src/SqlLab/reducers/sqlLab.js
+++ b/superset/assets/src/SqlLab/reducers/sqlLab.js
@@ -39,6 +39,11 @@ export default function sqlLabReducer(state = {}, action) {
const newState = Object.assign({}, state, { tabHistory });
return addToArr(newState, 'queryEditors', action.queryEditor);
},
+ [actions.QUERY_EDITOR_SAVED]() {
+ const { query, result } = action;
+ const existing = state.queryEditors.find(qe => qe.id === query.id);
+ return alterInArr(state, 'queryEditors', existing, { remoteId: result.remoteId }, 'id');
+ },
[actions.UPDATE_QUERY_EDITOR]() {
const id = action.alterations.remoteId;
const existing = state.queryEditors.find(qe => qe.remoteId === id);
diff --git a/superset/views/sql_lab.py b/superset/views/sql_lab.py
index 06339cd..1d202fa 100644
--- a/superset/views/sql_lab.py
+++ b/superset/views/sql_lab.py
@@ -156,17 +156,9 @@ class SavedQueryViewApi(SavedQueryView):
"sql",
"extra_json",
]
- show_columns = [
- "id",
- "label",
- "db_id",
- "schema",
- "description",
- "sql",
- "extra_json",
- ]
- add_columns = show_columns
+ add_columns = ["label", "db_id", "schema", "description", "sql", "extra_json"]
edit_columns = add_columns
+ show_columns = add_columns + ["id"]
@has_access_api
@expose("show/<pk>")