25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(completion): avoid table fallback for aliases
t8y23a52d961fc3e
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vueindex 4e297b3e7d..da13cce455 100644--- a/apps/desktop/src/components/editor/QueryEditor.vue+++ b/apps/desktop/src/components/editor/QueryEditor.vue@@ -1117,7 +1117,7 @@ async function performAsyncCompletionWithResult(epoch: number, completionContext// If qualifier didn't match any table names, try it as a schema namelet qualifierIsSchema = false;- if (completionContext.qualifier && tables.length === 0 && (completionContext.suggestTables || completionContext.exclusiveColumnSuggestions)) {+ if (completionContext.qualifier && !isReferencedTableQualifier(completionContext) && tables.length === 0 && (completionContext.suggestTables || completionContext.exclusiveColumnSuggestions)) {const schemaTables = await connectionStore.listCompletionTables(props.connectionId!, props.database!, completionContext.prefix, MAX_COMPLETION_TABLES, completionContext.qualifier);if (schemaTables.length > 0) {tables = schemaTables;diff --git a/packages/app-tests/sqlCompletion.test.ts b/packages/app-tests/sqlCompletion.test.tsindex a6c4af88da..217a76fd17 100644--- a/packages/app-tests/sqlCompletion.test.ts+++ b/packages/app-tests/sqlCompletion.test.ts@@ -262,6 +262,46 @@ test("keeps explicit alias column suggestions scoped to the alias table", () =>);});+test("does not show table names after an explicit alias qualifier", () => {+ const sql = "select * from billing_owner b where b.";+ const items = buildSqlCompletionItems(sql, sql.length, {+ tables: [+ { name: "base_gateway_expand", schema: "BU", type: "table" },+ { name: "billing_owner", schema: "BU", type: "table" },+ ],+ columnsByTable: new Map(),+ });++ assert.deepEqual(items, []);+});++test("suggests columns after an explicit alias qualifier without leaking tables", () => {+ const sql = "select * from billing_owner b where b.";+ const items = buildSqlCompletionItems(sql, sql.length, {+ tables: [+ { name: "base_gateway_expand", schema: "BU", type: "table" },+ { name: "billing_owner", schema: "BU", type: "table" },+ ],+ columnsByTable: new Map([+ [+ "BU.billing_owner",+ [+ { name: "owner_id", table: "billing_owner", schema: "BU", dataType: "number" },+ { name: "owner_name", table: "billing_owner", schema: "BU", dataType: "varchar" },+ ],+ ],+ ]),+ });++ assert.deepEqual(+ items.map((item) => [item.label, item.type, item.detail]),+ [+ ["owner_id", "column", "BU.billing_owner [number]"],+ ["owner_name", "column", "BU.billing_owner [varchar]"],+ ],+ );+});+test("shows column comments in WHERE field completions", () => {const sql = "select * from public.orders where st";const items = buildSqlCompletionItems(sql, sql.length, {