fix(sqllab): run previous state query #29230
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
A rare bug has occurred in SQL Lab where queries from the previous state are being executed.
This bug happens because SQL Lab no longer unmounts the ace editor when tabs are changed.
As a result, the state before the tab change is hoisted in the editor's shortcut callback function, causing it to request the previous state's query.
This commit addresses the issue by ensuring that the latest query state from Redux is always passed.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
before--out-of-update-query.mov
After:
after--out-of-update-query.mov
TESTING INSTRUCTIONS
Go to SQL Lab and then open a new tab from the existing tab
Select a different database option from the previous cloned option
Type any sql in the editor and then hit run
Switch to the previous tab and then make a selection in the sql editor
Switch back to the new tab and then click the sql editor to focus in the editor and then hit "Ctrl + Enter" to run query via shortcut
Please check the query run with the editor's state (not the default sql, SELECT ...)
ADDITIONAL INFORMATION