Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(completion): show column comments inline in SQL completions

t8y2b42ad91fc2dc
diff --git a/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts b/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts
index a5914fb92d..2bec0f86df 100644
--- a/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts
+++ b/apps/desktop/src/lib/__tests__/sql/semantic/completion.spec.ts
@@ -60,6 +60,15 @@ describe("semantic SQL completion candidates", () => {
expect(items.filter((item) => item.type === "column").map((item) => item.label)).not.toContain("legacy_id");
});
+ it("shows the column comment inline in the completion detail", () => {
+ const columnsByTable = new Map<string, SqlCompletionColumn[]>([["users", [{ name: "nickname", table: "users", schema: "public", dataType: "text", comment: "用户昵称" }]]]);
+
+ const { items } = semanticCompletion("SELECT nick| FROM users", { columnsByTable }, { databaseType: "postgres", dialect: "postgres" });
+
+ const nickname = items.find((item) => item.type === "column" && item.label === "nickname");
+ expect(nickname?.detail).toContain("-- 用户昵称");
+ });
+
it("ignores line-comment semicolons after a real statement boundary", () => {
const columnsByTable = new Map<string, SqlCompletionColumn[]>([
["codex_completion_a", [{ name: "legacy_id", table: "codex_completion_a", schema: "public" }]],
diff --git a/apps/desktop/src/lib/sql/sqlCompletion.ts b/apps/desktop/src/lib/sql/sqlCompletion.ts
index 4bb76847dc..63d497860c 100644
--- a/apps/desktop/src/lib/sql/sqlCompletion.ts
+++ b/apps/desktop/src/lib/sql/sqlCompletion.ts
@@ -4608,6 +4608,13 @@ function buildColumnDetail(column: SqlCompletionColumn): string {
if (column.isNullable === false) {
detail += " NOT NULL";
}
+ // Surface the column comment inline in the completion row (e.g. Chinese
+ // field notes) so it shows without opening the side info panel. This was
+ // dropped when qualified completion queries were optimized; keep it here.
+ const comment = column.comment?.trim();
+ if (comment) {
+ detail += ` -- ${comment}`;
+ }
return detail;
}