diff --git a/apps/desktop/src/composables/__tests__/useDataGridActions.spec.ts b/apps/desktop/src/composables/__tests__/useDataGridActions.spec.ts index 7fffba43d6..0c7c9b52b3 100644 --- a/apps/desktop/src/composables/__tests__/useDataGridActions.spec.ts +++ b/apps/desktop/src/composables/__tests__/useDataGridActions.spec.ts @@ -167,6 +167,20 @@ describe("useDataGridActions", () => { expect(mocks.executeTabSql.mock.calls[0]?.[2]).not.toHaveProperty("preserveTotalRowCountDuringExecution"); }); + it("executes the WHERE apply SQL on the emitting tab (#8216)", async () => { + // ContentArea 的 executeSql 事件契约是 (tabId, sql),App.vue 按此顺序透传; + // 签名若仍是 sql-first,resolveActionTab 会拿 SQL 文本当 tab id 匹配失败, + // 数据页筛选应用就静默不执行任何查询(只剩手动刷新可用)。 + const tab = tableDataTab(); + mocks.tabs.push(tab); + const actions = useDataGridActions(computed(() => tab)); + + await actions.onExecuteSql(tab.id, "SELECT * FROM public.users WHERE (status = 'active')"); + + expect(mocks.updateSql).toHaveBeenCalledWith("tab-1", "SELECT * FROM public.users WHERE (status = 'active')"); + expect(mocks.executeTabSql).toHaveBeenCalledWith("tab-1", "SELECT * FROM public.users WHERE (status = 'active')", { preserveResultDuringExecution: true }); + }); + it("keeps the restored filter and sort when the no-data placeholder refresh runs (#7963)", async () => { // 重启后恢复的数据标签页没有 result,刷新走的是 ContentArea 空态占位符那条 // 不带参数的入口;它必须回带标签页自身的 whereInput/orderByInput, diff --git a/apps/desktop/src/composables/useDataGridActions.ts b/apps/desktop/src/composables/useDataGridActions.ts index 4e83dabf10..6052674731 100644 --- a/apps/desktop/src/composables/useDataGridActions.ts +++ b/apps/desktop/src/composables/useDataGridActions.ts @@ -177,7 +177,7 @@ export function useDataGridActions(activeTab: ComputedRef) return true; } - async function onExecuteSql(sql: string, tabId?: string) { + async function onExecuteSql(tabId: string, sql: string) { const tab = resolveActionTab(tabId); if (!tab) return; queryStore.updateSql(tab.id, sql);