Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(gbase8s): discover and display views without owner prefix (#12302) (#12510)

lxk9558e78b8f39c4e
diff --git a/agents/drivers/gbase8s/src/main/java/com/dbx/agent/gbase8s/Gbase8sAgent.java b/agents/drivers/gbase8s/src/main/java/com/dbx/agent/gbase8s/Gbase8sAgent.java
index 7fe210f4b0..85967ba150 100644
--- a/agents/drivers/gbase8s/src/main/java/com/dbx/agent/gbase8s/Gbase8sAgent.java
+++ b/agents/drivers/gbase8s/src/main/java/com/dbx/agent/gbase8s/Gbase8sAgent.java
@@ -9,8 +9,10 @@ import com.dbx.agent.JdbcAgentProfile;
import com.dbx.agent.MultiSessionJsonRpcServer;
import com.dbx.agent.IndexInfo;
import com.dbx.agent.MetadataListConstraints;
+import com.dbx.agent.ObjectInfo;
import com.dbx.agent.ObjectSource;
import com.dbx.agent.QueryResult;
+import com.dbx.agent.StandardJdbcMetadata;
import com.dbx.agent.TableInfo;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -501,6 +503,19 @@ public final class Gbase8sAgent extends ConfiguredJdbcAgent {
return queryConstrainedTables(schema, normalized);
}
+ @Override
+ public List<ObjectInfo> listObjects(String schema) {
+ return listObjects(schema, MetadataListConstraints.NONE);
+ }
+
+ @Override
+ public List<ObjectInfo> listObjects(String schema, MetadataListConstraints constraints) {
+ MetadataListConstraints normalized = MetadataListConstraints.orNone(constraints);
+ String resolved = schema == null ? "" : schema.trim();
+ List<TableInfo> tables = listTables(resolved, normalized);
+ return normalized.filterObjects(StandardJdbcMetadata.INSTANCE.listObjects(tables, resolved));
+ }
+
@Override
public List<ColumnInfo> getColumns(String schema, String table) {
try {
diff --git a/agents/drivers/gbase8s/src/test/java/com/dbx/agent/gbase8s/Gbase8sAgentTest.java b/agents/drivers/gbase8s/src/test/java/com/dbx/agent/gbase8s/Gbase8sAgentTest.java
index 765cde6275..7a20684f44 100644
--- a/agents/drivers/gbase8s/src/test/java/com/dbx/agent/gbase8s/Gbase8sAgentTest.java
+++ b/agents/drivers/gbase8s/src/test/java/com/dbx/agent/gbase8s/Gbase8sAgentTest.java
@@ -5,6 +5,7 @@ import com.dbx.agent.ColumnInfo;
import com.dbx.agent.DdlBuilder;
import com.dbx.agent.IndexInfo;
import com.dbx.agent.MetadataListConstraints;
+import com.dbx.agent.ObjectInfo;
import com.dbx.agent.ObjectSource;
import com.dbx.agent.TableInfo;
import com.dbx.agent.test.TestSupport;
@@ -337,6 +338,51 @@ class Gbase8sAgentTest {
Assertions.assertTrue(sql.get(0).contains("t.owner = ?"), sql.get(0));
}
+ @Test
+ void listObjectsLoadsGbase8sTablesAndViews() {
+ List<String> sql = new ArrayList<>();
+ Gbase8sAgent agent = new Gbase8sAgent();
+ TestSupport.setPrivateConnection(agent, preparedConnection(sql, resultSet(
+ new String[]{"tabname", "tabtype", "comments"},
+ new Object[][]{
+ {"users", "T", "User table"},
+ {"v_active_users", "V", "Active users view"}
+ }
+ )));
+
+ List<ObjectInfo> objects = agent.listObjects("root");
+
+ Assertions.assertEquals(2, objects.size());
+ Assertions.assertEquals("users", objects.get(0).getName());
+ Assertions.assertEquals("TABLE", objects.get(0).getObject_type());
+ Assertions.assertEquals("v_active_users", objects.get(1).getName());
+ Assertions.assertEquals("VIEW", objects.get(1).getObject_type());
+ Assertions.assertTrue(sql.get(0).contains("FROM systables"));
+ }
+
+ @Test
+ void constrainedListObjectsFiltersGbase8sViews() {
+ List<String> sql = new ArrayList<>();
+ Gbase8sAgent agent = new Gbase8sAgent();
+ TestSupport.setPrivateConnection(agent, preparedConnection(sql, resultSet(
+ new String[]{"tabname", "tabtype", "comments"},
+ new Object[][]{
+ {"v_orders", "V", null}
+ }
+ )));
+
+ List<ObjectInfo> objects = agent.listObjects(
+ "gbasedbt",
+ new MetadataListConstraints(null, null, null, List.of("VIEW"))
+ );
+
+ Assertions.assertEquals(1, objects.size());
+ Assertions.assertEquals("v_orders", objects.get(0).getName());
+ Assertions.assertEquals("VIEW", objects.get(0).getObject_type());
+ Assertions.assertTrue(sql.get(0).contains("FROM systables"));
+ Assertions.assertTrue(sql.get(0).contains("tabtype IN ('V')"));
+ }
+
@Test
void extractsPrimaryKeyColumnNumbersFromGbase8sIndexParts() {
Assertions.assertEquals(
diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue
index c521d4e63f..48d07fca53 100644
--- a/apps/desktop/src/components/objects/ObjectBrowser.vue
+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue
@@ -2079,12 +2079,12 @@ async function openNewQuery(row: ObjectBrowserRow) {
tabId,
await buildTableSelectSql({
databaseType: effectiveDatabaseType.value,
- driverProfile: props.connection.driver_profile,
+ driverProfile: props.connection.driver_profile || (props.connection.db_type === "gbase8s" ? "gbase8s" : undefined),
serverVersion: props.connection.database_info?.productVersion,
identifierQuote: connectionStore.connectionIdentifierQuote?.(props.connection.id),
catalog: props.catalog,
database: props.database,
- schema,
+ schema: connectionTableSqlSchema(props.connection, schema),
tableName: row.name,
includeDatabaseName: settingsStore.editorSettings.generateSqlIncludeDatabaseName,
limit: 100,
diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
index 83d959c366..cbd25d0ee2 100644
--- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
+++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
@@ -2489,7 +2489,7 @@ async function openSidebarMultiTableDdlTab(targets: Array<TreeNode & { connectio
return buildViewDdl({
databaseType: databaseTypeForNode(target),
identifierQuote: connectionStore.connectionIdentifierQuote?.(target.connectionId),
- schema,
+ schema: connectionTableSqlSchema(connectionStore.getConfig(target.connectionId), schema),
name: target.label,
source: result.source,
});
@@ -2878,10 +2878,11 @@ function dropObjectSqlOptions(): DropObjectSqlOptions | null {
function dropObjectSqlOptionsForNode(node: TreeNode): DropObjectSqlOptions | null {
if (node.type !== "view" && node.type !== "materialized_view" && node.type !== "procedure" && node.type !== "function" && node.type !== "event") return null;
+ const config = node.connectionId ? connectionStore.getConfig(node.connectionId) : undefined;
return {
databaseType: tableStructureDatabaseTypeForNode(node),
objectType: node.type === "view" ? "VIEW" : node.type === "materialized_view" ? "MATERIALIZED_VIEW" : node.type === "procedure" ? "PROCEDURE" : node.type === "function" ? "FUNCTION" : "EVENT",
- schema: node.schema,
+ schema: connectionTableSqlSchema(config, node.schema),
name: node.objectName || node.label,
signature: node.signature,
// Cloud Spanner's dialect decides the quote; the static per-type mapping cannot.
diff --git a/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts b/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts
index 145aadfa10..9709e5a7e3 100644
--- a/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts
+++ b/apps/desktop/src/composables/__tests__/useSidebarDataOpenRuntime.spec.ts
@@ -117,6 +117,7 @@ vi.mock("@/lib/database/jdbcDialect", () => ({
effectiveDatabaseTypeForConnection: () => mocks.databaseType,
connectionObjectTreeNodeSchema: (_config: unknown, _database: string, schema?: string) => schema,
connectionObjectTreeQuerySchema: (_config: unknown, database: string, schema?: string) => schema ?? database,
+ connectionTableSqlSchema: (_config: unknown, schema?: string) => schema,
}));
vi.mock("@/lib/metadata/tableMetadataCache", async (importOriginal) => {
diff --git a/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts b/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts
index 87470e02bf..6a36f71a53 100644
--- a/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts
+++ b/apps/desktop/src/composables/useSidebarDataOpenRuntime.ts
@@ -6,7 +6,7 @@ import { useTunnelProfileStore } from "@/stores/tunnelProfileStore";
import type { TreeNode } from "@/types/database";
import { uuid } from "@/lib/common/utils";
import { appendDebugLog, isDebugLoggingEnabled } from "@/lib/backend/debugLog";
-import { effectiveDatabaseTypeForConnection, connectionObjectTreeNodeSchema, connectionObjectTreeQuerySchema } from "@/lib/database/jdbcDialect";
+import { effectiveDatabaseTypeForConnection, connectionObjectTreeNodeSchema, connectionObjectTreeQuerySchema, connectionTableSqlSchema } from "@/lib/database/jdbcDialect";
import { getCachedTableMetadata, loadTableMetadata, TABLE_METADATA_CACHE_TTL_MS, tableMetadataToDataTabMeta } from "@/lib/metadata/tableMetadataCache";
import { canApplyDataTabMetadata, dataTabMetadataNeedsRefresh, findExistingDataTabCandidate, isDataTabMetadataLifecycleStale, type DataTabOpenMode, type DataTabReuseMode } from "@/lib/sidebar/dataTabOpenPolicy";
import type { SidebarDataOpenRequest } from "@/lib/sidebar/sidebarDataOpenCoordinator";
@@ -406,10 +406,10 @@ export function useSidebarDataOpenRuntime() {
const includeRowId = shouldIncludeSyntheticRowId(effectiveDbType, primaryKeys, tableType);
const sql = await buildTableSelectSql({
databaseType: effectiveDbType,
- driverProfile: config?.driver_profile,
+ driverProfile: config?.driver_profile || (config?.db_type === "gbase8s" ? "gbase8s" : undefined),
serverVersion: connectionStore.getConfig(node.connectionId)?.database_info?.productVersion,
identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
- schema: tableSchema,
+ schema: connectionTableSqlSchema(config, tableSchema),
database: node.database,
tableName: node.label,
tableType,
diff --git a/apps/desktop/src/lib/__tests__/database/databaseObjectCapabilities.spec.ts b/apps/desktop/src/lib/__tests__/database/databaseObjectCapabilities.spec.ts
index 5532065916..80507beb50 100644
--- a/apps/desktop/src/lib/__tests__/database/databaseObjectCapabilities.spec.ts
+++ b/apps/desktop/src/lib/__tests__/database/databaseObjectCapabilities.spec.ts
@@ -173,4 +173,17 @@ describe("databaseObjectCapabilities", () => {
expect(schemaDiffRoutineObjectTypesIntersection("postgres", "opengauss")).toEqual(["PROCEDURE", "FUNCTION"]);
expect(sidebarObjectKindsForDatabase("sqlserver")).toEqual(["TABLE", "VIEW", "PROCEDURE", "FUNCTION"]);
});
+
+ it("gates sidebar object kinds per engine", () => {
+ // GBase 8s only lists tables and views.
+ expect(sidebarObjectKindsForDatabase("gbase8s")).toEqual(["TABLE", "VIEW"]);
+ expect(databaseObjectCapabilities("gbase8s").sourceReadable).toEqual(["VIEW"]);
+ // Native Informix lists procedures/functions from sysprocedures natively.
+ for (const dbType of ["gbase", "informix"] as const) {
+ // "gbase" has no explicit entry: in production it resolves to the "mysql"
+ // effective type, so direct callers hit the unknown-type ROUTINE_OBJECTS fallback.
+ expect(sidebarObjectKindsForDatabase(dbType)).toEqual(["TABLE", "VIEW", "PROCEDURE", "FUNCTION"]);
+ expect(databaseObjectCapabilities(dbType).sourceReadable).toEqual(["VIEW", "PROCEDURE", "FUNCTION"]);
+ }
+ });
});
diff --git a/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts b/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts
index 781164ed6b..a5f095f032 100644
--- a/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts
+++ b/apps/desktop/src/lib/__tests__/database/jdbcDialect.spec.ts
@@ -234,6 +234,8 @@ describe("jdbc dialect inference", () => {
it("omits the metadata owner from GBase 8s table SQL", () => {
expect(connectionTableSqlSchema({ db_type: "gbase8s", driver_profile: "gbase8s" }, "gbasedbt")).toBeUndefined();
+ expect(connectionTableSqlSchema({ db_type: "gbase8s" }, "gbasedbt")).toBeUndefined();
+ expect(connectionTableSqlSchema({ db_type: "informix", driver_profile: "gbase8s" }, "gbasedbt")).toBeUndefined();
expect(connectionTableSqlSchema({ db_type: "gbase", driver_profile: "gbase8a" }, "analytics")).toBe("analytics");
expect(connectionTableSqlSchema({ db_type: "informix", driver_profile: "informix" }, "informix")).toBe("informix");
});
diff --git a/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts b/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts
index 9a3acf23df..4f06c22605 100644
--- a/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts
+++ b/apps/desktop/src/lib/__tests__/table/tableSelectSql.spec.ts
@@ -273,7 +273,9 @@ describe("tableMetaWithoutOptionalDatabaseQualifier — copy extractors (#9326)"
describe("qualifiedTableName — GBase 8s", () => {
it("omits the metadata owner for GBase 8s table data", () => {
expect(qualifiedTableName({ databaseType: "informix", driverProfile: "gbase8s", identifierQuote: "", schema: "gbasedbt", tableName: "connection_smoke" })).toBe("connection_smoke");
+ expect(qualifiedTableName({ databaseType: "gbase8s", identifierQuote: "", schema: "gbasedbt", tableName: "connection_smoke" })).toBe("connection_smoke");
expect(quoteTableDataIdentifier("informix", "connection_smoke", "")).toBe("connection_smoke");
+ expect(quoteTableDataIdentifier("gbase8s", "connection_smoke", "")).toBe("connection_smoke");
});
it("keeps native Informix owner qualification", () => {
diff --git a/apps/desktop/src/lib/database/databaseObjectCapabilities.ts b/apps/desktop/src/lib/database/databaseObjectCapabilities.ts
index 5498de6b99..30ffefe10b 100644
--- a/apps/desktop/src/lib/database/databaseObjectCapabilities.ts
+++ b/apps/desktop/src/lib/database/databaseObjectCapabilities.ts
@@ -70,6 +70,10 @@ const DATABASE_TYPE_OBJECTS = new Map<DatabaseType, SidebarObjectKind[]>([
["cloudflare-d1", TABLE_VIEW_OBJECTS],
["duckdb", TABLE_VIEW_OBJECTS],
["clickhouse", TABLE_VIEW_OBJECTS],
+ ["gbase8s", TABLE_VIEW_OBJECTS],
+ // Informix lists procedures/functions from sysprocedures natively, so keep
+ // the routine-capable set here instead of the TABLE/VIEW-only one.
+ ["informix", ROUTINE_OBJECTS],
// Doris: backend listing path still uses the generic SHOW TABLES path (see
// `list_tables_once` for `PoolKind::Mysql` in crates/dbx-core/src/schema/mod.rs)
// and lacks a MV classifier. Keep Doris on TABLE_VIEW_OBJECTS until a
diff --git a/apps/desktop/src/lib/database/jdbcDialect.ts b/apps/desktop/src/lib/database/jdbcDialect.ts
index 062f9d7c38..478a2a3f74 100644
--- a/apps/desktop/src/lib/database/jdbcDialect.ts
+++ b/apps/desktop/src/lib/database/jdbcDialect.ts
@@ -394,7 +394,7 @@ export function connectionObjectTreeNodeSchema(connection: JdbcDialectConnection
/** GBase 8s reports the table owner as a schema, but does not accept it in table DML/DDL names. */
export function connectionTableSqlSchema(connection: JdbcDialectConnection | undefined, schema?: string): string | undefined {
- if (connection?.db_type === "gbase8s") return undefined;
+ if (connection?.db_type === "gbase8s" || isGbase8sProfile(connection?.driver_profile)) return undefined;
return schema;
}
diff --git a/apps/desktop/src/lib/table/tableSelectSql.ts b/apps/desktop/src/lib/table/tableSelectSql.ts
index a7139babb3..7bdd02f469 100644
--- a/apps/desktop/src/lib/table/tableSelectSql.ts
+++ b/apps/desktop/src/lib/table/tableSelectSql.ts
@@ -122,7 +122,7 @@ export function quoteTableIdentifier(databaseType: DatabaseType | undefined, nam
databaseType === "goldendb"
)
return `\`${name.replace(/`/g, "``")}\``;
- if (databaseType === "informix" && /^[A-Za-z_][A-Za-z0-9_$]*$/.test(name)) return name;
+ if ((databaseType === "informix" || databaseType === "gbase8s") && /^[A-Za-z_][A-Za-z0-9_$]*$/.test(name)) return name;
if (databaseType === "neo4j") return quoteCypherIdentifier(name);
if (databaseType === "sqlserver") return `[${name.replace(/\]/g, "]]")}]`;
return `"${name.replace(/"/g, '""')}"`;
@@ -134,7 +134,7 @@ export function quoteTableDataIdentifier(databaseType: DatabaseType | undefined,
return `${identifierQuote}${name.replaceAll(identifierQuote, identifierQuote + identifierQuote)}${identifierQuote}`;
}
if ((databaseType === "gaussdb" || databaseType === "opengauss" || databaseType === "postgres") && identifierQuote != null) return quoteGaussDbJdbcIdentifier(name, identifierQuote);
- if ((databaseType === "kingbase" || databaseType === "informix" || databaseType === "spanner") && identifierQuote != null) {
+ if ((databaseType === "kingbase" || databaseType === "informix" || databaseType === "gbase8s" || databaseType === "spanner") && identifierQuote != null) {
if (!identifierQuote) return name;
return `${identifierQuote}${name.replaceAll(identifierQuote, identifierQuote + identifierQuote)}${identifierQuote}`;
}
@@ -205,7 +205,7 @@ export function qualifiedTableName(options: Pick<BuildTableSelectSqlOptions, "da
const { databaseType, driverProfile, identifierQuote, schema, tableName, catalog, database, includeDatabaseName, quoteIdentifiers } = options;
const quoteTable = (name: string) => (quoteIdentifiers === false ? quoteTableIdentifierIfNeeded(databaseType, name, identifierQuote) : quoteTableIdentifier(databaseType, name));
const quoteTableData = (name: string) => (quoteIdentifiers === false ? quoteTableIdentifierIfNeeded(databaseType, name, identifierQuote) : quoteTableDataIdentifier(databaseType, name, identifierQuote));
- if (databaseType === "informix" && driverProfile?.trim().toLowerCase() === "gbase8s") {
+ if (databaseType === "gbase8s" || (databaseType === "informix" && driverProfile?.trim().toLowerCase() === "gbase8s")) {
return quoteTableData(tableName);
}
// Doris / StarRocks multi-catalog: address external-catalog tables with the
diff --git a/crates/dbx-core/assets/database-drivers.manifest.json b/crates/dbx-core/assets/database-drivers.manifest.json
index d260ec43e0..805c60bb3b 100644
--- a/crates/dbx-core/assets/database-drivers.manifest.json
+++ b/crates/dbx-core/assets/database-drivers.manifest.json
@@ -1847,7 +1847,7 @@
"queryExecution": true,
"metadataBrowse": true,
"objectBrowser": true,
- "objectSource": false,
+ "objectSource": true,
"schemaSearch": true,
"diagram": true,
"tableDataEdit": true,
diff --git a/crates/dbx-core/src/data/data_compare.rs b/crates/dbx-core/src/data/data_compare.rs
index 21581e3917..2cac03f9ea 100644
--- a/crates/dbx-core/src/data/data_compare.rs
+++ b/crates/dbx-core/src/data/data_compare.rs
@@ -1532,6 +1532,10 @@ fn build_limited_sampling_select_sql(
let order = order_by.map(|order_by| format!(" ORDER BY {order_by}")).unwrap_or_default();
format!("SELECT TOP ({row_limit}) {select_columns} FROM {table}{order}")
}
+ TablePaginationStrategy::InformixFirst => {
+ let order = order_by.map(|order_by| format!(" ORDER BY {order_by}")).unwrap_or_default();
+ format!("SELECT FIRST {row_limit} {select_columns} FROM {table}{order}")
+ }
_ => {
let order = order_by.map(|order_by| format!(" ORDER BY {order_by}")).unwrap_or_default();
format!("SELECT {select_columns} FROM {table}{order} LIMIT {row_limit}")
@@ -1633,7 +1637,7 @@ fn build_sampling_select_sql(
DatabaseType::Questdb => {
format!("SELECT {select_columns} FROM {table} ORDER BY RAND() LIMIT {sample_size}")
}
- DatabaseType::Informix => {
+ DatabaseType::Informix | DatabaseType::Gbase8s => {
format!("SELECT FIRST {sample_size} {select_columns} FROM {table} ORDER BY RAND()")
}
_ => {
@@ -1730,7 +1734,7 @@ fn build_sampling_select_sql(
DatabaseType::Questdb => {
format!("SELECT {select_columns} FROM {table} ORDER BY RAND() LIMIT {random_count}")
}
- DatabaseType::Informix => {
+ DatabaseType::Informix | DatabaseType::Gbase8s => {
format!("SELECT FIRST {random_count} {select_columns} FROM {table} ORDER BY RAND()")
}
_ => {
@@ -3178,6 +3182,26 @@ mod tests {
assert!(!sql.contains(" LIMIT "));
}
+ #[test]
+ fn builds_gbase8s_hybrid_sampling_sql_with_first() {
+ for database_type in [DatabaseType::Informix, DatabaseType::Gbase8s] {
+ let sql = build_sampling_select_sql(
+ database_type,
+ "gbasedbt",
+ "events",
+ &["id".to_string(), "name".to_string()],
+ &["id".to_string()],
+ &SamplingStrategy::Hybrid,
+ 10,
+ );
+
+ assert!(sql.contains("SELECT FIRST 5 id, name FROM"));
+ assert!(sql.contains("SELECT FIRST 2 id, name FROM"));
+ assert!(sql.contains("SELECT FIRST 3 id, name FROM"));
+ assert!(!sql.contains(" LIMIT "));
+ }
+ }
+
#[test]
fn degradation_chain_full_for_small_table() {
let threshold = DegradationThreshold::default();
diff --git a/crates/dbx-sql-core/src/object_source_sql.rs b/crates/dbx-sql-core/src/object_source_sql.rs
index 1ae3cc547e..88153717b1 100644
--- a/crates/dbx-sql-core/src/object_source_sql.rs
+++ b/crates/dbx-sql-core/src/object_source_sql.rs
@@ -563,7 +563,9 @@ fn build_executable_object_source_statements_with_mysql_validation_name(
return Ok(vec![executable_oracle_routine_ddl(source)]);
}
- if input.database_type == DatabaseType::Informix && input.object_type == ObjectSourceKind::View {
+ if matches!(input.database_type, DatabaseType::Informix | DatabaseType::Gbase8s)
+ && input.object_type == ObjectSourceKind::View
+ {
return Ok(executable_informix_view_statements(input.schema.as_deref(), &input.name, source));
}
@@ -774,7 +776,9 @@ pub fn build_editable_object_source(input: EditableObjectSourceSqlInput) -> Stri
// Some providers return full view DDL instead of a bare SELECT body.
return ensure_semicolon(source.trim());
}
- if input.database_type == DatabaseType::Informix && input.object_type == ObjectSourceKind::View {
+ if matches!(input.database_type, DatabaseType::Informix | DatabaseType::Gbase8s)
+ && input.object_type == ObjectSourceKind::View
+ {
return editable_informix_view_ddl(input.schema.as_deref(), &input.name, &source);
}
if is_mysql_like(input.database_type)
@@ -2727,6 +2731,19 @@ mod tests {
assert_eq!(sql, "CREATE VIEW demo_view as select id from users;");
}
+ #[test]
+ fn gbase8s_view_source_opened_for_editing_shows_unqualified_create_view() {
+ let sql = build_editable_object_source(EditableObjectSourceSqlInput {
+ database_type: DatabaseType::Gbase8s,
+ object_type: ObjectSourceKind::View,
+ schema: Some("gbasedbt".to_string()),
+ name: "v_orders".to_string(),
+ source: "create view \"gbasedbt\".v_orders as select id from orders".to_string(),
+ });
+
+ assert_eq!(sql, "CREATE VIEW v_orders as select id from orders;");
+ }
+
#[test]
fn view_ddl_wraps_postgres_body_as_create_or_replace_view() {
let sql = build_view_ddl_sql(BuildViewDdlInput {
diff --git a/crates/dbx-sql-dialect/src/sql_dialect/identifiers.rs b/crates/dbx-sql-dialect/src/sql_dialect/identifiers.rs
index 4c2035b4fd..34b2176b2e 100644
--- a/crates/dbx-sql-dialect/src/sql_dialect/identifiers.rs
+++ b/crates/dbx-sql-dialect/src/sql_dialect/identifiers.rs
@@ -48,7 +48,8 @@ pub fn qualified_table_name(database_type: Option<DatabaseType>, schema: Option<
}
return table_name;
}
- let supports_qualifier = database_type.is_some_and(is_schema_aware)
+ let supports_qualifier = (database_type.is_some_and(is_schema_aware)
+ && database_type != Some(DatabaseType::Gbase8s))
|| matches!(
database_type,
Some(DatabaseType::Mysql | DatabaseType::Goldendb | DatabaseType::StarRocks | DatabaseType::Doris)
diff --git a/crates/dbx-sql-dialect/src/sql_dialect/table_select.rs b/crates/dbx-sql-dialect/src/sql_dialect/table_select.rs
index 16939cf223..f7c585aab5 100644
--- a/crates/dbx-sql-dialect/src/sql_dialect/table_select.rs
+++ b/crates/dbx-sql-dialect/src/sql_dialect/table_select.rs
@@ -557,6 +557,9 @@ pub fn table_data_qualified_table_name(
.map(|schema| format!("{}.{table}", quote_iris_identifier(schema, identifier_quote)))
.unwrap_or(table);
}
+ if database_type == Some(DatabaseType::Gbase8s) {
+ return quote_table_data_identifier(database_type, table_name, identifier_quote);
+ }
if !uses_connection_identifier_quote(database_type, identifier_quote) {
return qualified_table_name(database_type, schema, table_name);
}
diff --git a/crates/dbx-sql-dialect/src/sql_dialect/tests.rs b/crates/dbx-sql-dialect/src/sql_dialect/tests.rs
index fedd4b45b5..8ba9f8252e 100644
--- a/crates/dbx-sql-dialect/src/sql_dialect/tests.rs
+++ b/crates/dbx-sql-dialect/src/sql_dialect/tests.rs
@@ -711,6 +711,32 @@ fn builds_table_data_where_and_schema_queries() {
}),
"SELECT FIRST 100 * FROM gbasedbt.connection_smoke"
);
+ assert_eq!(
+ build_table_data_select_sql(TableDataSelectSqlOptions {
+ database_type: Some(DatabaseType::Gbase8s),
+ schema: Some("gbasedbt".to_string()),
+ table_name: "v_orders".to_string(),
+ limit: Some(100),
+ ..Default::default()
+ }),
+ "SELECT FIRST 100 * FROM v_orders"
+ );
+ assert_eq!(
+ build_table_data_select_sql(TableDataSelectSqlOptions {
+ database_type: Some(DatabaseType::Gbase8s),
+ identifier_quote: Some(String::new()),
+ schema: Some("gbasedbt".to_string()),
+ table_name: "v_orders".to_string(),
+ limit: Some(100),
+ ..Default::default()
+ }),
+ "SELECT FIRST 100 * FROM v_orders"
+ );
+ assert_eq!(
+ build_count_table_sql(Some(DatabaseType::Gbase8s), Some("gbasedbt"), "v_orders"),
+ "SELECT COUNT(*) AS row_count FROM v_orders"
+ );
+ assert_eq!(qualified_table_name(Some(DatabaseType::Gbase8s), Some("gbasedbt"), "v_orders"), "v_orders");
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::Gaussdb),
diff --git a/plugins/connection-types/gbase8s.yaml b/plugins/connection-types/gbase8s.yaml
index 1a50039bdf..6c367755d8 100644
--- a/plugins/connection-types/gbase8s.yaml
+++ b/plugins/connection-types/gbase8s.yaml
@@ -22,7 +22,7 @@ capabilities:
queryExecution: true
metadataBrowse: true
objectBrowser: true
- objectSource: false
+ objectSource: true
schemaSearch: true
diagram: true
tableDataEdit: true