Merge pull request #10620 from Budibase/feature/oracle-conn-checking
Oracle connection checking
This commit is contained in:
commit
8e95038671
|
@ -47,7 +47,10 @@ async function getConnector(
|
|||
datasource: Datasource
|
||||
): Promise<IntegrationBase | DatasourcePlus> {
|
||||
const Connector = await getIntegration(datasource.source)
|
||||
// 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<VerifyDatasourceRequest, VerifyDatasourceResponse>
|
||||
) {
|
||||
const { datasource } = ctx.request.body
|
||||
const existingDatasource = await sdk.datasources.get(datasource._id!)
|
||||
|
||||
const enrichedDatasource = sdk.datasources.mergeConfigs(
|
||||
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")
|
||||
|
|
|
@ -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<T>(query: SqlQuery): Promise<Result<T>> {
|
||||
let connection
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue