1
0
Fork 0
mirror of synced 2024-07-11 09:15:48 +12:00

Fixes after testing against actual Oracle service.

This commit is contained in:
mike12345567 2023-05-16 19:31:12 +01:00
parent 832f8b3aa8
commit 9f57d7c33a
2 changed files with 20 additions and 9 deletions

View file

@ -47,7 +47,10 @@ async function getConnector(
datasource: Datasource
): Promise<IntegrationBase | DatasourcePlus> {
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,19 @@ export async function verify(
ctx: UserCtx<VerifyDatasourceRequest, VerifyDatasourceResponse>
) {
const { datasource } = ctx.request.body
const existingDatasource = await sdk.datasources.get(datasource._id!)
const enrichedDatasource = sdk.datasources.mergeConfigs(
datasource,
existingDatasource
)
let existingDatasource: undefined | Datasource
try {
existingDatasource = await sdk.datasources.get(datasource._id!)
} catch (err) {
// doesn't exist - can ignore, first creation
}
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")

View file

@ -22,7 +22,8 @@ import { FieldTypes } from "../constants"
import {
BindParameters,
Connection,
ConnectionAttributes, DBError,
ConnectionAttributes,
DBError,
ExecuteOptions,
Result,
} from "oracledb"
@ -330,6 +331,7 @@ class OracleIntegration extends Sql implements DatasourcePlus {
let connection
try {
connection = await this.getConnection()
response.connected = true
} catch (err: any) {
response.connected = false
response.error = err.message