[sqllab] fix exception caused by casting string to int with psycopg2 (#9287)

* [sqllab] fix exception caused by casting string to int with psycopg2

* rollback session on exception

* add SQLLAB_BACKEND_PERSISTENCE to default feature flags

* cast tab_state_id to str in python instead of sql

* remove import
This commit is contained in:
ʈᵃᵢ 2020-03-16 10:51:41 -07:00 committed by GitHub
parent b1916a190e
commit 8764ae3852
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -285,6 +285,7 @@ DEFAULT_FEATURE_FLAGS = {
"REDUCE_DASHBOARD_BOOTSTRAP_PAYLOAD": False,
"SHARE_QUERIES_VIA_KV_STORE": False,
"TAGGING_SYSTEM": False,
"SQLLAB_BACKEND_PERSISTENCE": False,
}
# This is merely a default.

View File

@ -2704,7 +2704,7 @@ class Superset(BaseSupersetView):
.filter_by(user_id=user_id)
.all()
)
tab_state_ids = [tab_state[0] for tab_state in tabs_state]
tab_state_ids = [str(tab_state[0]) for tab_state in tabs_state]
# return first active tab, or fallback to another one if no tab is active
active_tab = (
db.session.query(TabState)
@ -2728,7 +2728,7 @@ class Superset(BaseSupersetView):
user_queries = (
db.session.query(Query)
.filter_by(user_id=user_id)
.filter(Query.sql_editor_id.cast(Integer).in_(tab_state_ids))
.filter(Query.sql_editor_id.in_(tab_state_ids))
.all()
)
queries = {