[Bug] Query editor Ctrl/Cmd+click misses derived-table aliases and treats a table alias as a database
Bug Description
Ctrl/Cmd+click in the query editor does not resolve two common SQL aliases the way DataGrip does.
- A bare output column of a derived table (
FROM (SELECT ...) alias) does not jump back to that column's definition. - On MySQL, an alias-qualified column such as
o.created_dateis treated asdatabase.table. The editor tries to open a table named after the alias (o) and fails because that object does not exist.
This is a gap in the editor's own click navigation, not a MySQL dialect rule and not the Rust sqlparser path. Hover already checks whether a qualifier is a table alias; click navigation does not.
Steps to Reproduce
- Open a MySQL query editor.
- Paste the SQL below.
- Ctrl/Cmd+click the outer
amount_index. - Ctrl/Cmd+click
created_dateino.created_date >= '2026-11-01'.
SELECT amount_index,
amount_month,
amount_last_month
FROM (SELECT src.total AS amount_index,
sum(c.amount) AS amount_month
FROM orders o
LEFT JOIN charges c ON o.id = c.order_id
WHERE o.created_date >= '2026-11-01') t1
LEFT JOIN (SELECT sum(c.amount) AS amount_last_month
FROM orders o
LEFT JOIN charges c ON o.id = c.order_id
WHERE o.created_date >= '2026-10-01') t2 ON 1 = 1;
Expected Behavior
- Ctrl/Cmd+click on the outer
amount_indexjumps tosrc.total AS amount_indexinside derived tablet1. - Ctrl/Cmd+click on
created_dateino.created_dateopens the DDL of the real tableorders, becauseois that table's alias. - The same alias inside
t2resolves to that subquery'sorders, not a table namedo. - A name produced by more than one derived table should not jump to an arbitrary definition.
Actual Behavior
- Clicking the outer
amount_indexdoes not jump to its definition. - Clicking
o.created_datetries to open a non-existent tableoand errors out.
Cause
Query-editor Ctrl/Cmd+click uses the desktop semantic scanner, not Rust sqlparser.
- Derived tables outside a
WITHclause record output names but not the span ofAS <alias>. Jump targets are only built for CTE outputs, soFROM (SELECT ...) t1has nothing to jump to. That metadata was intentionally left off the common path. - MySQL is not a schema-qualified dialect, so a two-part name is parsed as
database.tablebefore alias lookup.o.created_datetherefore becomes databaseo, tablecreated_date. Hover already rejects a qualifier that is a known table alias; click navigation does not.
Relevant code:
apps/desktop/src/components/editor/useQueryEditorObjectNavigation.tsapps/desktop/src/lib/sql/semantic/model.ts(parseSubquerySource, CTE-only derived-table enrichment)apps/desktop/src/lib/sql/semantic/cteNavigation.tsapps/desktop/src/lib/editor/hoverTableLookup.tsapps/desktop/src/lib/sql/queryCursorTableTarget.ts
Why this is not a plugin
The current plugin contribution points are connection, workbench, context menu, result view, command, and MCP. None of them can replace the query editor's click resolver or attach a jump span to a derived-table output. Fixing this needs a host change, or a new editor-navigation extension point.
Environment
- Database: MySQL (two-part names are
database.table; no schema level) - Source:
main@b6d611ab0(v0.6.75) - OS / runtime: not captured from the app's About panel. Reproduced from the query-editor navigation code, not from a packaged build log.
Priority
P2. Query editing still works; only declaration navigation is wrong, and the alias case opens a missing object.
/claim
✅ @imcman 已认领 #15731,开始处理吧!