dbeaver / dbeaver/dbeaver

Use adaptive selection with Ctrl+A to mark current statement/query/script

Open
#17,723 4 comments 0 reactions 1 assignee Claimed by @E1izabeth View on GitHub
sp:3 xf:sql
Dominant language
Java
Stars
51.8k
Forks
4.4k
Avg merge
3d 8h
Merged PRs (30d)
188

Description

**Is your feature request related to a problem? Please describe.**
I feel one does often need to copy sub-statements from other queries/CTEs. It would be really convenient if there was a way to quickly mark the current statement/query/script based on the position of the cursor inside the editor.
E.g. if you have this in your editor:
```sql
WITH island_base AS -- Get the base table with all relevant cols and add sorted lag and lead helper columns
(
SELECT
pch.ModifiedDate,
pch.ProductID,
pch.StandardCost,
LEAD(ModifiedDate) OVER (PARTITION BY ProductID ORDER BY ModifiedDate) AS lead,
LAG(ModifiedDate) OVER (PARTITION BY ProductID ORDER BY ModifiedDate) AS lag,
ROW_NUMBER() OVER (PARTITION BY ProductID ORDER BY ModifiedDate) AS island_location
FROM
Production.ProductCostHistory AS pch
),
island_start AS -- Compare previous row with current one, if delta is bigger then 1 this line is the start of an island and gets and island number
(
SELECT
ROW_NUMBER() OVER (PARTITION BY ProductID ORDER BY ModifiedDate) AS island_number,
ProductID,
ModifiedDate AS island_date_start,
island_location AS island_loc_start
FROM
island_base
WHERE DATEDIFF(DAY, lag, ModifiedDate) > 1 OR lag IS NULL
),
[Rest of current query]
;

SELECT
[Some other sql statement]
;
```

**Describe the solution you'd like**
When you have the cursor inside a complete statement and press Ctrl+A depending on how often you press it different parts should be marked (Comparable to the double/triple mouse click selection of words and paragraphs in word processors):

1. Only the statement at the current cursor position is selected
2. Selects the current query including a seperator like ";"
3. Select complete script

**Describe alternatives you've considered**
Alternatively one could consider a mark statement/paragraph/script toogle button that a shortcut could be assigned to.

**Additional context**
GIF simulation with mouse selection:
![Simulated_Demonstration](https://user-images.githubusercontent.com/8171872/192155087-7b231535-9e11-42f0-9ee1-170f7498fed2.gif)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.