feat(sqllab): Allow running query without highlighting the code #27314
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
When a user enters multiple queries in one tab and wants to execute each of them, they would have to highlight the SQL they want to execute (in previous versions), which would not be ideal for extremely long queries. To solve this problem, I created the getCurrentQuery function to allow executing each query without the need to highlight the specific query they wish to run. Instead, users can place the cursor at the intended query and press the RUN button.
It's important to note that queries must be separated by either at least one blank line or a semicolon, and no blank lines are allowed within the same query. When the cursor is placed at the blank lines between two queries, the upper query will be executed. This also handles the case when a semicolon is part of the query.
This function was actually created a long time ago, and I found that in newer versions, there already exists a shortcut key to execute the current query. I wanted to share this implementation in case it might be useful or maybe created as another shortcut key.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
Screen.Recording.2567-03-01.at.10.11.04.mov
After
Screen.Recording.2567-03-01.at.10.15.23.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION