From 5e7d839cb1c2fc8b35e44f268df2692b4615ebe6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 16 May 2023 10:50:27 +0200 Subject: [PATCH] Use existing merge --- packages/server/src/api/controllers/datasource.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 686515b293..a87c8c68f6 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -25,7 +25,6 @@ import { DatasourcePlus, } from "@budibase/types" import sdk from "../../sdk" -import _ from "lodash" function getErrorTables(errors: any, errorType: string) { return Object.entries(errors) @@ -128,10 +127,14 @@ export async function verify( ctx: UserCtx ) { const { datasource } = ctx.request.body + const existingDatasource = await sdk.datasources.get(datasource._id!) - const { config } = await sdk.datasources.get(datasource._id!) + const enrichedDatasource = sdk.datasources.mergeConfigs( + datasource, + existingDatasource + ) - const connector = await getConnector(_.merge(datasource, { config })) + const connector = await getConnector(enrichedDatasource) if (!connector.testConnection) { ctx.throw(400, "Connection information verification not supported") }