From 476bb79c29d16da1e1d5bdaf1291383a5da5e86f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 30 Sep 2022 15:19:34 +0100 Subject: [PATCH] Quick fix for development machines, when running Budibase development stack on systems that are not oracle compatiable it would fail to start due to the lack of dependency. --- packages/server/src/integrations/index.ts | 6 +++++- packages/server/src/integrations/oracle.ts | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/server/src/integrations/index.ts b/packages/server/src/integrations/index.ts index 99cd391278..240f68ed91 100644 --- a/packages/server/src/integrations/index.ts +++ b/packages/server/src/integrations/index.ts @@ -57,7 +57,11 @@ const INTEGRATIONS: { [key: string]: any } = { } // optionally add oracle integration if the oracle binary can be installed -if (process.arch && !process.arch.startsWith("arm")) { +if ( + process.arch && + !process.arch.startsWith("arm") && + oracle.integration.isInstalled() +) { DEFINITIONS[SourceName.ORACLE] = oracle.schema INTEGRATIONS[SourceName.ORACLE] = oracle.integration } diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index 5f35935e12..101d459ec0 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -15,17 +15,22 @@ import { getSqlQuery, SqlClient, } from "./utils" -import oracledb, { +import Sql from "./base/sql" +import { FieldTypes } from "../constants" +import { BindParameters, Connection, ConnectionAttributes, ExecuteOptions, Result, } from "oracledb" -import Sql from "./base/sql" -import { FieldTypes } from "../constants" - -oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT +let oracledb: any +try { + oracledb = require("oracledb") + oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT +} catch (err) { + console.log("ORACLEDB is not installed") +} interface OracleConfig { host: string @@ -183,6 +188,10 @@ class OracleIntegration extends Sql implements DatasourcePlus { return parts.join(" || ") } + static isInstalled() { + return oracledb != null + } + /** * Map the flat tabular columns and constraints data into a nested object */