This is an automated email from the ASF dual-hosted git repository. villebro pushed a commit to branch 1.5 in repository https://gitbox.apache.org/repos/asf/superset.git
commit c4d24a09a81c554c375d72d2746808c5a4a36132 Author: Ville Brofeldt <[email protected]> AuthorDate: Wed Apr 6 12:32:41 2022 +0300 fix(sqllab): null database with backend persistence (#19548) (cherry picked from commit 2d81c4c79f93b9954d5090964b4f140bfb35723e) --- 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,
