-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sql lab): deleting the last saved query or the last executed from history #19225
fix(sql lab): deleting the last saved query or the last executed from history #19225
Conversation
1972421
to
04550d3
Compare
# 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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
04550d3
to
776a96f
Compare
This looks good! Ping me when the tests are passing because I wanna do some frontend testing on it :) |
776a96f
to
db20638
Compare
Codecov Report
@@ Coverage Diff @@
## master #19225 +/- ##
==========================================
- Coverage 66.76% 66.59% -0.18%
==========================================
Files 1670 1670
Lines 64392 64397 +5
Branches 6499 6499
==========================================
- Hits 42991 42884 -107
- Misses 19718 19830 +112
Partials 1683 1683
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
db20638
to
a1e2c11
Compare
/testenv up FEATURE_SQLLAB_BACKEND_PERSISTENCE=True |
@AAfghahi Ephemeral environment spinning up at http://54.218.227.72:8080. Credentials are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thank you!
Ephemeral environment shutdown and build artifacts deleted. |
🏷️ preset:2022.11 |
SUMMARY
When the SQL Lab has the persistence enabled on the backend (
SQLLAB_BACKEND_PERSISTENCE
), the queries failed on delete in two cases: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:
CleanShot.2021-05-19.at.22.12.13.mp4
After:
Screen.Recording.2022-03-16.at.17.27.35.mov
Saved Query
Before:
Saved.query.mp4
After:
Screen.Recording.2022-03-16.at.17.28.42.mov
TESTING INSTRUCTIONS
Saved query:
Query History:
ADDITIONAL INFORMATION