mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-20 00:17:44 +00:00
fix(query): avoid preflight probes for Oracle and PostgreSQL
Refs: #9960
This commit is contained in:
@@ -340,6 +340,37 @@ describe("queryStore multi-statement errors", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["oracle", "postgres"])("skips the redundant health probe before a %s batch execution", async (dbType) => {
|
||||
const sql = Array.from({ length: 20 }, (_, index) => `INSERT INTO users (id) VALUES (${index + 1});`).join("\n");
|
||||
const blockedHealthProbe = deferred<void>();
|
||||
mocks.ensureConnected.mockImplementation((_connectionId, options) => (options?.verifyHealth === false ? Promise.resolve() : blockedHealthProbe.promise));
|
||||
const connectionId = `${dbType}-1`;
|
||||
mocks.getConnectionConfig.mockReturnValue({
|
||||
id: connectionId,
|
||||
name: dbType,
|
||||
db_type: dbType,
|
||||
database: "app",
|
||||
query_timeout_secs: 30,
|
||||
});
|
||||
mocks.executeMulti.mockResolvedValue(
|
||||
Array.from({ length: 20 }, (_, statementIndex) => ({
|
||||
columns: [],
|
||||
rows: [],
|
||||
affected_rows: 1,
|
||||
execution_time_ms: 1,
|
||||
statement_index: statementIndex,
|
||||
})),
|
||||
);
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
const tabId = store.createTab(connectionId, "app", "Query", "query", "public", sql);
|
||||
|
||||
await store.executeTabSql(tabId, sql, { sourceOffset: 0 });
|
||||
|
||||
expect(mocks.ensureConnected).toHaveBeenCalledWith(connectionId, { verifyHealth: false });
|
||||
expect(mocks.executeMultiWithProgress).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("skips a failed statement and continues the original batch without replaying successful statements", async () => {
|
||||
const sqlError = structuredSqlError();
|
||||
const sql = "INSERT INTO t VALUES (1);\nINSERT INTO t VALUES (1);\nINSERT INTO t VALUES (2);\nINSERT INTO t VALUES (3)";
|
||||
|
||||
@@ -6810,7 +6810,11 @@ export const useQueryStore = defineStore("query", () => {
|
||||
queryExecutionLog("info", "ensure-connected:skip", { traceId, elapsed: elapsed(), reason: "mongo-use-only" });
|
||||
} else {
|
||||
queryExecutionLog("info", "ensure-connected:start", { traceId, elapsed: elapsed() });
|
||||
await connStore.ensureConnected(executionConnectionId);
|
||||
if (conn?.db_type === "oracle" || conn?.db_type === "postgres") {
|
||||
await connStore.ensureConnected(executionConnectionId, { verifyHealth: false });
|
||||
} else {
|
||||
await connStore.ensureConnected(executionConnectionId);
|
||||
}
|
||||
queryExecutionLog("info", "ensure-connected:done", { traceId, elapsed: elapsed() });
|
||||
}
|
||||
conn = connStore.getConfig(executionConnectionId);
|
||||
|
||||
Reference in New Issue
Block a user