fix(query): stop unsupported SQL Server page retries
This commit is contained in:
parent
e25f2c762f
commit
d9018091c7
|
|
@ -930,4 +930,41 @@ describe("queryStore hidden primary key editing", () => {
|
|||
await vi.waitFor(() => expect(tab.resultTotalRowCount).toBe(123));
|
||||
expect(tab.resultTotalRowCountLoading).toBe(false);
|
||||
});
|
||||
|
||||
it("stops appending when a SQL Server query has no bounded next-page plan", async () => {
|
||||
getConnectionConfig.mockReturnValue({ id: "sqlserver-1", name: "SQL Server", db_type: "sqlserver", database: "app", query_timeout_secs: 30 });
|
||||
analyzeEditableQueryEditability.mockResolvedValue({ editable: false, reason: "complex-query" });
|
||||
const rows = Array.from({ length: 28 }, (_, index) => [index + 1]);
|
||||
executeMulti.mockResolvedValueOnce([
|
||||
{
|
||||
columns: ["id"],
|
||||
rows,
|
||||
affected_rows: 28,
|
||||
execution_time_ms: 1,
|
||||
has_more: true,
|
||||
},
|
||||
]);
|
||||
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
const tabId = store.createTab("sqlserver-1", "app", "Query");
|
||||
const sql = "SELECT a.id, b.* FROM orders a JOIN order_details b ON b.order_id = a.id";
|
||||
|
||||
await store.executeTabSql(tabId, sql);
|
||||
expect(executeMulti).toHaveBeenCalledTimes(1);
|
||||
|
||||
await store.executeTabSql(tabId, sql, {
|
||||
resultBaseSql: sql,
|
||||
pagination: { limit: 25, offset: 28 },
|
||||
appendResult: { maxRows: 10_000 },
|
||||
preserveResultDuringExecution: true,
|
||||
preserveTotalRowCountDuringExecution: true,
|
||||
replaceActiveResultInGroup: true,
|
||||
});
|
||||
|
||||
const tab = store.tabs.find((item) => item.id === tabId)!;
|
||||
expect(executeMulti).toHaveBeenCalledTimes(1);
|
||||
expect(tab.result?.rows).toEqual(rows);
|
||||
expect(tab.result?.has_more).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3850,6 +3850,21 @@ export const useQueryStore = defineStore("query", () => {
|
|||
pageOffset = plan.pageOffset;
|
||||
countSql = plan.countSql;
|
||||
useAgentResultSession = plan.useAgentResultSession;
|
||||
const hasBoundedPagination = typeof pageLimit === "number" && typeof pageOffset === "number";
|
||||
if (options?.appendResult && !hasBoundedPagination && !useAgentResultSession) {
|
||||
const current = tabs.value.find((item) => item.id === id);
|
||||
if (current?.executionId === executionId && current.result) {
|
||||
current.result.has_more = false;
|
||||
const activeResultIndex = current.activeResultIndex;
|
||||
if (Array.isArray(current.results) && typeof activeResultIndex === "number" && activeResultIndex >= 0 && activeResultIndex < current.results.length) {
|
||||
current.results[activeResultIndex]!.has_more = false;
|
||||
}
|
||||
touchResult(current);
|
||||
syncDisplayedResultRun(current, queryBaseSql, openInNewResultTab);
|
||||
}
|
||||
queryExecutionLog("info", "append-result:pagination-unsupported", { traceId, elapsed: elapsed() });
|
||||
return false;
|
||||
}
|
||||
} else if (tab.mode === "data") {
|
||||
pageLimit = options?.pagination?.limit ?? tableOpenPageLimit(settingsStore.editorSettings.tableOpenPageSize);
|
||||
pageOffset = options?.pagination?.offset ?? 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue