dbgate icon indicating copy to clipboard operation
dbgate copied to clipboard

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

Open ApproachingApathy opened this issue 10 months ago • 4 comments

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 avatar Apr 26 '24 18:04 ApproachingApathy

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 avatar Apr 29 '24 17:04 ProjectInfinity

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

janproch avatar May 08 '24 15:05 janproch

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.

ApproachingApathy avatar May 08 '24 17:05 ApproachingApathy

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

janproch avatar May 08 '24 17:05 janproch