fix(sql lab): deleting the last saved query or the last executed from history (#19225)

* fix: fix issue when deleting the last saved query or the last executed query

* merge migration
This commit is contained in:
Diego Medina
2022-03-17 17:01:18 -04:00
committed by GitHub
parent 51061f0d67
commit aa5c80bda6
3 changed files with 93 additions and 1 deletions

View File

@@ -291,7 +291,9 @@ class TabState(Model, AuditMixinNullable, ExtraJSONMixin):
hide_left_bar = Column(Boolean, default=False)
# any saved queries that are associated with the Tab State
saved_query_id = Column(Integer, ForeignKey("saved_query.id"), nullable=True)
saved_query_id = Column(
Integer, ForeignKey("saved_query.id", ondelete="SET NULL"), nullable=True
)
saved_query = relationship("SavedQuery", foreign_keys=[saved_query_id])
def to_dict(self) -> Dict[str, Any]: