mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-19 16:16:45 +00:00
@@ -5,12 +5,15 @@ import { buildGetDatabaseCommentSql } from "@/lib/database/dbAdminSql";
|
||||
import {
|
||||
defaultAutoCommitForDbType,
|
||||
isSchemaAware,
|
||||
supportsConnectionQueryActions,
|
||||
supportsConnectionScopedQueryExecution,
|
||||
supportsConnectionDatabaseBrowser,
|
||||
supportsDatabaseNameCompletion,
|
||||
supportsDatabaseSchemaQualifier,
|
||||
supportsDatabaseSearch,
|
||||
supportsObjectBrowser,
|
||||
supportsObjectBrowserTreeNode,
|
||||
supportsQueryExecution,
|
||||
supportsQueryTargetDatabaseListing,
|
||||
supportsQueryEditorBlockComments,
|
||||
supportsSqlInListPaste,
|
||||
@@ -81,6 +84,32 @@ describe("connection-scoped query targets", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("connection query actions", () => {
|
||||
it("keeps SQL query surfaces available for ordinary databases", () => {
|
||||
expect(supportsConnectionQueryActions("mysql")).toBe(true);
|
||||
expect(supportsConnectionQueryActions("postgres")).toBe(true);
|
||||
expect(supportsConnectionQueryActions("redis")).toBe(true);
|
||||
expect(supportsConnectionQueryActions(undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it("hides the sidebar new-query entry for specialized surfaces without a query engine", () => {
|
||||
expect(supportsConnectionQueryActions("nacos")).toBe(false);
|
||||
expect(supportsConnectionQueryActions("consul")).toBe(false);
|
||||
expect(supportsConnectionQueryActions("hbase")).toBe(false);
|
||||
expect(supportsConnectionQueryActions("zookeeper")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("zookeeper query capabilities", () => {
|
||||
it("does not advertise query execution or schema search for the kv-only agent", () => {
|
||||
// The ZooKeeper agent exposes only kv_* operations: no list-databases or
|
||||
// query method exists, so the manifest must not claim either capability
|
||||
// (issue #8215: "new query" errored calling list-databases).
|
||||
expect(supportsQueryExecution("zookeeper")).toBe(false);
|
||||
expect(supportsDatabaseSearch("zookeeper")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("database and schema qualifiers", () => {
|
||||
it.each(["sqlserver", "trino", "prestosql"] as const)("supports three-part object names for %s", (databaseType) => {
|
||||
expect(supportsDatabaseSchemaQualifier(databaseType)).toBe(true);
|
||||
|
||||
@@ -112,8 +112,14 @@ export function supportsClearableQuerySchema(dbType?: DatabaseType): boolean {
|
||||
return !!dbType && CLEARABLE_QUERY_SCHEMA_TYPES.has(dbType);
|
||||
}
|
||||
|
||||
/**
|
||||
* ZooKeeper has no query surface: its agent implements only kv_* operations,
|
||||
* so the sidebar "new query" flow would call list-databases and fail
|
||||
* (issue #8215). It is excluded alongside the other specialized surfaces
|
||||
* (nacos, consul, hbase) whose connection workbench replaces query tabs.
|
||||
*/
|
||||
export function supportsConnectionQueryActions(dbType?: DatabaseType): boolean {
|
||||
return dbType !== "nacos" && dbType !== "consul" && dbType !== "hbase";
|
||||
return dbType !== "nacos" && dbType !== "consul" && dbType !== "hbase" && dbType !== "zookeeper";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2446,11 +2446,11 @@
|
||||
"defaultPort": 2181,
|
||||
"supportLevel": "connect",
|
||||
"capabilities": {
|
||||
"queryExecution": true,
|
||||
"queryExecution": false,
|
||||
"metadataBrowse": false,
|
||||
"objectBrowser": false,
|
||||
"objectSource": false,
|
||||
"schemaSearch": true,
|
||||
"schemaSearch": false,
|
||||
"diagram": false,
|
||||
"tableDataEdit": false,
|
||||
"tableStructureEdit": false,
|
||||
|
||||
@@ -336,7 +336,11 @@ fn driver_manifest_declares_expected_product_capabilities() {
|
||||
assert_eq!(zookeeper.runtime_mode, "agent");
|
||||
assert_eq!(zookeeper.agent_key.as_deref(), Some("zookeeper"));
|
||||
assert_eq!(zookeeper.support_level, "connect");
|
||||
assert!(zookeeper.capabilities.query_execution);
|
||||
// ZooKeeper has no SQL engine and its agent implements only kv_* operations;
|
||||
// claiming query execution or schema search made "new query" call
|
||||
// list-databases on an agent that does not support it (issue #8215).
|
||||
assert!(!zookeeper.capabilities.query_execution);
|
||||
assert!(!zookeeper.capabilities.schema_search);
|
||||
assert!(zookeeper.capabilities.driver_management);
|
||||
assert!(!zookeeper.capabilities.metadata_browse);
|
||||
|
||||
|
||||
@@ -14,11 +14,15 @@ skipTcpProbe: true
|
||||
defaultPort: 2181
|
||||
supportLevel: connect
|
||||
capabilities:
|
||||
queryExecution: true
|
||||
# ZooKeeper has no SQL engine and its agent exposes only kv_* operations:
|
||||
# no list_databases or query method exists, so query execution and schema
|
||||
# search must stay off (issue #8215: "new query" errored calling
|
||||
# list-databases on a ZooKeeper connection).
|
||||
queryExecution: false
|
||||
metadataBrowse: false
|
||||
objectBrowser: false
|
||||
objectSource: false
|
||||
schemaSearch: true
|
||||
schemaSearch: false
|
||||
diagram: false
|
||||
tableDataEdit: false
|
||||
tableStructureEdit: false
|
||||
|
||||
Reference in New Issue
Block a user