john-bodley commented on code in PR #24488:
URL: https://github.com/apache/superset/pull/24488#discussion_r1239138419
##########
superset/datasets/commands/bulk_delete.py:
##########
@@ -40,35 +39,10 @@ def __init__(self, model_ids: list[int]):
def run(self) -> None:
self.validate()
- if not self._models:
- return None
+ assert self._models
+
try:
DatasetDAO.bulk_delete(self._models)
- for model in self._models:
Review Comment:
This is logic taken https://github.com/apache/superset/pull/24466.
Previously a test was failing because the relationship no longer existed in
Python after the commit. See
[here](https://docs.sqlalchemy.org/en/20/orm/cascades.html#notes-on-delete-deleting-objects-referenced-from-collections-and-scalar-relationships)
for details. The issue was that:
```python
DatasetDAO.bulk_delete(self._models)
```
includes a `db.session.commit()` in which all the attributes have expired.
I'm not really sure why this worked before, but the TL;DR is this logic has
been moved inside the DAO and is executed prior to the commit.
--
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]