fix(query): show SQL Server notices outside result-set tabs
Closes #9166
This commit is contained in:
11 files changed
+188
-12
No files matched your search
@@ -429,8 +429,8 @@ GO`;
|
||||
|
||||
await execution.tryExecute();
|
||||
|
||||
expect(activeOutputView.value).toBe("result");
|
||||
expect(activeTab.value?.result?.rows).toEqual([["x"]]);
|
||||
expect(activeOutputView.value).toBe("messages");
|
||||
});
|
||||
|
||||
it("keeps a SQL Server data result selected when a trailing message result exists", async () => {
|
||||
|
||||
@@ -100,6 +100,31 @@ describe("SQL Server result focus: doExecute vs executeTargetSql", () => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
it("opens message-only executeTargetSql output in the messages view", async () => {
|
||||
const tab = { ...queryTab(), sql: "PRINT N'x'" };
|
||||
const connection = sqlServerConnection();
|
||||
const activeOutputView = ref<"result" | "summary" | "explain" | "chart" | "messages">("result");
|
||||
const queryStore = useQueryStore();
|
||||
const { messageResult } = sqlServerMessageFirstResults();
|
||||
vi.spyOn(queryStore, "executeTabSql").mockImplementation(async () => {
|
||||
tab.result = messageResult;
|
||||
return true;
|
||||
});
|
||||
vi.spyOn(queryStore, "getExecutionTab").mockReturnValue(tab);
|
||||
vi.spyOn(useHistoryStore(), "add").mockResolvedValue(undefined);
|
||||
const execution = useSqlExecution({
|
||||
activeTab: computed(() => tab as QueryTab | undefined),
|
||||
activeConnection: computed(() => connection),
|
||||
executableSql: computed(() => tab.sql),
|
||||
activeOutputView,
|
||||
});
|
||||
|
||||
await execution.executeTargetSql({ tab, connection, sql: tab.sql });
|
||||
|
||||
expect(activeOutputView.value).toBe("messages");
|
||||
expect(tab.result?.rows).toEqual([["x"]]);
|
||||
});
|
||||
|
||||
// ---- control: the single-connection editor path (fixed by be3336c1e) ----
|
||||
it("CONTROL doExecute re-focuses the real data result when a message result was selected", async () => {
|
||||
const sql = "PRINT N'x'; SELECT 1 AS value;";
|
||||
|
||||
@@ -418,11 +418,11 @@ export function useSqlExecution(deps: {
|
||||
if (sqlServerMessageResultIndex !== undefined && sqlServerMessageResultIndex >= 0) {
|
||||
focusSqlServerDataResult(tab.id, executionDatabaseType, tab);
|
||||
if (executionTabStillActive) {
|
||||
deps.activeOutputView.value = "result";
|
||||
deps.activeOutputView.value = tab.result?.server_message === true ? "messages" : "result";
|
||||
}
|
||||
} else if (executionDatabaseType === "sqlserver" && tab.result?.server_message === true) {
|
||||
if (executionTabStillActive) {
|
||||
deps.activeOutputView.value = "result";
|
||||
deps.activeOutputView.value = "messages";
|
||||
}
|
||||
} else if (tab.result && !tab.result.columns.length && !tab.results?.some((result) => result.columns.length > 0)) {
|
||||
if (executionTabStillActive) {
|
||||
@@ -607,7 +607,7 @@ export function useSqlExecution(deps: {
|
||||
// 跳动(闪烁/竞态)。worker 结果已由 captureMultiDbExecutionWorkerResult 记录
|
||||
// 到 source tab 的 result run 并通过 projectResultRun 投影显示,无需再切主视图。
|
||||
if (!workerId && deps.activeTab.value?.id === tab.id) {
|
||||
deps.activeOutputView.value = success && (latest.result?.columns.length || latest.results?.some((result) => result.columns.length)) ? "result" : "summary";
|
||||
deps.activeOutputView.value = success && latest.result?.server_message === true ? "messages" : success && (latest.result?.columns.length || latest.results?.some((result) => result.columns.length)) ? "result" : "summary";
|
||||
}
|
||||
return finish(success ? { status: "success", errorMessage } : { status: "failed", errorMessage });
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user