Файли
openidea/src/features/database/tableInput.ts
T
Vladislav Kuzmin bd396485c2 feat(database): support DuckDB SQL and browse attached catalogs (#6254)
DuckDB sources get DuckDB's SQL dialect (highlighting, completion, formatting and resolution) and the database tree lists attached catalogs with their schemas, tables and columns. The JDBC bridge gains a catalogs command and catalog-scoped schema and table metadata, matched by exact catalog and schema names; tables in another catalog open and page through the source session. DDL that attaches, detaches or changes a catalog refreshes the tree.

Co-authored-by: principalwater <[email protected]>
2026-11-28 09:07:53 +08:00

22 рядки
786 B
TypeScript

import type { EditorInput } from "@/workbench/contributions";
export const TABLE_KIND = "db-table";
export interface TableRef {
id: string;
schema: string;
table: string;
catalog?: string;
}
export function tableTitle(input: EditorInput): string {
const { catalog, schema, table } = input.data as TableRef;
return catalog === undefined ? table : `${catalog}.${schema}.${table}`;
}
export function tableInput(id: string, schema: string, table: string, catalog?: string): EditorInput {
const data: TableRef = catalog === undefined ? { id, schema, table } : { id, schema, table, catalog };
const key = catalog === undefined ? `${id}:${schema}.${table}` : JSON.stringify([id, catalog, schema, table]);
return { kind: TABLE_KIND, key: `${TABLE_KIND}:${key}`, data };
}