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(grid): allow deleting rows from DISTINCT join results

zipg10ac216964dc
diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.ts
index e54dd2b10d..a286bd5761 100644
--- a/apps/desktop/src/stores/queryStore.ts
+++ b/apps/desktop/src/stores/queryStore.ts
@@ -4432,7 +4432,11 @@ export const useQueryStore = defineStore("query", () => {
const queryAnalysis = {
...target.analysis,
...(target.analysis.distinct && canInsertIntoEditableQuerySource(tab, dbType as DatabaseType, target, target.sourceColumns) ? { allowInsert: true } : {}),
- allowDelete: !target.analysis.distinct,
+ // A DISTINCT result is still one-to-one with the selected source row
+ // when that source's complete primary key is present in the projection.
+ // The candidate filter above guarantees that identity before enabling
+ // the primary-key based delete SQL.
+ allowDelete: true,
allowInsertDelete: false,
multiSource: true,
};
diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.ts
index 47ab2e7a45..ad7d3f271a 100644
--- a/packages/app-tests/queryStore.test.ts
+++ b/packages/app-tests/queryStore.test.ts
@@ -3438,7 +3438,7 @@ test("binds DISTINCT qualified-star edits to the single safe joined source", asy
assert.equal(tab?.queryAnalysis?.multiSource, true);
assert.equal(tab?.queryAnalysis?.distinct, true);
assert.equal(tab?.queryAnalysis?.allowInsert, true);
- assert.equal(tab?.queryAnalysis?.allowDelete, false);
+ assert.equal(tab?.queryAnalysis?.allowDelete, true);
assert.equal(tab?.queryAnalysis?.allowInsertDelete, false);
assert.equal(tab?.tableMeta?.tableName, "users");
assert.deepEqual(tab?.querySourceColumns, ["id", "name"]);