1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Move creation pool on the connect step

This commit is contained in:
Adria Navarro 2023-06-28 10:39:43 +01:00
parent f2d41addbd
commit 8a7d610faf
2 changed files with 14 additions and 14 deletions

View file

@ -11,7 +11,7 @@ import { BuildSchemaErrors, InvalidColumns } from "../../constants"
import { getIntegration } from "../../integrations" import { getIntegration } from "../../integrations"
import { getDatasourceAndQuery } from "./row/utils" import { getDatasourceAndQuery } from "./row/utils"
import { invalidateDynamicVariables } from "../../threads/utils" import { invalidateDynamicVariables } from "../../threads/utils"
import { db as dbCore, context, events, cache } from "@budibase/backend-core" import { db as dbCore, context, events } from "@budibase/backend-core"
import { import {
UserCtx, UserCtx,
Datasource, Datasource,

View file

@ -96,7 +96,6 @@ const SCHEMA: Integration = {
class SqlServerIntegration extends Sql implements DatasourcePlus { class SqlServerIntegration extends Sql implements DatasourcePlus {
private readonly config: MSSQLConfig private readonly config: MSSQLConfig
private index: number = 0 private index: number = 0
private readonly pool: sqlServer.ConnectionPool
private client?: sqlServer.ConnectionPool private client?: sqlServer.ConnectionPool
public tables: Record<string, ExternalTable> = {} public tables: Record<string, ExternalTable> = {}
public schemaErrors: Record<string, string> = {} public schemaErrors: Record<string, string> = {}
@ -114,17 +113,6 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
constructor(config: MSSQLConfig) { constructor(config: MSSQLConfig) {
super(SqlClient.MS_SQL) super(SqlClient.MS_SQL)
this.config = config this.config = config
const clientCfg = {
...this.config,
port: +this.config,
options: {
encrypt: this.config.encrypt,
enableArithAbort: true,
},
}
delete clientCfg.encrypt
this.pool = new sqlServer.ConnectionPool(clientCfg)
} }
async testConnection() { async testConnection() {
@ -150,7 +138,19 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
async connect() { async connect() {
try { try {
this.client = await this.pool.connect() const clientCfg = {
...this.config,
port: +this.config,
options: {
encrypt: this.config.encrypt,
enableArithAbort: true,
},
}
delete clientCfg.encrypt
const pool = new sqlServer.ConnectionPool(clientCfg)
this.client = await pool.connect()
} catch (err: any) { } catch (err: any) {
if (err?.originalError?.errors?.length) { if (err?.originalError?.errors?.length) {
const messages = [] const messages = []