This is an automated email from the ASF dual-hosted git repository.
erikrit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 7c059cd fix: make dataset update methods static instead of global
(#16044)
7c059cd is described below
commit 7c059cda39956d5ce808d697546f4f2bcb574964
Author: Erik Ritter <[email protected]>
AuthorDate: Tue Aug 3 08:47:52 2021 -0700
fix: make dataset update methods static instead of global (#16044)
---
superset/connectors/druid/models.py | 34 +++++++++++++++++-----------------
superset/connectors/sqla/models.py | 28 ++++++++++++++--------------
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/superset/connectors/druid/models.py
b/superset/connectors/druid/models.py
index 8768046..af73d2d 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -1690,25 +1690,25 @@ class DruidDatasource(Model, BaseDatasource):
latest_metadata = self.latest_metadata() or {}
return [{"name": k, "type": v.get("type")} for k, v in
latest_metadata.items()]
+ @staticmethod
+ def update_datasource(
+ _mapper: Mapper, _connection: Connection, obj: Union[DruidColumn,
DruidMetric]
+ ) -> None:
+ """
+ Forces an update to the datasource's changed_on value when a metric or
column on
+ the datasource is updated. This busts the cache key for all charts
that use the
+ datasource.
-def update_datasource(
- _mapper: Mapper, _connection: Connection, obj: Union[DruidColumn,
DruidMetric]
-) -> None:
- """
- Forces an update to the datasource's changed_on value when a metric or
column on
- the datasource is updated. This busts the cache key for all charts that
use the
- datasource.
-
- :param _mapper: Unused.
- :param _connection: Unused.
- :param obj: The metric or column that was updated.
- """
- db.session.execute(
- update(DruidDatasource).where(DruidDatasource.id == obj.datasource.id)
- )
+ :param _mapper: Unused.
+ :param _connection: Unused.
+ :param obj: The metric or column that was updated.
+ """
+ db.session.execute(
+ update(DruidDatasource).where(DruidDatasource.id ==
obj.datasource.id)
+ )
sa.event.listen(DruidDatasource, "after_insert", security_manager.set_perm)
sa.event.listen(DruidDatasource, "after_update", security_manager.set_perm)
-sa.event.listen(DruidMetric, "after_update", update_datasource)
-sa.event.listen(DruidColumn, "after_update", update_datasource)
+sa.event.listen(DruidMetric, "after_update", DruidDatasource.update_datasource)
+sa.event.listen(DruidColumn, "after_update", DruidDatasource.update_datasource)
diff --git a/superset/connectors/sqla/models.py
b/superset/connectors/sqla/models.py
index a3fd9cb..1a55607 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1653,26 +1653,26 @@ class SqlaTable( # pylint:
disable=too-many-public-methods,too-many-instance-at
):
raise Exception(get_dataset_exist_error_msg(target.full_name))
+ @staticmethod
+ def update_table(
+ _mapper: Mapper, _connection: Connection, obj: Union[SqlMetric,
TableColumn]
+ ) -> None:
+ """
+ Forces an update to the table's changed_on value when a metric or
column on the
+ table is updated. This busts the cache key for all charts that use the
table.
-def update_table(
- _mapper: Mapper, _connection: Connection, obj: Union[SqlMetric,
TableColumn]
-) -> None:
- """
- Forces an update to the table's changed_on value when a metric or column
on the
- table is updated. This busts the cache key for all charts that use the
table.
-
- :param _mapper: Unused.
- :param _connection: Unused.
- :param obj: The metric or column that was updated.
- """
- db.session.execute(update(SqlaTable).where(SqlaTable.id == obj.table.id))
+ :param _mapper: Unused.
+ :param _connection: Unused.
+ :param obj: The metric or column that was updated.
+ """
+ db.session.execute(update(SqlaTable).where(SqlaTable.id ==
obj.table.id))
sa.event.listen(SqlaTable, "after_insert", security_manager.set_perm)
sa.event.listen(SqlaTable, "after_update", security_manager.set_perm)
sa.event.listen(SqlaTable, "before_update", SqlaTable.before_update)
-sa.event.listen(SqlMetric, "after_update", update_table)
-sa.event.listen(TableColumn, "after_update", update_table)
+sa.event.listen(SqlMetric, "after_update", SqlaTable.update_table)
+sa.event.listen(TableColumn, "after_update", SqlaTable.update_table)
RLSFilterRoles = Table(
"rls_filter_roles",