fix: queryEditor bug (#16452)

* queryEditor bug

* update tests

Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
AAfghahi
2021-08-26 18:20:02 -04:00
committed by GitHub
parent fd6456186d
commit ee2eccdb67
2 changed files with 37 additions and 20 deletions

View File

@@ -898,16 +898,11 @@ export function updateSavedQuery(query) {
export function queryEditorSetSql(queryEditor, sql) {
return function (dispatch) {
const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)
? SupersetClient.put({
endpoint: encodeURI(`/tabstateview/${queryEditor.id}`),
postPayload: { sql, latest_query_id: queryEditor.latestQueryId },
})
: Promise.resolve();
return sync
.then(() => dispatch({ type: QUERY_EDITOR_SET_SQL, queryEditor, sql }))
.catch(() =>
if (isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE)) {
return SupersetClient.put({
endpoint: encodeURI(`/tabstateview/${queryEditor.id}`),
postPayload: { sql, latest_query_id: queryEditor.latestQueryId },
}).catch(() =>
dispatch(
addDangerToast(
t(
@@ -918,6 +913,8 @@ export function queryEditorSetSql(queryEditor, sql) {
),
),
);
}
return dispatch({ type: QUERY_EDITOR_SET_SQL, queryEditor, sql });
};
}