Skip to content
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

BUG: Run Current doesn't work as expected when there's only one query. #760

Open
ApproachingApathy opened this issue Apr 26, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ApproachingApathy
Copy link

ApproachingApathy commented Apr 26, 2024

Describe the bug
When there is only one query in the buffer, "Run Current" will run the current line instead of the current query.

To Reproduce
Steps to reproduce the behavior:

  1. Open a new query.
  2. Create a single multiline query.
  3. Trigger Run Current
  4. DbGate will send the individual line that the cursor is on instead of the entire query, usually resulting in a syntax error.

Expected behavior
The entire query should be run. "Current" should mean the current query, and DbGate should send the entire multiline query to the DB to execute. II previously asked about this issue in #743 But have sinced realized that it only occurs when there is only one query.

Screenshots
If applicable, add screenshots to help explain your problem.
2024-05-08T11:54:32-screenshot
Run current when cursor is on line 4.

2024-05-08T11:54:53-screenshot
Run current with same query highlighted.

2024-05-08T12:15:28-screenshot
Run current behaves correctly when there are multiple queries.

Version Information (please complete the following information):

  • OS: Linux Arch
  • App Version: 5.2.7
  • Install source: AUR
  • Type: Application
  • Database engine: PostgresSQL
@ApproachingApathy ApproachingApathy changed the title BUG: Run Current doesn't work when there's only one query. BUG: Run Current doesn't work as expected when there's only one query. Apr 26, 2024
@ProjectInfinity
Copy link
Collaborator

Hmm yes that sounds like a bug. Execute current should ideally execute the currently highlighted query, even if it does span across multiple lines.

@ProjectInfinity ProjectInfinity added the bug Something isn't working label Apr 29, 2024
@janproch
Copy link
Member

janproch commented May 8, 2024

From my point of view, running only current line is more flexible and more safe solution. It could be use also in case of more single-line queries

If user needs to run the entire query, he could use "Run" command

@ApproachingApathy
Copy link
Author

From my point of view, running only current line is more flexible and more safe solution. It could be use also in case of more single-line queries

If user needs to run the entire query, he could use "Run" command

If this behavior is chosen, I would expect it to be consistent. Currently, buffers with multiple queries behave as expected, where run current runs the current query. This is also how every DB client I've used behaves, and IMO is much more useful than the alternative.

I've added some screenshots to show what's happening.

@janproch
Copy link
Member

janproch commented May 8, 2024

I understand your point

However, I am not sure that running entire query is safe. There is possibility, that query uses some nonstandard delimiters and dbgate's detection of query segments will result into one query. Then running the entire query could cause some damage, if user expects running of query part.

Safe option could be to ask user, whether to run the entire query, when no parts were detected and he will execute "Run current" command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants