From 073139cde946a2ff31eb56ed76f7965002981c95 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 14 Aug 2026 05:45:54 +0000 Subject: [PATCH] fix(frontend): restore formatting checks --- .../sidebar/SidebarTreeRuntimeHost.vue | 20 ++++++++++++++++++- .../useSidebarTableMutationRuntime.ts | 16 ++++++++++++++- .../DatabaseUserAdmin.component.spec.ts | 5 +---- .../database/databaseUserAdmin.spec.ts | 4 +--- .../lib/__tests__/database/dbAdminSql.spec.ts | 11 +++++++++- 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue index 80bd7dabdc..0204b7c9dd 100644 --- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue +++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue @@ -485,7 +485,25 @@ const { confirmDropAllMongoIndexes, } = useSidebarDatabaseSpecificMutationRuntime({ activeNode, connectionStore }); -const { isTableNotView, supportsTruncate, supportsMysqlAutoIncrement, canDropTableCascade, canTruncateTableCascade, refreshDropTablePreviewSql, refreshTruncateTablePreviewSql, dropTable, refreshTableList, confirmDropTable, emptyTable, confirmEmptyTable, truncateTable, confirmTruncateTable, mysqlAutoIncrement, refreshMysqlAutoIncrementPreviewSql, confirmMysqlAutoIncrement } = useSidebarTableMutationRuntime({ +const { + isTableNotView, + supportsTruncate, + supportsMysqlAutoIncrement, + canDropTableCascade, + canTruncateTableCascade, + refreshDropTablePreviewSql, + refreshTruncateTablePreviewSql, + dropTable, + refreshTableList, + confirmDropTable, + emptyTable, + confirmEmptyTable, + truncateTable, + confirmTruncateTable, + mysqlAutoIncrement, + refreshMysqlAutoIncrementPreviewSql, + confirmMysqlAutoIncrement, +} = useSidebarTableMutationRuntime({ activeNode, releaseActiveNodeReference, connectionStore, diff --git a/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts b/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts index d984750960..281989a26c 100644 --- a/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts +++ b/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts @@ -6,7 +6,21 @@ import type { DatabaseType, TreeNode } from "@/types/database"; import { supportsTableTruncate } from "@/lib/database/databaseCapabilities"; import { buildDropTableSql, buildEmptyTableSql, buildMysqlAutoIncrementSql, buildTruncateTableSql, supportsDropTableCascade, supportsNativeMysqlAutoIncrement, supportsTruncateTableCascade, type MysqlAutoIncrementSqlOptions, type TableAdminSqlOptions } from "@/lib/database/dbAdminSql"; import { isSqlServerLinkedNode } from "@/lib/database/sqlServerLinkedServers"; -import { sidebarDangerTarget, showDropTableConfirm, showEmptyTableConfirm, showMysqlAutoIncrementConfirm, showTruncateTableConfirm, dropTablePreviewSql, dropTableCascade, emptyTablePreviewSql, mysqlAutoIncrementPreviewKey, mysqlAutoIncrementPreviewSql, mysqlAutoIncrementValue, truncateTablePreviewSql, truncateTableCascade } from "@/components/sidebar/sidebarTreeDialogState"; +import { + sidebarDangerTarget, + showDropTableConfirm, + showEmptyTableConfirm, + showMysqlAutoIncrementConfirm, + showTruncateTableConfirm, + dropTablePreviewSql, + dropTableCascade, + emptyTablePreviewSql, + mysqlAutoIncrementPreviewKey, + mysqlAutoIncrementPreviewSql, + mysqlAutoIncrementValue, + truncateTablePreviewSql, + truncateTableCascade, +} from "@/components/sidebar/sidebarTreeDialogState"; interface SidebarTableMutationRuntimeOptions { activeNode: ShallowRef; diff --git a/apps/desktop/src/lib/__tests__/database/DatabaseUserAdmin.component.spec.ts b/apps/desktop/src/lib/__tests__/database/DatabaseUserAdmin.component.spec.ts index f681bbf42e..ca855dc8cc 100644 --- a/apps/desktop/src/lib/__tests__/database/DatabaseUserAdmin.component.spec.ts +++ b/apps/desktop/src/lib/__tests__/database/DatabaseUserAdmin.component.spec.ts @@ -259,10 +259,7 @@ describe("DatabaseUserAdmin MySQL account Host changes", () => { await vi.waitFor(() => expect(mocks.executeQuery.mock.calls.some((call) => call[2] === "SHOW GRANTS FOR 'same-user'@'new-host';")).toBe(true)); expect(mocks.executeMulti.mock.calls[0][2]).toBe("RENAME USER 'same-user'@'old-host' TO 'same-user'@'new-host';"); expect(mocks.productionGuard).toHaveBeenCalledWith(expect.objectContaining({ connection: nativeMysqlConnection, sql: "RENAME USER 'same-user'@'old-host' TO 'same-user'@'new-host';" })); - expect(mocks.executeQuery.mock.calls.slice(2).map((call) => call[2])).toEqual([ - "SELECT User AS user, Host AS host, plugin AS plugin FROM mysql.user ORDER BY User, Host;", - "SHOW GRANTS FOR 'same-user'@'new-host';", - ]); + expect(mocks.executeQuery.mock.calls.slice(2).map((call) => call[2])).toEqual(["SELECT User AS user, Host AS host, plugin AS plugin FROM mysql.user ORDER BY User, Host;", "SHOW GRANTS FOR 'same-user'@'new-host';"]); expect(root?.textContent).toContain("same-user@new-host"); expect(root?.querySelector('input[placeholder="userAdmin.newHost"]')).toBeNull(); }); diff --git a/apps/desktop/src/lib/__tests__/database/databaseUserAdmin.spec.ts b/apps/desktop/src/lib/__tests__/database/databaseUserAdmin.spec.ts index d5607bfb08..71bd34a01e 100644 --- a/apps/desktop/src/lib/__tests__/database/databaseUserAdmin.spec.ts +++ b/apps/desktop/src/lib/__tests__/database/databaseUserAdmin.spec.ts @@ -91,9 +91,7 @@ describe("database user admin providers", () => { expect(blankLegacyNative).toBe(nativeMysqlUserAdminProvider); expect(native).toBe(nativeMysqlUserAdminProvider); expect(normalizedNative).toBe(nativeMysqlUserAdminProvider); - expect(native?.renameUserSql?.({ user: "app'user", host: "old\\host" }, "new'\\host")).toBe( - "RENAME USER 'app''user'@'old\\\\host' TO 'app''user'@'new''\\\\host';", - ); + expect(native?.renameUserSql?.({ user: "app'user", host: "old\\host" }, "new'\\host")).toBe("RENAME USER 'app''user'@'old\\\\host' TO 'app''user'@'new''\\\\host';"); }); it("does not expose account Host changes to MySQL-compatible providers", () => { diff --git a/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts b/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts index 3c03ac3f9c..01296dd008 100644 --- a/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts +++ b/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts @@ -13,7 +13,16 @@ const apiMock = vi.hoisted(() => ({ vi.mock("@/lib/backend/api", () => apiMock); -import { buildDuplicateTableStructurePlan, buildMysqlAutoIncrementSql, collectDuplicateTableColumnComments, damengDropSchemaExecutionSchema, damengDuplicateTableCreateOptions, duplicateTableStructureRequiresScript, oracleDuplicateTableCreateOptions, supportsNativeMysqlAutoIncrement } from "@/lib/database/dbAdminSql"; +import { + buildDuplicateTableStructurePlan, + buildMysqlAutoIncrementSql, + collectDuplicateTableColumnComments, + damengDropSchemaExecutionSchema, + damengDuplicateTableCreateOptions, + duplicateTableStructureRequiresScript, + oracleDuplicateTableCreateOptions, + supportsNativeMysqlAutoIncrement, +} from "@/lib/database/dbAdminSql"; beforeEach(() => { vi.clearAllMocks();