fix(transfer): keep doris-family mysql connections selectable
This commit is contained in:
4 files changed
+60
-8
No files matched your search
@@ -25,7 +25,10 @@ import {
|
||||
setGaussdbIdentifierQuoteStyle,
|
||||
setGaussdbTargetServerType,
|
||||
supportsGaussdbIdentifierQuoteStyle,
|
||||
transferDatabaseTypeForConnection,
|
||||
} from "@/lib/database/jdbcDialect";
|
||||
import { supportsTransfer } from "@/lib/database/databaseFeatureSupport";
|
||||
import { transferObjectKindsForDatabase } from "@/lib/database/transferObjectKinds";
|
||||
|
||||
describe("jdbc dialect inference", () => {
|
||||
it("detects InterSystems IRIS and Caché JDBC connections", () => {
|
||||
@@ -223,6 +226,34 @@ describe("jdbc dialect inference", () => {
|
||||
expect(effectiveDatabaseTypeForConnection(gbase8sProfileWithLegacyGbaseUrl)).toBe("jdbc");
|
||||
});
|
||||
|
||||
it("keeps doris-family mysql connections on the mysql transfer path", () => {
|
||||
// Doris/SelectDB/StarRocks connections are saved as db_type=mysql with a
|
||||
// doris-family driver_profile. The SQL dialect stays doris/starrocks
|
||||
// (3-part catalog names), but transfer admission and object kinds must ride
|
||||
// the raw mysql db_type: the standalone doris/starrocks manifest entries are
|
||||
// not transfer-capable, so the effective type would hide these connections
|
||||
// from the transfer dialog and drop their non-table object kinds.
|
||||
for (const driver_profile of ["starrocks", "doris", "selectdb"]) {
|
||||
const connection = { db_type: "mysql" as const, driver_profile };
|
||||
const transferType = transferDatabaseTypeForConnection(connection);
|
||||
|
||||
expect(transferType).toBe("mysql");
|
||||
expect(supportsTransfer(transferType)).toBe(true);
|
||||
expect(transferObjectKindsForDatabase(transferType)).toContain("VIEW");
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves transfer types for non-doris-family connections through the effective type", () => {
|
||||
expect(transferDatabaseTypeForConnection(undefined)).toBeUndefined();
|
||||
expect(transferDatabaseTypeForConnection({ db_type: "mysql" })).toBe("mysql");
|
||||
expect(transferDatabaseTypeForConnection({ db_type: "postgres" })).toBe("postgres");
|
||||
expect(transferDatabaseTypeForConnection({ db_type: "gbase" })).toBe("mysql");
|
||||
expect(transferDatabaseTypeForConnection({ db_type: "jdbc", connection_string: "jdbc:gbase://localhost:5258/dbx_test" })).toBe("gbase");
|
||||
// A generic-JDBC Doris URL keeps its raw db_type (never admitted), matching
|
||||
// the pre-effective-type behavior for unknown jdbc connections.
|
||||
expect(transferDatabaseTypeForConnection({ db_type: "jdbc", connection_string: "jdbc:doris://localhost:9030/dbx_test" })).toBe("jdbc");
|
||||
});
|
||||
|
||||
it("uses Hive tree and execution semantics for Inceptor JDBC metadata", () => {
|
||||
const connection = {
|
||||
db_type: "jdbc" as const,
|
||||
|
||||
@@ -82,6 +82,22 @@ export function effectiveDatabaseTypeForConnection(connection?: JdbcDialectConne
|
||||
return inferJdbcDialect(connection) ?? "jdbc";
|
||||
}
|
||||
|
||||
/**
|
||||
* Database type the data-transfer pipeline treats a connection as. Doris-family
|
||||
* engines (Doris/SelectDB/StarRocks) are saved as `db_type=mysql` with a
|
||||
* doris/starrocks `driver_profile`, and the transfer backend routes them through
|
||||
* the MySQL object family (catalog routing is driver_profile-aware); the
|
||||
* standalone `doris`/`starrocks` manifest entries are not transfer-capable.
|
||||
* Resolve those connections back to their raw db_type so they stay selectable in
|
||||
* the transfer dialog and keep the MySQL object kinds — the effective type alone
|
||||
* would drop them from the connection list and disable every non-table kind.
|
||||
*/
|
||||
export function transferDatabaseTypeForConnection(connection?: JdbcDialectConnection): DatabaseType | undefined {
|
||||
const effective = effectiveDatabaseTypeForConnection(connection);
|
||||
if (effective === "doris" || effective === "starrocks") return connection?.db_type;
|
||||
return effective;
|
||||
}
|
||||
|
||||
export function connectionUsesConnectionRootSchemaMode(connection?: JdbcDialectConnection): boolean {
|
||||
const type = effectiveDatabaseTypeForConnection(connection);
|
||||
return !!type && CONNECTION_ROOT_SCHEMA_TYPES.has(type);
|
||||
|
||||
Reference in new issue
Block a user