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
|
datasource: Datasource
|
||||||
): Promise<IntegrationBase | DatasourcePlus> {
|
): Promise<IntegrationBase | DatasourcePlus> {
|
||||||
const Connector = await getIntegration(datasource.source)
|
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)
|
datasource = await sdk.datasources.enrich(datasource)
|
||||||
|
}
|
||||||
// Connect to the DB and build the schema
|
// Connect to the DB and build the schema
|
||||||
return new Connector(datasource.config)
|
return new Connector(datasource.config)
|
||||||
}
|
}
|
||||||
|
@ -127,13 +130,17 @@ export async function verify(
|
||||||
ctx: UserCtx<VerifyDatasourceRequest, VerifyDatasourceResponse>
|
ctx: UserCtx<VerifyDatasourceRequest, VerifyDatasourceResponse>
|
||||||
) {
|
) {
|
||||||
const { datasource } = ctx.request.body
|
const { datasource } = ctx.request.body
|
||||||
const existingDatasource = await sdk.datasources.get(datasource._id!)
|
let existingDatasource: undefined | Datasource
|
||||||
|
if (datasource._id) {
|
||||||
const enrichedDatasource = sdk.datasources.mergeConfigs(
|
existingDatasource = await sdk.datasources.get(datasource._id)
|
||||||
|
}
|
||||||
|
let enrichedDatasource = datasource
|
||||||
|
if (existingDatasource) {
|
||||||
|
enrichedDatasource = sdk.datasources.mergeConfigs(
|
||||||
datasource,
|
datasource,
|
||||||
existingDatasource
|
existingDatasource
|
||||||
)
|
)
|
||||||
|
}
|
||||||
const connector = await getConnector(enrichedDatasource)
|
const connector = await getConnector(enrichedDatasource)
|
||||||
if (!connector.testConnection) {
|
if (!connector.testConnection) {
|
||||||
ctx.throw(400, "Connection information verification not supported")
|
ctx.throw(400, "Connection information verification not supported")
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
Table,
|
Table,
|
||||||
DatasourcePlus,
|
DatasourcePlus,
|
||||||
DatasourceFeature,
|
DatasourceFeature,
|
||||||
|
ConnectionInfo,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import {
|
import {
|
||||||
buildExternalTableId,
|
buildExternalTableId,
|
||||||
|
@ -49,7 +50,7 @@ const SCHEMA: Integration = {
|
||||||
type: "Relational",
|
type: "Relational",
|
||||||
description:
|
description:
|
||||||
"Oracle Database is an object-relational database management system developed by Oracle Corporation",
|
"Oracle Database is an object-relational database management system developed by Oracle Corporation",
|
||||||
features: [],
|
features: [DatasourceFeature.CONNECTION_CHECKING],
|
||||||
datasource: {
|
datasource: {
|
||||||
host: {
|
host: {
|
||||||
type: DatasourceFieldType.STRING,
|
type: DatasourceFieldType.STRING,
|
||||||
|
@ -322,6 +323,30 @@ class OracleIntegration extends Sql implements DatasourcePlus {
|
||||||
this.schemaErrors = final.errors
|
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>> {
|
private async internalQuery<T>(query: SqlQuery): Promise<Result<T>> {
|
||||||
let connection
|
let connection
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue