fix(tdengine): recognize tbname in stable diagnostics

Closes #5685
This commit is contained in:
t8y2 committed 2026-08-08 18:28:11 +08:00
1 parent be7b9ac021
commit ad9ca8400b
9 files changed
+167 -2

No files matched your search

@@ -96,6 +96,18 @@ function dorisConnection(): ConnectionConfig {
} as ConnectionConfig;
}
function tdengineConnection(): ConnectionConfig {
return {
...postgresConnection(),
id: "tdengine-1",
name: "TDengine",
db_type: "tdengine",
port: 6041,
username: "root",
database: "issue_5685",
} as ConnectionConfig;
}
function deferred<T>() {
let resolve!: (value: T) => void;
const promise = new Promise<T>((res) => {
@@ -141,6 +153,31 @@ describe("connectionStore completion assistant", () => {
expect(tables).toEqual([{ name: "users", schema: "public", type: "table" }]);
});
it("preserves TDengine stable type in completion metadata", async () => {
const listTables = vi.fn().mockResolvedValue([
{ name: "test_tb", table_type: "STABLE", comment: null },
{ name: "ordinary_table", table_type: "TABLE", comment: null },
]);
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));
vi.doMock("@/lib/backend/api", () => ({
checkConnectionHealth: vi.fn().mockResolvedValue(undefined),
listTables,
}));
const { useConnectionStore } = await import("@/stores/connectionStore");
const store = useConnectionStore();
store.connections = [tdengineConnection()];
store.connectedIds.add("tdengine-1");
const tables = await store.listCompletionTables("tdengine-1", "issue_5685");
expect(tables).toEqual([
{ name: "test_tb", type: "table", tableType: "STABLE" },
{ name: "ordinary_table", type: "table" },
]);
});
it("deduplicates in-flight assistant table requests", async () => {
const completionAssistantSearch = vi.fn().mockResolvedValue({
candidates: [{ name: "accounts", kind: "table", schema: "public" }],
@@ -125,6 +125,7 @@ import { RABBITMQ_MQ_TENANT, resolveMqSystemKindFromConnection } from "@/lib/mq/
import { applySidebarDatabaseStorage, applySidebarTableStorage, sidebarDatabaseNames, supportsSidebarDatabaseStorage, supportsSidebarTableStorage, type SidebarTableStorageScope } from "@/lib/sidebar/sidebarDatabaseStorage";
import { connectionHasConfiguredSidebarVisibleFilter, nacosVisibleNamespaceSummary, sidebarVisibleFilterSummary } from "@/lib/sidebar/sidebarVisibleFilterSummary";
import { connectionCanConfigureSidebarVisibleDatabases } from "@/lib/sidebar/sidebarVisibleFilterMenu";
import { isTdengineStableTableType } from "@/lib/table/tableEditing";
const PINNED_TREE_NODES_STORAGE_KEY = "dbx-pinned-tree-nodes";
const ACTIVE_CONNECTION_STORAGE_KEY = "dbx-active-connection";
@@ -1602,9 +1603,15 @@ export const useConnectionStore = defineStore("connection", () => {
name: table.name,
schema,
type: sqlObjectNavigationTypeFromTableType(table.table_type),
...completionStableTableType(table.table_type),
}));
}
function completionStableTableType(tableType: string | null | undefined): Partial<Pick<SqlCompletionTable, "tableType">> {
if (!tableType || !isTdengineStableTableType(tableType)) return {};
return { tableType: tableType.trim() };
}
function sameSidebarObjectName(left: string | undefined, right: string | undefined): boolean {
return (left || "").toLowerCase() === (right || "").toLowerCase();
}
@@ -5542,6 +5549,7 @@ export const useConnectionStore = defineStore("connection", () => {
name: candidate.name,
schema: candidate.schema ?? undefined,
type: sqlObjectNavigationTypeFromTableType(candidate.data_type || candidate.kind),
...completionStableTableType(candidate.data_type),
};
if (!withOracleMetadata) return table;
return {
@@ -6022,6 +6030,7 @@ export const useConnectionStore = defineStore("connection", () => {
catalog,
schema,
type: sqlObjectNavigationTypeFromTableType(table.table_type),
...completionStableTableType(table.table_type),
}));
} else {
results = lookupLocalCompletionTables(connectionId, database, normalizedFilter, limit, undefined, catalog);
@@ -6042,6 +6051,7 @@ export const useConnectionStore = defineStore("connection", () => {
catalog,
schema,
type: sqlObjectNavigationTypeFromTableType(table.table_type),
...completionStableTableType(table.table_type),
}));
} catch {
results = [];
@@ -6064,6 +6074,7 @@ export const useConnectionStore = defineStore("connection", () => {
catalog,
schema,
type: sqlObjectNavigationTypeFromTableType(table.table_type),
...completionStableTableType(table.table_type),
}));
} else {
completionTablesCache.value[cacheKey] = lookupLocalCompletionTables(connectionId, database, normalizedFilter, limit, undefined, catalog);
@@ -6082,6 +6093,7 @@ export const useConnectionStore = defineStore("connection", () => {
name: table.name,
catalog,
type: sqlObjectNavigationTypeFromTableType(table.table_type),
...completionStableTableType(table.table_type),
}));
completionTablesCache.value[cacheKey] = limit ? completionTablesCache.value[cacheKey].slice(0, limit) : completionTablesCache.value[cacheKey];
indexCompletionTables(connectionId, database, schema, completionTablesCache.value[cacheKey], catalog);