You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2022/04/06 09:32:52 UTC
[superset] branch master updated: fix(sqllab): null database with backend persistence (#19548)
This is an automated email from the ASF dual-hosted git repository.
villebro 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 2d81c4c79f fix(sqllab): null database with backend persistence (#19548)
2d81c4c79f is described below
commit 2d81c4c79f93b9954d5090964b4f140bfb35723e
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Wed Apr 6 12:32:41 2022 +0300
fix(sqllab): null database with backend persistence (#19548)
---
superset-frontend/src/SqlLab/actions/sqlLab.js | 21 ++++++++++++++++-----
superset/models/sql_lab.py | 2 +-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js
index 02e07d5831..e602b796bd 100644
--- a/superset-frontend/src/SqlLab/actions/sqlLab.js
+++ b/superset-frontend/src/SqlLab/actions/sqlLab.js
@@ -1393,10 +1393,21 @@ export function queryEditorSetFunctionNames(queryEditor, dbId) {
functionNames: json.function_names,
}),
)
- .catch(() =>
- dispatch(
- addDangerToast(t('An error occurred while fetching function names.')),
- ),
- );
+ .catch(err => {
+ if (err.status === 404) {
+ // for databases that have been deleted, just reset the function names
+ dispatch({
+ type: QUERY_EDITOR_SET_FUNCTION_NAMES,
+ queryEditor,
+ functionNames: [],
+ });
+ } else {
+ dispatch(
+ addDangerToast(
+ t('An error occurred while fetching function names.'),
+ ),
+ );
+ }
+ });
};
}
diff --git a/superset/models/sql_lab.py b/superset/models/sql_lab.py
index 6a3b4ad8bf..57d7220705 100644
--- a/superset/models/sql_lab.py
+++ b/superset/models/sql_lab.py
@@ -118,7 +118,7 @@ class Query(Model, ExtraJSONMixin):
"changedOn": self.changed_on,
"changed_on": self.changed_on.isoformat(),
"dbId": self.database_id,
- "db": self.database.database_name,
+ "db": self.database.database_name if self.database else None,
"endDttm": self.end_time,
"errorMessage": self.error_message,
"executedSql": self.executed_sql,