betodealmeida commented on code in PR #20114:
URL: https://github.com/apache/superset/pull/20114#discussion_r892671019
##########
superset/common/query_object.py:
##########
@@ -396,6 +398,24 @@ def cache_key(self, **extra: Any) -> str:
if annotation_layers:
cache_dict["annotation_layers"] = annotation_layers
+ # Add an impersonation key to cache if impersonation is enabled on the
db
+ if (
+ feature_flag_manager.is_feature_enabled("CACHE_IMPERSONATION")
+ and self.datasource
+ and hasattr(self.datasource, "database")
+ and self.datasource.database.impersonate_user
+ ):
+
+ if key :=
self.datasource.database.db_engine_spec.get_impersonation_key(
+ get_username()
Review Comment:
Passing the user object here instead of the username makes the method more
flexible, since other DBs might want to use the ID or the email. You can simply
do:
```suggestion
getattr(g, "user", None)
```
And add `from flask import g` to the top of the file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]