25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(mongodb): offer rename collection on legacy agent connections
Loc Nguyen808317e0e780
diff --git a/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.ts b/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.tsindex 839ed3c5e9..94f9ad8eca 100644--- a/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.ts+++ b/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.ts@@ -277,7 +277,8 @@ describe("MongoDB sidebar mutation runtime", () => {activeNode.value = mongoCollectionNode();expect(feature.canDropMongoCollection.value).toBe(true);expect(feature.canDropAllMongoIndexes.value).toBe(false);- expect(feature.canRenameMongoCollection.value).toBe(false);+ // The Legacy Agent supports renameCollection (capability-gated in the backend).+ expect(feature.canRenameMongoCollection.value).toBe(true);expect(feature.canCloneMongoCollection.value).toBe(true);expect(feature.canCreateMongoIndex.value).toBe(false);activeNode.value = mongoIndexesGroupNode();diff --git a/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.rename.spec.ts b/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.rename.spec.tsindex 178ea6aebf..fff3e12388 100644--- a/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.rename.spec.ts+++ b/apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.rename.spec.ts@@ -177,6 +177,33 @@ function milvusCollectionNode(): TreeNode {};}+describe("MongoDB collection rename availability", () => {+ beforeEach(() => {+ setActivePinia(createPinia());+ vi.clearAllMocks();+ });++ it("offers rename on both the native driver and the Legacy Agent", () => {+ // The Agent has renameCollection (capability-gated in the backend), so the menu no longer+ // hides the action on legacy connections; a read-only connection still gets nothing.+ for (const driver_profile of [undefined, "mongodb-native", "mongodb-legacy"]) {+ mocks.getConfig.mockReturnValue({ id: "conn-1", name: "Mongo", db_type: "mongodb", host: "localhost", port: 27017, username: "op", password: "", driver_profile });+ const activeNode = shallowRef(collectionNode());+ const { canRenameMongoCollection } = useSidebarDatabaseSpecificMutationRuntime({+ activeNode,+ connectionStore: { getConfig: mocks.getConfig, ensureConnected: mocks.ensureConnected, loadMongoCollections: mocks.loadMongoCollections, treeNodes: [] } as any,+ });+ expect(canRenameMongoCollection.value, `driver_profile=${driver_profile}`).toBe(true);+ }+ mocks.getConfig.mockReturnValue({ id: "conn-1", name: "Mongo", db_type: "mongodb", host: "localhost", port: 27017, username: "op", password: "", driver_profile: "mongodb-legacy", read_only: true });+ const { canRenameMongoCollection } = useSidebarDatabaseSpecificMutationRuntime({+ activeNode: shallowRef(collectionNode()),+ connectionStore: { getConfig: mocks.getConfig, ensureConnected: mocks.ensureConnected, loadMongoCollections: mocks.loadMongoCollections, treeNodes: [] } as any,+ });+ expect(canRenameMongoCollection.value).toBe(false);+ });+});+describe("Milvus collection rename", () => {beforeEach(() => {setActivePinia(createPinia());diff --git a/apps/desktop/src/composables/useSidebarDatabaseSpecificMutationRuntime.ts b/apps/desktop/src/composables/useSidebarDatabaseSpecificMutationRuntime.tsindex 694ac510cf..f815dd2846 100644--- a/apps/desktop/src/composables/useSidebarDatabaseSpecificMutationRuntime.ts+++ b/apps/desktop/src/composables/useSidebarDatabaseSpecificMutationRuntime.ts@@ -33,7 +33,7 @@ import {type MongoIndexSpecSnapshot,} from "@/lib/sidebar/mongoCollectionMutation";import { elasticsearchClearIndexPreview, isElasticsearchProtocolIndex, isPartialElasticsearchClear, notifyElasticsearchIndexCleared } from "@/lib/sidebar/elasticsearchIndexActions";-import { supportsMongoAllDriverMutations, supportsMongoIndexMutations, supportsNativeMongoDriverMutations } from "@/lib/mongo/mongoCapabilities";+import { supportsMongoAllDriverMutations, supportsMongoIndexMutations } from "@/lib/mongo/mongoCapabilities";import { runMongoSidebarMutation } from "@/lib/sidebar/runMongoSidebarMutation";import { executeWithProductionContextGuard } from "@/lib/database/productionExecutionGuard";import { connectionIsEffectivelyReadOnly } from "@/lib/database/readOnlyWriteAccess";@@ -121,10 +121,6 @@ export function useSidebarDatabaseSpecificMutationRuntime(options: SidebarDatabareturn !!node.connectionId && supportsMongoAllDriverMutations(connectionStore.getConfig(node.connectionId));}- function usesNativeMongoDriver(node: Pick<TreeNode, "connectionId">): boolean {- return !!node.connectionId && supportsNativeMongoDriverMutations(connectionStore.getConfig(node.connectionId));- }-function canMutateMongoIndexes(node: TreeNode): boolean {return !!node.connectionId && supportsMongoIndexMutations(connectionStore.getConfig(node.connectionId), mongoCollectionKindFromNode(node));}@@ -150,7 +146,7 @@ export function useSidebarDatabaseSpecificMutationRuntime(options: SidebarDataba}function canRenameMongoCollectionNode(node: TreeNode): boolean {- return canMutateMilvusCollectionNode(node) || (canMutateMongoCollectionNode(node) && usesNativeMongoDriver(node) && isRenamableMongoCollection(node.label, mongoCollectionKindFromNode(node)));+ return canMutateMilvusCollectionNode(node) || (canMutateMongoCollectionNode(node) && isRenamableMongoCollection(node.label, mongoCollectionKindFromNode(node)));}function canCloneMongoCollectionNode(node: TreeNode): boolean {diff --git a/apps/desktop/src/lib/mongo/__tests__/mongoCapabilities.spec.ts b/apps/desktop/src/lib/mongo/__tests__/mongoCapabilities.spec.tsindex 969f12e281..d2e9f82d74 100644--- a/apps/desktop/src/lib/mongo/__tests__/mongoCapabilities.spec.ts+++ b/apps/desktop/src/lib/mongo/__tests__/mongoCapabilities.spec.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { isMongoLegacyDriverProfile, mongoCollectionSupportsIndexes, supportsMongoAllDriverMutations, supportsMongoIndexMutations, supportsNativeMongoDriverMutations } from "@/lib/mongo/mongoCapabilities";+import { isMongoLegacyDriverProfile, mongoCollectionSupportsIndexes, supportsMongoAllDriverMutations, supportsMongoIndexMutations } from "@/lib/mongo/mongoCapabilities";describe("MongoDB driver mutation capabilities", () => {it("keeps index and drop mutations available through both native and Legacy drivers", () => {@@ -12,7 +12,6 @@ describe("MongoDB driver mutation capabilities", () => {expect(supportsMongoAllDriverMutations(readOnly)).toBe(false);expect(supportsMongoIndexMutations(readOnly, "collection")).toBe(false);- expect(supportsNativeMongoDriverMutations({ ...readOnly, driver_profile: "mongodb" })).toBe(false);});it("keeps index metadata visible on read-only collections", () => {@@ -32,14 +31,6 @@ describe("MongoDB driver mutation capabilities", () => {expect(supportsMongoIndexMutations(native, " VIEW ")).toBe(false);});- it("reserves native-only mutations for the native MongoDB driver", () => {- expect(supportsNativeMongoDriverMutations({ db_type: "mongodb", driver_profile: "mongodb" })).toBe(true);- expect(supportsNativeMongoDriverMutations({ db_type: "mongodb", driver_profile: undefined })).toBe(true);- expect(supportsNativeMongoDriverMutations({ db_type: "mongodb", driver_profile: "mongodb-legacy" })).toBe(false);- expect(supportsNativeMongoDriverMutations({ db_type: "mongodb", driver_profile: "legacy" })).toBe(false);- expect(supportsNativeMongoDriverMutations({ db_type: "mongodb", driver_profile: "MongoDB_Legacy" })).toBe(false);- });-it("recognizes historical Legacy profile spellings", () => {expect(isMongoLegacyDriverProfile("mongodb-legacy")).toBe(true);expect(isMongoLegacyDriverProfile(" mongodb_legacy ")).toBe(true);@@ -49,6 +40,6 @@ describe("MongoDB driver mutation capabilities", () => {it("does not grant MongoDB mutations to another connection type", () => {expect(supportsMongoAllDriverMutations({ db_type: "postgres", driver_profile: undefined })).toBe(false);- expect(supportsNativeMongoDriverMutations(undefined)).toBe(false);+ expect(supportsMongoAllDriverMutations(undefined)).toBe(false);});});diff --git a/apps/desktop/src/lib/mongo/mongoCapabilities.ts b/apps/desktop/src/lib/mongo/mongoCapabilities.tsindex 77b1573040..dc48e5552c 100644--- a/apps/desktop/src/lib/mongo/mongoCapabilities.ts+++ b/apps/desktop/src/lib/mongo/mongoCapabilities.ts@@ -22,8 +22,3 @@ export function mongoCollectionSupportsIndexes(collectionKind?: string): booleanexport function supportsMongoIndexMutations(connection?: MongoConnectionProfile, collectionKind?: string): boolean {return supportsMongoAllDriverMutations(connection) && mongoCollectionSupportsIndexes(collectionKind);}--/** Capabilities which require the native Rust MongoDB driver. */-export function supportsNativeMongoDriverMutations(connection?: MongoConnectionProfile): boolean {- return supportsMongoAllDriverMutations(connection) && !isMongoLegacyDriverProfile(connection?.driver_profile);-}