fix: handle legacy gbase driver_profile and add MCP driver_profile param

This commit is contained in:
t8y2 2026-06-18 01:45:33 +08:00
parent d6544ba4be
commit 4aa907d8b5
3 changed files with 12 additions and 6 deletions

View File

@ -28,15 +28,15 @@ export function inferJdbcDialect(connection?: JdbcDialectConnection): DatabaseTy
export function effectiveDatabaseTypeForConnection(connection?: JdbcDialectConnection): DatabaseType | undefined {
if (!connection) return undefined;
if (connection.db_type === "gbase" && connection.driver_profile === "gbase8a") return "mysql";
if (connection.db_type === "gbase" && connection.driver_profile === "gbase8s") return "informix";
if (connection.db_type === "gbase" && isGbase8sProfile(connection.driver_profile)) return "informix";
if (connection.db_type === "gbase") return "mysql";
if (connection.db_type !== "jdbc") return connection.db_type;
return inferJdbcDialect(connection) ?? "jdbc";
}
export function tableStructureDatabaseTypeForConnection(connection?: JdbcDialectConnection): DatabaseType | undefined {
if (!connection) return undefined;
if (connection.db_type === "gbase" && connection.driver_profile === "gbase8a") return "gbase";
if (connection.db_type === "gbase" && !isGbase8sProfile(connection.driver_profile)) return "gbase";
return effectiveDatabaseTypeForConnection(connection);
}
@ -55,14 +55,13 @@ export function connectionUsesSchemaExecutionContext(connection?: Pick<Connectio
}
export function connectionObjectTreeQuerySchema(connection: JdbcDialectConnection | undefined, database: string, schema?: string): string {
if (connection?.db_type === "gbase" && connection.driver_profile === "gbase8a") return "";
if (connection?.db_type === "jdbc" && inferJdbcDialect(connection) === "databend") return schema || database;
if (connectionUsesDatabaseObjectTreeMode(connection)) return "";
return schema || database;
}
export function connectionObjectTreeNodeSchema(connection: JdbcDialectConnection | undefined, database: string, schema?: string): string | undefined {
if (connection?.db_type === "gbase" && connection.driver_profile === "gbase8a") return undefined;
if (connection?.db_type === "jdbc" && inferJdbcDialect(connection) === "databend") return schema || database;
if (connection?.db_type === "jdbc" && inferJdbcDialect(connection) === "databend") return schema || database;
if (connectionUsesDatabaseObjectTreeMode(connection)) return undefined;
if (schema) return schema;
@ -76,3 +75,7 @@ export function codeMirrorSqlDialect(dbType: DatabaseType | undefined): "mysql"
if (dbType === "sqlserver") return "sqlserver";
return "mysql";
}
function isGbase8sProfile(driverProfile?: string): boolean {
return driverProfile === "gbase8s";
}

View File

@ -167,8 +167,9 @@ export function createDbxMcpServer(backend: Backend, options: { isWebMode?: bool
password: z.string().default("").describe("Password"),
database: z.string().optional().describe("Default database name"),
ssl: z.boolean().default(false).describe("Enable SSL"),
driver_profile: z.string().optional().describe("Driver profile (e.g. 'gbase8a', 'gbase8s')"),
},
async ({ name, db_type, host, port, username, password, database, ssl }) => {
async ({ name, db_type, host, port, username, password, database, ssl, driver_profile }) => {
const existing = await backend.findConnection(name);
if (existing) return text(`Connection "${name}" already exists.`);
const DEFAULT_PORTS: Record<string, number> = {
@ -189,6 +190,7 @@ export function createDbxMcpServer(backend: Backend, options: { isWebMode?: bool
password,
database,
ssl,
driver_profile,
ssh_enabled: false,
} as Omit<ConnectionConfig, "id">);
await notifyReload();

View File

@ -268,6 +268,7 @@ pub async fn cancel_transfer(transfer_id: String) -> Result<(), String> {
/// Sort table names by foreign key dependency.
/// `parents_first: true` → parent tables first (insert/export order).
/// `parents_first: false` → child tables first (drop order).
#[allow(dead_code)]
#[tauri::command]
pub async fn sort_tables_by_fk_dependency(
state: tauri::State<'_, std::sync::Arc<AppState>>,