You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2017/10/11 00:52:25 UTC
[incubator-superset] branch master updated: [sql lab] fix
impersonation + template issue (#3644)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin 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 76f8d33 [sql lab] fix impersonation + template issue (#3644)
76f8d33 is described below
commit 76f8d33d81a7bec284d9cb95afaf397161e8c22b
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Oct 10 17:52:22 2017 -0700
[sql lab] fix impersonation + template issue (#3644)
When the database impersonation flag is on, a query using a template
fails. It has to do with templating using a database connection without
a username being specified by the caller, along with the fact that the
work is taking place on a worker, outside a web request, where
referencing g.user raises this exception.
---
superset/models/core.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/superset/models/core.py b/superset/models/core.py
index b8293b5..7392e87 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -598,7 +598,12 @@ class Database(Model, AuditMixinNullable):
params['poolclass'] = NullPool
uri = self.db_engine_spec.adjust_database_uri(uri, schema)
if self.impersonate_user:
- uri.username = user_name if user_name else g.user.username
+ eff_username = uri.username
+ if user_name:
+ eff_username = user_name
+ elif hasattr(g, 'user') and g.user.username:
+ eff_username = g.user.username
+ uri.username = eff_username
return create_engine(uri, **params)
def get_reserved_words(self):
--
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <co...@superset.apache.org>'].