fix(navicat): prefer ConnType when importing connections

This commit is contained in:
Moe. authored and GitHub committed 2026-07-01 01:23:51 +08:00
1 parent b11ab2ddff
commit 1a8b52410f
3 files changed
+22 -5

No files matched your search

@@ -84,4 +84,17 @@ describe("parseNavicatConnections", () => {
expect(connection?.database).toBe("appdb");
expect(connection?.port).toBe(15432);
});
it("prefers Navicat ConnType over Redis deployment Type", async () => {
const [connection] = await parseNavicatConnections(`<Connections>
<Connection ConnectionName="redis-standalone" ConnType="REDIS" ServiceProvider="Default" Type="Standalone" Host="redis.example.test" Port="16379" AuthenticationMode="UsernamePassword" UserName="default" />
</Connections>`);
expect(connection?.db_type).toBe("redis");
expect(connection?.driver_profile).toBe("redis");
expect(connection?.name).toBe("redis-standalone");
expect(connection?.host).toBe("redis.example.test");
expect(connection?.port).toBe(16379);
expect(connection?.username).toBe("default");
});
});
+2 -2
View File
@@ -146,7 +146,7 @@ function valuesFromElement(element: Element) {
}
function isConnectionCandidate(node: ParsedNode) {
const type = getAny(node.values, ["type", "connType", "connectionType", "databaseType", "driver"]);
const type = getAny(node.values, ["connType", "databaseType", "driver", "connectionType", "type"]);
const name = getAny(node.values, ["name", "connectionName", "connName", "caption", "title"]);
const host = getAny(node.values, ["host", "server", "hostname", "serverHost", "address"]);
const file = getSqlitePath(node.values);
@@ -154,7 +154,7 @@ function isConnectionCandidate(node: ParsedNode) {
}
async function parseConnection(node: ParsedNode): Promise<ConnectionConfig | null> {
const rawType = getAny(node.values, ["type", "connType", "connectionType", "databaseType", "driver", "dbType"]);
const rawType = getAny(node.values, ["connType", "databaseType", "driver", "dbType", "connectionType", "type"]);
const portValue = Number(getAny(node.values, ["port", "serverPort"]));
const port = Number.isFinite(portValue) && portValue > 0 ? portValue : undefined;
const profile = inferProfile(rawType, node.tag, port);