zephyring commented on code in PR #25043:
URL: https://github.com/apache/superset/pull/25043#discussion_r1300358441
##########
superset/connectors/sqla/models.py:
##########
@@ -1427,46 +1425,20 @@ def quote_identifier(self) -> Callable[[str], str]:
@staticmethod
def before_update(
- mapper: Mapper, # pylint: disable=unused-argument
- connection: Connection, # pylint: disable=unused-argument
+ mapper: Mapper,
+ connection: Connection,
target: SqlaTable,
) -> None:
"""
- Check before update if the target table already exists.
-
- Note this listener is called when any fields are being updated and
thus it is
- necessary to first check whether the reference table is being updated.
-
- Note this logic is temporary, given uniqueness is handled via the
dataset DAO,
- but is necessary until both the legacy datasource editor and
datasource/save
- endpoints are deprecated.
+ Note this listener is called when any fields are being updated
:param mapper: The table mapper
:param connection: The DB-API connection
:param target: The mapped instance being persisted
:raises Exception: If the target table is not unique
"""
-
- # pylint: disable=import-outside-toplevel
- from superset.daos.dataset import DatasetDAO
- from superset.datasets.commands.exceptions import
get_dataset_exist_error_msg
-
- # Check whether the relevant attributes have changed.
- state = db.inspect(target) # pylint: disable=no-member
-
- for attr in ["database_id", "schema", "table_name"]:
- history = state.get_history(attr, True)
- if history.has_changes():
- break
- else:
- return None
-
- if not DatasetDAO.validate_uniqueness(
Review Comment:
this check has already been made in dataset update command and proper domain
exception thrown there, thus removing this extra check here.
We also have unique constraints at db layer for (db, schema, table) tuple
--
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]