fix(mysql): refresh stale snapshots and streamline table reloads
This commit is contained in:
11 files changed
+911
-54
No files matched your search
@@ -17,6 +17,25 @@ describe("data tab snapshot restore vs tableMetaPending", () => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
it("keeps projection-only metadata pending until complete identity metadata arrives", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
const tabId = store.createTab("pg-1", "app", "users", "data", "public");
|
||||
const tab = store.tabs.find((item) => item.id === tabId)!;
|
||||
const metadata = { tableName: "users", schema: "public", columns: [column("id")], primaryKeys: ["id"] };
|
||||
store.setTableMeta(tabId, metadata);
|
||||
expect(tab.tableMetaPending).toBe(false);
|
||||
|
||||
store.setTableMeta(tabId, { ...metadata, columns: [{ ...column("id"), is_primary_key: false }], primaryKeys: [] }, { rowIdentityPending: true });
|
||||
expect(tab.tableMetaPending).toBe(true);
|
||||
expect(tab.tableMeta?.primaryKeys).toEqual([]);
|
||||
store.setTableMeta(tabId, { ...metadata, columns: [], primaryKeys: [] });
|
||||
expect(tab.tableMetaPending).toBe(true);
|
||||
|
||||
store.setTableMeta(tabId, metadata);
|
||||
expect(tab.tableMetaPending).toBe(false);
|
||||
});
|
||||
|
||||
it("does not roll back real metadata to a placeholder snapshot and re-pends placeholder restores", async () => {
|
||||
vi.doMock("@/lib/tabs/tabResultCache", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("@/lib/tabs/tabResultCache")>();
|
||||
|
||||
@@ -5064,9 +5064,10 @@ export const useQueryStore = defineStore("query", () => {
|
||||
return clearInvalidDataTabSortState(tab, tab.tableMeta.columns);
|
||||
}
|
||||
|
||||
function setTableMeta(id: string, meta: NonNullable<QueryTab["tableMeta"]>) {
|
||||
function setTableMeta(id: string, meta: NonNullable<QueryTab["tableMeta"]>, options: { rowIdentityPending?: boolean } = {}) {
|
||||
const tab = tabs.value.find((t) => t.id === id);
|
||||
if (tab) {
|
||||
if (options.rowIdentityPending) tab.tableMetaPending = true;
|
||||
tab.tableMeta = meta;
|
||||
// 记录写入时的连接元数据代次:disconnect/关库/死池重连会使该代次递增,
|
||||
// 代次失配视同冷缓存,即使位于 30s TTL 窗口内也会重建结构(issue #6623 /
|
||||
@@ -5078,7 +5079,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
// columns/primaryKeys 为空的占位身份(如 useNavigationTargets),不得
|
||||
// 借此提前解除编辑门控。失败/中止路径不清除——标签页保持只读是安全
|
||||
// 兜底,刷新或重开表会重新加载元数据恢复
|
||||
if (meta.columns.length > 0) tab.tableMetaPending = false;
|
||||
if (meta.columns.length > 0 && !options.rowIdentityPending) tab.tableMetaPending = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user