fix(grid): allow deleting rows from DISTINCT join results

This commit is contained in:
zipg authored and GitHub committed 2026-09-02 11:18:44 +08:00
1 parent 103e221cc3
commit 10ac216964
2 files changed
+6 -2

No files matched your search

+5 -1
View File
@@ -4432,7 +4432,11 @@ export const useQueryStore = defineStore("query", () => {
const queryAnalysis = { const queryAnalysis = {
...target.analysis, ...target.analysis,
...(target.analysis.distinct && canInsertIntoEditableQuerySource(tab, dbType as DatabaseType, target, target.sourceColumns) ? { allowInsert: true } : {}), ...(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, allowInsertDelete: false,
multiSource: true, multiSource: true,
}; };
+1 -1
View File
@@ -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?.multiSource, true);
assert.equal(tab?.queryAnalysis?.distinct, true); assert.equal(tab?.queryAnalysis?.distinct, true);
assert.equal(tab?.queryAnalysis?.allowInsert, 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?.queryAnalysis?.allowInsertDelete, false);
assert.equal(tab?.tableMeta?.tableName, "users"); assert.equal(tab?.tableMeta?.tableName, "users");
assert.deepEqual(tab?.querySourceColumns, ["id", "name"]); assert.deepEqual(tab?.querySourceColumns, ["id", "name"]);