fix(sqlserver): preserve legacy compatibility setting

This commit is contained in:
zipg authored and GitHub committed 2026-07-25 19:41:27 +08:00
1 parent c1270ba793
commit e6da0a6298
6 files changed
+245 -12

No files matched your search

@@ -41,11 +41,11 @@ describe("connectionStore SQL Server legacy compatibility", () => {
setActivePinia(createPinia());
});
it("does not preinstall the legacy component for historical disabled-encryption configs", async () => {
it("migrates historical disabled-encryption configs and installs the legacy component", async () => {
const connectDb = vi.fn().mockResolvedValue("sqlserver-1");
const installAgent = vi.fn().mockResolvedValue(undefined);
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => true }));
vi.doMock("@/lib/backend/api", () => ({
connectDb,
installAgent,
@@ -56,8 +56,16 @@ describe("connectionStore SQL Server legacy compatibility", () => {
const store = useConnectionStore();
await store.connect(sqlServerNativeConnectionWithDisabledEncryption());
expect(installAgent).not.toHaveBeenCalled();
expect(installAgent).toHaveBeenCalledWith("sqlserver-legacy");
expect(connectDb).toHaveBeenCalledTimes(1);
expect(connectDb).toHaveBeenCalledWith(
expect.objectContaining({
driver_profile: "sqlserver-legacy",
driver_label: "SQL Server legacy compatibility component",
url_params: "",
}),
expect.any(Number),
);
});
it("reconnects persisted legacy profiles without reinstalling an installed component", async () => {
@@ -66,6 +74,7 @@ describe("connectionStore SQL Server legacy compatibility", () => {
const config = sqlServerNativeConnectionWithDisabledEncryption();
config.driver_profile = "sqlserver-legacy";
config.driver_label = "SQL Server legacy compatibility component";
config.url_params = "";
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => true }));
vi.doMock("@/lib/backend/api", () => ({
@@ -87,6 +96,7 @@ describe("connectionStore SQL Server legacy compatibility", () => {
const connectDb = vi.fn().mockRejectedValue(new Error("TLS negotiation failed\nSQL Server error 18456: Login failed"));
const installAgent = vi.fn().mockResolvedValue(undefined);
const config = sqlServerNativeConnectionWithDisabledEncryption();
config.url_params = "";
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => true }));
vi.doMock("@/lib/backend/api", () => ({
+3 -1
View File
@@ -54,7 +54,7 @@ import { collapseExpandedTreeNodes } from "@/lib/sidebar/sidebarTreeCollapse";
import { findDatabaseTreeNode } from "@/lib/sidebar/treeRefreshTarget";
import { shouldMarkDisconnected } from "@/lib/connection/connectionHealth";
import { connectionAttemptOriginalErrorMessage, connectionAttemptTimeoutMessage, connectionAttemptTimeoutMs } from "@/lib/connection/connectionAttemptTimeout";
import { requiresSqlServerLegacyCompatibilityComponent, SQLSERVER_LEGACY_COMPATIBILITY_DRIVER_KEY } from "@/lib/connection/sqlServerLegacyCompatibility";
import { migrateSqlServerLegacyCompatibilityConfig, requiresSqlServerLegacyCompatibilityComponent, SQLSERVER_LEGACY_COMPATIBILITY_DRIVER_KEY } from "@/lib/connection/sqlServerLegacyCompatibility";
import { deleteTabResultSnapshotsForOwner } from "@/lib/tabs/tabResultCache";
import { connectionUsesVisibleSchemaFilter, filterDatabaseNamesForConnection, filterSchemaNamesForConnection, filterVisibleDatabaseNames, normalizeVisibleDatabaseSelection } from "@/lib/database/visibleDatabases";
import {
@@ -910,6 +910,8 @@ export const useConnectionStore = defineStore("connection", () => {
}
function normalizeConnection(config: ConnectionConfig): ConnectionConfig {
config = { ...config };
migrateSqlServerLegacyCompatibilityConfig(config);
const labelMap: Record<string, string> = {
mysql: "MySQL",
postgres: "PostgreSQL",