mistercrunch commented on PR #26654:
URL: https://github.com/apache/superset/pull/26654#issuecomment-2137929403

   Thinking about this, I think I understand the issue better now, and it's not 
the same issue as the one I tackled in this PR
   
   Looking simply at this:
   ```python
   class TaggedObject(Model, AuditMixinNullable):
       """An association between an object and a tag."""
   
       __tablename__ = "tagged_object"
       id = Column(Integer, primary_key=True)
       tag_id = Column(Integer, ForeignKey("tag.id"))
       object_id = Column(
           Integer,
           ForeignKey("dashboards.id"),
           ForeignKey("slices.id"),
           ForeignKey("saved_query.id"),
       )
       object_type = Column(Enum(ObjectType))
   
       tag = relationship("Tag", back_populates="objects", overlaps="tags")
   ```
   there's nothing that clarifies the nature of the relationship being 
dependent on object_type. For sqlalchemy to properly cascade deletes here from 
dashboard or other object type, is has to apply a condition on object_type, 
which I'm guessing it doesn't. I really can't given that semantically we don't 
really tell it as we defined the model.
   
   In terms of solutions, there's either:
   - do some sqlalchemy kungfu to model/clarify the nature of the relationship 
do that cascade delete work as expected, this requires digging a bit deeper 
into sqlaclehmy semantics and seeing what's possible there
   - improve the DAOs / commands to delete tags proactively BEFORE deleting the 
objects, which means the delete CASCADE is effectively a no-op
   
   I think option #1 seems best AFAIC, if possible. 


-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to