fix(gbase8s): omit owner qualifier in table admin SQL

This commit is contained in:
New2Niu authored and GitHub committed 2026-09-14 14:52:13 +08:00
1 parent 6d866905b5
commit 1533064f1f
6 files changed
+37 -10

No files matched your search

@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { shallowRef } from "vue";
import type { TreeNode } from "@/types/database";
import type { ConnectionConfig, DatabaseType, TreeNode } from "@/types/database";
import { dropTableCascade, dropTablePreviewSql, emptyTablePreviewSql, sidebarDangerRunningCancel, sidebarDangerRunningExecutionId, sidebarDangerTarget, truncateTableCascade, truncateTablePreviewSql } from "@/components/sidebar/sidebarTreeDialogState";
const mocks = vi.hoisted(() => ({
@@ -49,19 +49,20 @@ function tableNode(database: string | null | undefined): TreeNode {
} as TreeNode;
}
function runtime(database: string | null | undefined) {
function runtime(database: string | null | undefined, config: Pick<ConnectionConfig, "db_type"> & Partial<Pick<ConnectionConfig, "driver_profile">> = { db_type: "saphana" }, databaseType: DatabaseType = "saphana") {
const node = tableNode(database);
const activeNode = shallowRef(node);
const connectionStore = {
ensureConnected: mocks.ensureConnected,
getConfig: () => config,
removeTreeNode: mocks.removeTreeNode,
} as any;
const feature = useSidebarTableMutationRuntime({
activeNode,
releaseActiveNodeReference: mocks.releaseActiveNodeReference,
connectionStore,
currentDatabaseType: () => "saphana",
databaseTypeForNode: () => "saphana",
currentDatabaseType: () => databaseType,
databaseTypeForNode: () => databaseType,
executeWithProductionGuard: mocks.executeWithProductionGuard,
closeDroppedTableObjectTabsForNode: mocks.closeDroppedTableObjectTabsForNode,
refreshMutatedTableDataTabsForNode: mocks.refreshMutatedTableDataTabsForNode,
@@ -121,6 +122,14 @@ describe("useSidebarTableMutationRuntime SAP HANA schema-scoped actions", () =>
expect(mocks.releaseActiveNodeReference).toHaveBeenCalledWith([node.id]);
});
it("omits the GBase 8s metadata owner from generated table SQL", async () => {
const { feature } = runtime("tenant", { db_type: "gbase", driver_profile: "gbase8s" }, "informix");
await feature.confirmDropTable();
expect(mocks.buildDropTableSql).toHaveBeenCalledWith(expect.objectContaining({ databaseType: "informix", schema: undefined, tableName: "ORDERS" }));
});
it.each(["confirmEmptyTable", "confirmTruncateTable"] as const)("refreshes data tabs after %s", async (action) => {
const { feature, node } = runtime("");
@@ -19,6 +19,7 @@ import {
type VacuumTableSqlOptions,
} from "@/lib/database/dbAdminSql";
import { isSqlServerLinkedNode } from "@/lib/database/sqlServerLinkedServers";
import { connectionTableSqlSchema } from "@/lib/database/jdbcDialect";
import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
import { uuid } from "@/lib/common/utils";
import * as api from "@/lib/backend/api";
@@ -74,9 +75,10 @@ export function useSidebarTableMutationRuntime(options: SidebarTableMutationRunt
const supportsMysqlAutoIncrement = computed(() => activeNode.value.type === "table" && supportsNativeMysqlAutoIncrement(activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined));
function tableAdminSqlOptions(optionsOverride?: { cascade?: boolean }): TableAdminSqlOptions {
const config = activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined;
const result: TableAdminSqlOptions = {
databaseType: currentDatabaseType(),
schema: activeNode.value.schema,
schema: connectionTableSqlSchema(config, activeNode.value.schema),
tableName: activeNode.value.label,
// Cloud Spanner's two dialects quote differently, so admin SQL needs the quote the connected
// agent reported rather than the static per-type mapping.
@@ -87,9 +89,10 @@ export function useSidebarTableMutationRuntime(options: SidebarTableMutationRunt
}
function tableAdminSqlOptionsForNode(node: TreeNode, optionsOverride?: { cascade?: boolean }): TableAdminSqlOptions {
const config = node.connectionId ? connectionStore.getConfig(node.connectionId) : undefined;
const result: TableAdminSqlOptions = {
databaseType: databaseTypeForNode(node),
schema: node.schema,
schema: connectionTableSqlSchema(config, node.schema),
tableName: node.label,
identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
};