mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-21 03:39:58 +00:00
fix(jdbc): use schema tree for inferred db2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ConnectionConfig, DatabaseType } from "@/types/database";
|
||||
import { isSchemaAware, usesDatabaseObjectTreeMode } from "@/lib/databaseFeatureSupport";
|
||||
import { isSchemaAware, usesDatabaseObjectTreeMode, usesTreeSchemaMode } from "@/lib/databaseFeatureSupport";
|
||||
|
||||
const JDBC_DIALECT_MATCHERS: Array<{ type: DatabaseType; patterns: RegExp[] }> = [
|
||||
{ type: "databend", patterns: [/jdbc:databend:/i, /com\.databend\.jdbc\.DatabendDriver/i, /databend-jdbc/i] },
|
||||
@@ -34,8 +34,10 @@ export function connectionUsesDatabaseObjectTreeMode(connection?: Pick<Connectio
|
||||
if (!connection) return false;
|
||||
if (connection.db_type !== "jdbc") return usesDatabaseObjectTreeMode(connection.db_type);
|
||||
const dialect = inferJdbcDialect(connection);
|
||||
if (!dialect) return true;
|
||||
if (dialect === "hive" || dialect === "trino") return false;
|
||||
return true;
|
||||
if (dialect === "databend") return true;
|
||||
return !usesTreeSchemaMode(dialect);
|
||||
}
|
||||
|
||||
export function connectionUsesSchemaExecutionContext(connection?: Pick<ConnectionConfig, "db_type" | "connection_string" | "jdbc_driver_class" | "jdbc_driver_paths">): boolean {
|
||||
|
||||
@@ -37,11 +37,15 @@ test("effective database type keeps non-JDBC types and enables compatible JDBC s
|
||||
test("JDBC tree shape follows the inferred driver dialect", () => {
|
||||
const kyuubi = { db_type: "jdbc" as const, jdbc_driver_class: "org.apache.kyuubi.jdbc.KyuubiHiveDriver" };
|
||||
const hive = { db_type: "jdbc" as const, jdbc_driver_class: "org.apache.hive.jdbc.HiveDriver" };
|
||||
const db2 = { db_type: "jdbc" as const, connection_string: "jdbc:db2://db.example.com:50000/SAMPLE" };
|
||||
|
||||
assert.equal(connectionUsesDatabaseObjectTreeMode(kyuubi), true);
|
||||
assert.equal(connectionObjectTreeQuerySchema(kyuubi, "test", undefined), "");
|
||||
assert.equal(connectionUsesDatabaseObjectTreeMode(hive), false);
|
||||
assert.equal(connectionObjectTreeQuerySchema(hive, "spark_catalog", "test"), "test");
|
||||
assert.equal(connectionUsesDatabaseObjectTreeMode(db2), false);
|
||||
assert.equal(connectionObjectTreeQuerySchema(db2, "SAMPLE", "APP"), "APP");
|
||||
assert.equal(connectionObjectTreeNodeSchema(db2, "SAMPLE", "APP"), "APP");
|
||||
assert.equal(
|
||||
qualifiedTableName({
|
||||
databaseType: effectiveDatabaseTypeForConnection(hive),
|
||||
|
||||
Reference in New Issue
Block a user