fix(sidebar): preserve case-sensitive object identities

This commit is contained in:
zipg authored and GitHub committed 2026-07-27 16:52:35 +08:00
1 parent 0aced0012c
commit bd693d7b98
4 files changed
+188 -39

No files matched your search

@@ -322,7 +322,7 @@ describe("connectionStore metadata loading", () => {
{ id: "oracle-1:XE:DIP:__views:DIP:V_TWO", label: "V_TWO", type: "view", connectionId: "oracle-1", database: "XE", schema: "DIP", isExpanded: false },
];
const loadSchemaCache = vi.fn(async (key: string) =>
key.endsWith(":objects-v5")
key.endsWith(":objects-v6")
? {
version: 2,
cachedAt: new Date().toISOString(),
@@ -385,7 +385,7 @@ describe("connectionStore metadata loading", () => {
expect(storedViewGroup?.type).toBe("group-views");
await store.loadObjectGroupChildren(storedViewGroup!);
expect(loadSchemaCache).toHaveBeenCalledWith("oracle-1:XE:DIP:group-views:objects-v6");
expect(loadSchemaCache).toHaveBeenCalledWith("oracle-1:XE:DIP:group-views:objects-v7");
expect(listTables).toHaveBeenCalledWith(connection.id, "XE", "DIP", undefined, 201, 0, ["VIEW"]);
expect(storedViewGroup?.children?.map((node) => node.label)).toEqual(["V_ONE", "V_THREE", "V_TWO"]);
});
+5 -5
View File
@@ -1279,7 +1279,7 @@ export const useConnectionStore = defineStore("connection", () => {
function objectGroupCacheKey(node: TreeNode): string {
const config = node.connectionId ? getConfig(node.connectionId) : undefined;
const cacheVersion = config?.db_type === "oracle" ? "objects-v6" : "objects-v5";
const cacheVersion = config?.db_type === "oracle" ? "objects-v7" : "objects-v6";
return schemaCacheKey(node.connectionId || "", node.database || "", node.schema || "", node.type, cacheVersion);
}
@@ -1460,7 +1460,7 @@ export const useConnectionStore = defineStore("connection", () => {
}
function treeNodeObjectIdentity(node: TreeNode): string {
return `${node.type}\0${(node.schema || "").toLowerCase()}\0${node.label.toLowerCase()}`;
return `${node.type}\0${node.schema || ""}\0${node.label}`;
}
function mergeLocatedTreeChildren(parent: TreeNode, currentChildren: TreeNode[], pageChildren: TreeNode[], connectionId: string, database: string): TreeNode[] {
@@ -3558,7 +3558,7 @@ export const useConnectionStore = defineStore("connection", () => {
nodeKind: "simple-tables",
catalog,
});
const cacheKey = schemaCacheKey(connectionId, `doris-catalog:${catalog}`, database, "objects-simple-v4");
const cacheKey = schemaCacheKey(connectionId, `doris-catalog:${catalog}`, database, "objects-simple-v5");
if (!options?.force && !searchFilter && !tableNameFilter) {
const cached = await loadPersistedTreeChildren(node, cacheKey);
if (cached.hit) {
@@ -3631,7 +3631,7 @@ export const useConnectionStore = defineStore("connection", () => {
await ensureConnected(connectionId);
if (useCachedChildren(node, options)) return;
const simpleObjectDisplay = useSettingsStore().editorSettings.sidebarObjectDisplay === "simple";
const cacheKey = schemaCacheKey(connectionId, database, schema || "", simpleObjectDisplay ? "objects-simple-v5" : "objects-grouped-v6");
const cacheKey = schemaCacheKey(connectionId, database, schema || "", simpleObjectDisplay ? "objects-simple-v6" : "objects-grouped-v7");
const searchFilter = activeTreeLoadSearchFilter(options);
const config = getConfig(connectionId);
const querySchema = connectionObjectTreeQuerySchema(config, database, schema);
@@ -3865,7 +3865,7 @@ export const useConnectionStore = defineStore("connection", () => {
if (!canApplyTreeMetadataResult(parent)) return;
parent.objectCount = mergedChildren.length;
setChildren(parent, nextChildren);
await savePersistedTreeChildren(schemaCacheKey(parentConnectionId, parentDatabase, parent.schema || "", "objects-simple-v5"), nextChildren);
await savePersistedTreeChildren(schemaCacheKey(parentConnectionId, parentDatabase, parent.schema || "", "objects-simple-v6"), nextChildren);
parent.isExpanded = true;
return;
}