hughhhh commented on code in PR #24580:
URL: https://github.com/apache/superset/pull/24580#discussion_r1253335004


##########
superset/databases/filters.py:
##########
@@ -41,6 +41,16 @@ class DatabaseFilter(BaseFilter):  # pylint: 
disable=too-few-public-methods
     # TODO(bogdan): consider caching.
 
     def apply(self, query: Query, value: Any) -> Query:
+        # Dynamic Filters need to be applied to the Query before we filter
+        # databases with anything else. This way you can show/hide databases 
using
+        # Feature Flags for example in conjuction with the regular role 
filtering.
+        # If not, if an user has access to all Databases it would skip this 
dynamic
+        # filtering.
+
+        if dynamic_filter := 
current_app.config["EXTRA_DYNAMIC_DATABASE_FILTER"]:
+            query = dynamic_filter(query)

Review Comment:
   what happens when the `dynamic_filter` isn't defined? looking at the code it 
seems like ` return query.filter(` will fail.
   
   Can we add a condition to check if the `dynamic_filter` is defined, then 
have a test to back it



-- 
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]

Reply via email to