diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 956bffa795..8f13e0e618 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -47,7 +47,10 @@ async function getConnector( datasource: Datasource ): Promise { const Connector = await getIntegration(datasource.source) - datasource = await sdk.datasources.enrich(datasource) + // can't enrich if it doesn't have an ID yet + if (datasource._id) { + datasource = await sdk.datasources.enrich(datasource) + } // Connect to the DB and build the schema return new Connector(datasource.config) } @@ -127,13 +130,17 @@ export async function verify( ctx: UserCtx ) { const { datasource } = ctx.request.body - const existingDatasource = await sdk.datasources.get(datasource._id!) - - const enrichedDatasource = sdk.datasources.mergeConfigs( - datasource, - existingDatasource - ) - + let existingDatasource: undefined | Datasource + if (datasource._id) { + existingDatasource = await sdk.datasources.get(datasource._id) + } + let enrichedDatasource = datasource + if (existingDatasource) { + enrichedDatasource = sdk.datasources.mergeConfigs( + datasource, + existingDatasource + ) + } const connector = await getConnector(enrichedDatasource) if (!connector.testConnection) { ctx.throw(400, "Connection information verification not supported") diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index 82d8382a31..f8ec6e8bae 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -8,6 +8,7 @@ import { Table, DatasourcePlus, DatasourceFeature, + ConnectionInfo, } from "@budibase/types" import { buildExternalTableId, @@ -49,7 +50,7 @@ const SCHEMA: Integration = { type: "Relational", description: "Oracle Database is an object-relational database management system developed by Oracle Corporation", - features: [], + features: [DatasourceFeature.CONNECTION_CHECKING], datasource: { host: { type: DatasourceFieldType.STRING, @@ -322,6 +323,30 @@ class OracleIntegration extends Sql implements DatasourcePlus { this.schemaErrors = final.errors } + async testConnection() { + const response: ConnectionInfo = { + connected: false, + } + let connection + try { + connection = await this.getConnection() + response.connected = true + } catch (err: any) { + response.connected = false + response.error = err.message + } finally { + if (connection) { + try { + await connection.close() + } catch (err: any) { + response.connected = false + response.error = err.message + } + } + } + return response + } + private async internalQuery(query: SqlQuery): Promise> { let connection try {