andy-clapson commented on code in PR #39390:
URL: https://github.com/apache/superset/pull/39390#discussion_r3191353048


##########
superset/utils/encrypt.py:
##########
@@ -99,14 +99,27 @@ def __init__(self, previous_secret_key: str) -> None:
 
     def discover_encrypted_fields(self) -> dict[str, dict[str, EncryptedType]]:
         """
-        Iterates over SqlAlchemy's metadata, looking for EncryptedType
-        columns along the way. Builds up a dict of
+        Iterates over ORM-mapped tables, looking for EncryptedType columns
+        along the way. Builds up a dict of
         table_name -> dict of col_name: enc type instance
+
+        Superset's ORM models inherit from Flask-AppBuilder's declarative base
+        (`flask_appbuilder.Model`), whose MetaData is distinct from
+        `db.metadata`. We combine both sources so encrypted columns are found
+        regardless of which base a model uses.
         :return:
         """
+        from flask_appbuilder import (  # pylint: 
disable=import-outside-toplevel
+            Model as FABModel,
+        )
+
         meta_info: dict[str, Any] = {}
 
-        for table_name, table in self._db.metadata.tables.items():
+        tables: dict[str, Any] = {}
+        tables.update(FABModel.metadata.tables)
+        tables.update(self._db.metadata.tables)

Review Comment:
   fair, edited so that it does



##########
superset/utils/encrypt.py:
##########
@@ -99,14 +99,27 @@ def __init__(self, previous_secret_key: str) -> None:
 
     def discover_encrypted_fields(self) -> dict[str, dict[str, EncryptedType]]:
         """
-        Iterates over SqlAlchemy's metadata, looking for EncryptedType
-        columns along the way. Builds up a dict of
+        Iterates over ORM-mapped tables, looking for EncryptedType columns
+        along the way. Builds up a dict of
         table_name -> dict of col_name: enc type instance
+
+        Superset's ORM models inherit from Flask-AppBuilder's declarative base
+        (`flask_appbuilder.Model`), whose MetaData is distinct from
+        `db.metadata`. We combine both sources so encrypted columns are found
+        regardless of which base a model uses.
         :return:

Review Comment:
   specified



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