feat: add Oracle database support

This commit is contained in:
t8y2
2026-04-30 04:28:33 +08:00
parent 5dfe340551
commit 2e971ce152
13 changed files with 617 additions and 19 deletions
+8 -1
View File
@@ -277,7 +277,7 @@ function quoteIdent(tab: ActiveTab, name: string): string {
function qualifiedTableName(tab: NonNullable<typeof activeTab.value>): string {
const config = connectionStore.getConfig(tab.connectionId);
if (!tab.tableMeta) return "";
if (config?.db_type === "postgres" && tab.tableMeta.schema) {
if ((config?.db_type === "postgres" || config?.db_type === "oracle") && tab.tableMeta.schema) {
return `${quoteIdent(tab, tab.tableMeta.schema)}.${quoteIdent(tab, tab.tableMeta.tableName)}`;
}
return quoteIdent(tab, tab.tableMeta.tableName);
@@ -293,9 +293,16 @@ function buildTableSql(
tab: NonNullable<typeof activeTab.value>,
options: { orderBy?: string; limit?: number; offset?: number } = {},
): string {
const config = connectionStore.getConfig(tab.connectionId);
const limit = options.limit ?? 100;
const orderBy = options.orderBy ?? defaultOrderBy(tab);
const order = orderBy ? ` ORDER BY ${orderBy}` : "";
if (config?.db_type === "oracle") {
const offset = options.offset ? ` OFFSET ${options.offset} ROWS` : "";
return `SELECT * FROM ${qualifiedTableName(tab)}${order}${offset} FETCH FIRST ${limit} ROWS ONLY`;
}
const offset = options.offset ? ` OFFSET ${options.offset}` : "";
return `SELECT * FROM ${qualifiedTableName(tab)}${order} LIMIT ${limit}${offset};`;
}
@@ -87,6 +87,7 @@ function onDbTypeChange(val: string) {
mongodb: { type: "mongodb", port: 27017, user: "" },
clickhouse: { type: "clickhouse", port: 8123, user: "default" },
sqlserver: { type: "sqlserver", port: 1433, user: "sa" },
oracle: { type: "oracle", port: 1521, user: "system" },
tidb: { type: "mysql", port: 4000, user: "root" },
oceanbase: { type: "mysql", port: 2881, user: "root" },
goldendb: { type: "mysql", port: 3306, user: "root" },
@@ -110,6 +111,7 @@ function onDbTypeChange(val: string) {
const iconTypeMap: Record<string, string> = {
mysql: "mysql", postgres: "postgres", sqlite: "sqlite", redis: "redis",
mongodb: "mongodb", duckdb: "duckdb", clickhouse: "clickhouse", sqlserver: "sqlserver",
oracle: "oracle",
mariadb: "mariadb", tidb: "tidb", oceanbase: "mysql", goldendb: "mysql",
opengauss: "postgres", gaussdb: "postgres", kingbase: "postgres", vastbase: "postgres",
};
@@ -123,6 +125,7 @@ const dbOptions = [
{ value: "duckdb", label: "DuckDB" },
{ value: "clickhouse", label: "ClickHouse" },
{ value: "sqlserver", label: "SQL Server" },
{ value: "oracle", label: "Oracle" },
{ value: "mariadb", label: "MariaDB" },
];
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -144,7 +144,7 @@ async function openData() {
if (!(node.type === "table" || node.type === "view") || !node.connectionId || !node.database) return;
await connectionStore.ensureConnected(node.connectionId);
const config = connectionStore.getConfig(node.connectionId);
const qualifiedName = config?.db_type === "postgres" && node.schema
const qualifiedName = (config?.db_type === "postgres" || config?.db_type === "oracle") && node.schema
? `${quoteIdent(node.schema)}.${quoteIdent(node.label)}`
: quoteIdent(node.label);
const tabId = queryStore.createTab(node.connectionId, node.database, node.label, "data");
@@ -153,7 +153,9 @@ async function openData() {
const columns = await api.getColumns(node.connectionId, node.database, querySchema, node.label);
const pks = columns.filter((c) => c.is_primary_key).map((c) => c.name);
const order = pks.length ? ` ORDER BY ${pks.map((pk) => `${quoteIdent(pk)} ASC`).join(", ")}` : "";
const sql = `SELECT * FROM ${qualifiedName}${order} LIMIT 100;`;
const sql = config?.db_type === "oracle"
? `SELECT * FROM ${qualifiedName}${order} FETCH FIRST 100 ROWS ONLY`
: `SELECT * FROM ${qualifiedName}${order} LIMIT 100;`;
queryStore.updateSql(tabId, sql);
queryStore.setTableMeta(tabId, {
schema: node.schema,
+1 -1
View File
@@ -1,4 +1,4 @@
export type DatabaseType = "mysql" | "postgres" | "sqlite" | "redis" | "duckdb" | "clickhouse" | "sqlserver" | "mongodb";
export type DatabaseType = "mysql" | "postgres" | "sqlite" | "redis" | "duckdb" | "clickhouse" | "sqlserver" | "mongodb" | "oracle";
export interface ConnectionConfig {
id: string;