diegomedina248 commented on a change in pull request #19225:
URL: https://github.com/apache/superset/pull/19225#discussion_r828705104



##########
File path: superset/views/sql_lab.py
##########
@@ -228,6 +229,29 @@ def migrate_query(  # pylint: disable=no-self-use
     def delete_query(  # pylint: disable=no-self-use
         self, tab_state_id: int, client_id: str
     ) -> FlaskResponse:
+        # Before deleting the query, ensure it's not tied to any
+        # active tab as the last query. If so, replace the query
+        # with the latest one created in that tab
+        tab_state_query = db.session.query(TabState).filter_by(

Review comment:
       We could also set the `latest_query_id` to NULL, the same as 
`saved_query_id`, if we don't care about reassign the latest query.




-- 
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]

Reply via email to