From 0345f2e6a7b3ce2a8b5ce06fc0d12291e2ee86ac Mon Sep 17 00:00:00 2001 From: Guy Ben-Aharon Date: Mon, 7 Oct 2024 09:56:34 +0300 Subject: [PATCH] add list for databases with schemas (#248) --- src/context/chartdb-context/chartdb-provider.tsx | 8 +++++--- src/lib/domain/db-schema.ts | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/context/chartdb-context/chartdb-provider.tsx b/src/context/chartdb-context/chartdb-provider.tsx index ddec0faf..924439d7 100644 --- a/src/context/chartdb-context/chartdb-provider.tsx +++ b/src/context/chartdb-context/chartdb-provider.tsx @@ -15,7 +15,10 @@ import { useNavigate } from 'react-router-dom'; import { useConfig } from '@/hooks/use-config'; import type { DatabaseEdition } from '@/lib/domain/database-edition'; import type { DBSchema } from '@/lib/domain/db-schema'; -import { schemaNameToSchemaId } from '@/lib/domain/db-schema'; +import { + databasesWithSchemas, + schemaNameToSchemaId, +} from '@/lib/domain/db-schema'; import { useLocalConfig } from '@/hooks/use-local-config'; import { defaultSchemas } from '@/lib/data/default-schemas'; import { useEventEmitter } from 'ahooks'; @@ -57,8 +60,7 @@ export const ChartDBProvider: React.FC = ({ const schemas = useMemo( () => - databaseType === DatabaseType.POSTGRESQL || - databaseType === DatabaseType.SQL_SERVER + databasesWithSchemas.includes(databaseType) ? [ ...new Set( tables diff --git a/src/lib/domain/db-schema.ts b/src/lib/domain/db-schema.ts index 2a8a52b0..b82bea15 100644 --- a/src/lib/domain/db-schema.ts +++ b/src/lib/domain/db-schema.ts @@ -1,3 +1,5 @@ +import { DatabaseType } from './database-type'; + export interface DBSchema { id: string; name: string; @@ -15,3 +17,8 @@ export const schemaNameToDomainSchemaName = ( : (schema ?? '').trim() === '' ? undefined : schema; + +export const databasesWithSchemas: DatabaseType[] = [ + DatabaseType.POSTGRESQL, + DatabaseType.SQL_SERVER, +];