diegomedina248 opened a new pull request #19225: URL: https://github.com/apache/superset/pull/19225
### SUMMARY When the SQL Lab has the persistence enabled on the backend (`SQLLAB_BACKEND_PERSISTENCE`), the queries failed on delete in two cases: * From the Query History tab, if the query was the last executed. * From the Saved queries, if the query was the last executed in a tab. The issue is rooted in the `TabState` table, which has a foreign key to the saved query and to the latest executed one. So, we need to clear that relation before deleting the query. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF #### Query History Before: https://user-images.githubusercontent.com/17252075/158682064-793e824c-f29b-491f-bdf7-6b6d01918e2e.mp4 After: https://user-images.githubusercontent.com/17252075/158684980-93b09132-d1d4-4029-a6ea-10891d68a0f1.mov #### Saved Query Before: https://user-images.githubusercontent.com/17252075/158681766-eda7dbb2-9ffd-4f35-b703-17c9e2e0e138.mp4 After: https://user-images.githubusercontent.com/17252075/158685178-409ff966-c6a9-4179-9d77-30e44a79038b.mov ### TESTING INSTRUCTIONS Saved query: * Go to SQL editor * Input a valid sql query using examples or your own db * Run query and Save as a new query (don't close the saved query tab in SQL editor) * Go to "Saved queries" page * Try to delete the saved query * See the error Query History: * In SQL editor, run query * Navigate to query history * Click on trash icon ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- 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]
