fix(mysql): use database-specific catalog switching

This commit is contained in:
jischeng authored and GitHub committed 2026-07-29 20:41:09 +08:00
1 parent 9571519179
commit 2152f8cde8
31 files changed
+818 -182

No files matched your search

@@ -338,6 +338,16 @@ describe("queryStore multi-statement errors", () => {
expect(mocks.executeMulti).toHaveBeenCalledWith("mysql-1", "app", "SELECT 1", undefined, expect.any(String), expect.objectContaining({ continueOnError: false }));
});
it("passes the selected external catalog to query execution", async () => {
mocks.executeMulti.mockResolvedValue([{ columns: ["value"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 }]);
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
const tabId = store.createTab("mysql-1", "bi", "Query", "query", undefined, undefined, "paimon_catalog");
await store.executeTabSql(tabId, "SELECT * FROM events");
expect(mocks.executeMulti).toHaveBeenCalledWith("mysql-1", "bi", "SELECT * FROM events", undefined, expect.any(String), expect.objectContaining({ catalog: "paimon_catalog" }));
});
it("keeps old and new executions as result runs, then lets normal execution replace the active run", async () => {
mocks.executeMulti
@@ -1,5 +1,6 @@
import { createPinia, setActivePinia } from "pinia";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useQueryStore } from "@/stores/queryStore";
describe("queryStore switchTab", () => {
beforeEach(() => {
@@ -74,6 +75,44 @@ describe("queryStore switchTab", () => {
expect(settingsStore.settingsPageActive).toBe(false);
});
it("keeps same-named tabs from different catalogs distinct", async () => {
const queryStore = useQueryStore();
const paimonTabId = queryStore.createTab("sr-1", "bi", "events", "query", undefined, undefined, "paimon_catalog");
const internalTabId = queryStore.createTab("sr-1", "bi", "events", "query", undefined, undefined, "internal");
expect(internalTabId).not.toBe(paimonTabId);
expect(queryStore.tabs).toHaveLength(2);
});
it("preserves catalog context when duplicating a query tab", async () => {
const queryStore = useQueryStore();
const tabId = queryStore.createTab("sr-1", "bi", undefined, "query", undefined, "SELECT 1", "paimon_catalog");
queryStore.duplicateTab(tabId);
expect(queryStore.tabs).toHaveLength(2);
expect(queryStore.tabs[1].catalog).toBe("paimon_catalog");
});
it("switches catalog and database as one query context", () => {
const queryStore = useQueryStore();
const tabId = queryStore.createTab("sr-1", "internal_db", undefined, "query");
const tab = queryStore.tabs.find((candidate) => candidate.id === tabId)!;
tab.result = {
columns: ["id"],
rows: [[1]],
affected_rows: 0,
execution_time_ms: 1,
};
queryStore.updateCatalog(tabId, "paimon_catalog", "bi");
expect(tab.catalog).toBe("paimon_catalog");
expect(tab.database).toBe("bi");
expect(tab.result).toBeUndefined();
});
it("stores local data-grid column filters on the tab result", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const queryStore = useQueryStore();