mssql tedious fix #236

This commit is contained in:
Jan Prochazka 2022-02-28 18:00:14 +01:00
parent 50f9b9f025
commit bfea77c56b
2 changed files with 31 additions and 10 deletions

View File

@ -5,6 +5,7 @@ services:
dbgate: dbgate:
build: docker build: docker
# image: dbgate/dbgate:beta-alpine # image: dbgate/dbgate:beta-alpine
# image: dbgate/dbgate:beta
restart: always restart: always
ports: ports:
- 3100:3000 - 3100:3000
@ -17,6 +18,13 @@ services:
environment: environment:
WEB_ROOT: /dbgate WEB_ROOT: /dbgate
# CONNECTIONS: mssql
# LABEL_mssql: MS Sql
# SERVER_mssql: mssql
# USER_mssql: sa
# PORT_mssql: 1433
# PASSWORD_mssql: Pwd2020Db
# ENGINE_mssql: mssql@dbgate-plugin-mssql
proxy: proxy:
# image: nginx # image: nginx
build: test/nginx build: test/nginx
@ -32,6 +40,14 @@ services:
# FILE_sqlite: /mnt/sqt/Chinook.db # FILE_sqlite: /mnt/sqt/Chinook.db
# ENGINE_sqlite: sqlite@dbgate-plugin-sqlite # ENGINE_sqlite: sqlite@dbgate-plugin-sqlite
# mssql:
# image: mcr.microsoft.com/mssql/server
# restart: always
# environment:
# - ACCEPT_EULA=Y
# - SA_PASSWORD=Pwd2020Db
# - MSSQL_PID=Express
volumes: volumes:
dbgate-data: dbgate-data:
driver: local driver: local

View File

@ -24,6 +24,20 @@ function extractTediousColumns(columns, addDriverNativeColumn = false) {
async function tediousConnect({ server, port, user, password, database, ssl }) { async function tediousConnect({ server, port, user, password, database, ssl }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const connectionOptions = {
encrypt: !!ssl,
cryptoCredentialsDetails: ssl ? _.pick(ssl, ['ca', 'cert', 'key']) : undefined,
trustServerCertificate: ssl ? (!ssl.ca && !ssl.cert && !ssl.key ? true : ssl.rejectUnauthorized) : undefined,
enableArithAbort: true,
validateBulkLoadParameters: false,
requestTimeout: 1000 * 3600,
port: port ? parseInt(port) : undefined,
};
if (database) {
connectionOptions.database = database;
}
const connection = new tedious.Connection({ const connection = new tedious.Connection({
server, server,
@ -35,16 +49,7 @@ async function tediousConnect({ server, port, user, password, database, ssl }) {
}, },
}, },
options: { options: connectionOptions,
encrypt: !!ssl,
cryptoCredentialsDetails: ssl ? _.pick(ssl, ['ca', 'cert', 'key']) : undefined,
trustServerCertificate: ssl ? (!ssl.ca && !ssl.cert && !ssl.key ? true : ssl.rejectUnauthorized) : undefined,
enableArithAbort: true,
validateBulkLoadParameters: false,
requestTimeout: 1000 * 3600,
database,
port: port ? parseInt(port) : undefined,
},
}); });
connection.on('connect', function (err) { connection.on('connect', function (err) {
if (err) { if (err) {