Skip to content

Ability to run multiple statements #352

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

Merged
merged 12 commits into from
Mar 17, 2025
Merged

Ability to run multiple statements #352

merged 12 commits into from
Mar 17, 2025

Conversation

worksofliam
Copy link
Contributor

@worksofliam worksofliam commented Mar 15, 2025

This adds new options under the play button.

Shown when there is no selection:

  • Run all statements in the editor
  • Run all statements from cursor

Shown when there is a selection:

  • Run selected statements

This will execute all statements, but only show the result set for the last statement. Prefixes like cl, csv, etc, are still allowed and will work as they do when running single statements.

If a statement is execute and it errors, then no more statements will be executed.

If you use stop, then the statement execution will stop.

Signed-off-by: worksofliam <mrliamallan@live.co.uk>
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
@worksofliam worksofliam linked an issue Mar 15, 2025 that may be closed by this pull request
Copy link

github-actions bot commented Mar 15, 2025

👋 A new build is available for this PR based on 67644d2.

Copy link
Collaborator

@julesyan julesyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of issues and questions I have run into so far:

  • For run selected:
    • does not work for partial selection, i get "No statements to run". I expect it to automatically pick up the two statements because there are two statements highlighted, regardless if it is fully highlighted
      image
    • similar, if i highlight a full statement but partially highlight another statement, it will only run the fully highlighted statement. Similar to above I expect it to run both
      image
  • General:
    • when an error happens in one of the statements it produces both a pop up error and an error in the IBM i view. Not sure if that was intended, but a bit annoying as a user. If I already have the error in the window, I do not need a notification as well. Can discuss furthur if you disagree
    • Why cant run all and run from cursor also be options when things are selected?
    • Not sure if this is something you want to implement, but since we have the syntax checking, if there are any errors, maybe we shouldnt be allowed to run all? The only caveat being if its actual valid syntax and the checker is incorrect. If so then maybe we can give a warning that "the syntax is incorrect, would you like to still run all".
    • if a statement is taking awhile, and i happen to edit the file while i wait, will that break the upcoming statement? Or are we saving the statements before we start the whole run?

In better news, I like that it highlights which statement is currently running!

@julesyan
Copy link
Collaborator

Adding on, it does seem like you are saving the statements, not sure how that works when a file is edited though (is the get of the document a snapshot?).
Is there a reason we cannot run CL commands in the multiple?

Signed-off-by: worksofliam <mrliamallan@live.co.uk>
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
@worksofliam
Copy link
Contributor Author

@julesyan

  • For run selected, it will now correctly select the statements without the entire statement needing to be encapsulated in the selection range.
  • The popup error is gone. Didn't realize double errors were appearing during my testing.
  • Run all is now always shown, but Run from selected is still only available when no selection is made
  • cl: now correctly throws an error when it doesn't run correctly.
  • No plans to do anything with syntax checking enablement. You can still run single statements even if the syntax is invalid.

If you edit a document while it is running the statements, they will run as the statements were run it was initiated, but the ranges may be incorrect when it comes around the the next statement being executed is selected. We could add some logic to re-parse the document after every statement is run to grab the current changes.. though that might be slow for very very large documents.

@forstie
Copy link
Collaborator

forstie commented Mar 15, 2025

  1. When run from or run all are in motion, can we have the "Cancel SQL" thing permitted?
  2. Do you think some users will want key short-cuts for the new RUN actions?
  3. When you code a stop; after a query, VS incorrectly says that the query is "still running".

image

--
-- Watch compare progress / activity  
--
SELECT *
   FROM TABLE (
         qsys2.active_job_info(
            job_name_filter => 'IFSCOMP', subsystem_list_filter => 'QBATCH')
      );
stop; 

Signed-off-by: worksofliam <mrliamallan@live.co.uk>
@worksofliam
Copy link
Contributor Author

@forstie New build is coming.

  1. Fixed
  2. Not sure yet...
  3. Also fixed 😄

@worksofliam worksofliam requested a review from julesyan March 15, 2025 23:08
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
@julesyan
Copy link
Collaborator

If you edit a document while it is running the statements, they will run as the statements were run it was initiated, but the ranges may be incorrect when it comes around the the next statement being executed is selected. We could add some logic to re-parse the document after every statement is run to grab the current changes.. though that might be slow for very very large documents.

I think if you just pre-parse all the statements out, then run it all, that should avoid accidentally messing up the run. I dont think we should reparse the document and pick up new changes, that seems unnecessary overhead. Essentially just run it as a snapshot of when the button was hit

@julesyan
Copy link
Collaborator

Aside from the issue with CL vs cl, looks good!

Signed-off-by: worksofliam <mrliamallan@live.co.uk>
@worksofliam
Copy link
Contributor Author

@julesyan A new commit is in to make the prefixes case insensitive.

@forstie
Copy link
Collaborator

forstie commented Mar 16, 2025

Everything is looking super now. Thanks for the adjustments!

@forstie forstie self-requested a review March 16, 2025 16:04
Copy link
Collaborator

@forstie forstie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent.

Signed-off-by: worksofliam <mrliamallan@live.co.uk>
@worksofliam worksofliam requested a review from forstie March 16, 2025 17:17
@forstie
Copy link
Collaborator

forstie commented Mar 16, 2025

Run Selected works correctly after the change, thank you

Copy link
Collaborator

@forstie forstie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
The only thing to consider is short cuts to these great new actions.

@worksofliam worksofliam merged commit 0d509d7 into main Mar 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question... Run all/ Run from Selected/ Run Selected...
3 participants