fix(sqlserver): handle query timeout and multi-result-set pagination
* Fix SQL Server query timeout and result pagination * Address SQL Server timeout review feedback * Cover SQL Server lock wait timeout --------- Co-authored-by: zipg <4047349+zipg@users.noreply.github.com>
This commit is contained in:
1 parent
3a9bdc1cf6
commit
f73633f622
5 files changed
+216
-25
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { queryResultBaseSql, queryResultExecutionSql } from "@/lib/tabs/tabPresentation";
|
||||
import type { QueryTab } from "@/types/database";
|
||||
|
||||
function queryTab(overrides: Partial<QueryTab>): QueryTab {
|
||||
return {
|
||||
id: "tab-1",
|
||||
title: "SQL",
|
||||
connectionId: "conn-1",
|
||||
database: "db",
|
||||
sql: "SELECT * FROM dbo.first;\nSELECT * FROM dbo.second;",
|
||||
originalSql: "",
|
||||
isExecuting: false,
|
||||
isCancelling: false,
|
||||
isExplaining: false,
|
||||
mode: "query",
|
||||
...overrides,
|
||||
} as QueryTab;
|
||||
}
|
||||
|
||||
describe("query result SQL selection", () => {
|
||||
it("uses the active result source statement for multi-result query actions", () => {
|
||||
const tab = queryTab({
|
||||
resultBaseSql: "SELECT * FROM dbo.first;\nSELECT * FROM dbo.second;",
|
||||
result: {
|
||||
columns: ["id"],
|
||||
rows: [[1]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
sourceStatement: "SELECT * FROM dbo.second",
|
||||
},
|
||||
});
|
||||
|
||||
expect(queryResultBaseSql(tab)).toBe("SELECT * FROM dbo.second");
|
||||
expect(queryResultExecutionSql(tab)).toBe("SELECT * FROM dbo.second");
|
||||
});
|
||||
|
||||
it("prefers the sorted SQL when the active result is sorted", () => {
|
||||
const tab = queryTab({
|
||||
resultSortedSql: "SELECT * FROM dbo.second ORDER BY id DESC",
|
||||
result: {
|
||||
columns: ["id"],
|
||||
rows: [[2]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
sourceStatement: "SELECT * FROM dbo.second",
|
||||
},
|
||||
});
|
||||
|
||||
expect(queryResultBaseSql(tab)).toBe("SELECT * FROM dbo.second");
|
||||
expect(queryResultExecutionSql(tab)).toBe("SELECT * FROM dbo.second ORDER BY id DESC");
|
||||
});
|
||||
});
|
||||
@@ -150,6 +150,14 @@ export function resultSqlForGrid(tab: Pick<QueryTab, "result" | "resultBaseSql"
|
||||
return tab.result?.sourceStatement || tab.resultBaseSql || tab.lastExecutedSql || tab.sql;
|
||||
}
|
||||
|
||||
export function queryResultBaseSql(tab: Pick<QueryTab, "result" | "resultBaseSql" | "lastExecutedSql" | "sql">): string {
|
||||
return resultSqlForGrid(tab);
|
||||
}
|
||||
|
||||
export function queryResultExecutionSql(tab: Pick<QueryTab, "result" | "resultBaseSql" | "resultSortedSql" | "lastExecutedSql" | "sql">): string {
|
||||
return tab.resultSortedSql || resultSqlForGrid(tab);
|
||||
}
|
||||
|
||||
export function tabularResultItems(results: QueryResult[] | undefined): { result: QueryResult; index: number; n: number; label?: string; title?: string }[] {
|
||||
if (!results) return [];
|
||||
return results
|
||||
|
||||
Reference in new issue
Block a user