Merge branch 'master' into develop

This commit is contained in:
Jan Prochazka 2021-10-24 10:30:34 +02:00
commit 84832472a2
9 changed files with 66 additions and 35 deletions

View File

@ -107,6 +107,6 @@
"electron-builder": "22.10.5"
},
"optionalDependencies": {
"msnodesqlv8": "^2.0.10"
"msnodesqlv8": "^2.4.0"
}
}

View File

@ -1,6 +1,6 @@
{
"private": true,
"version": "4.4.0-alpha.1",
"version": "4.3.4-beta.4",
"name": "dbgate-all",
"workspaces": [
"packages/*",

View File

@ -71,6 +71,6 @@
"webpack-cli": "^3.3.11"
},
"optionalDependencies": {
"msnodesqlv8": "^2.0.10"
"msnodesqlv8": "^2.4.0"
}
}

View File

@ -47,6 +47,7 @@ export interface EngineDriver {
showConnectionTab?: (tab: 'ssl' | 'sshTunnel', values: any) => boolean;
beforeConnectionSave?: (values: any) => any;
databaseUrlPlaceholder?: string;
defaultAuthTypeName?: string;
connect({ server, port, user, password, database }): Promise<any>;
close(pool): Promise<any>;
query(pool: any, sql: string, options?: QueryOptions): Promise<QueryResult>;

View File

@ -65,6 +65,8 @@
<FormSelectField
label="Authentication"
name="authType"
isNative
defaultValue={driver?.defaultAuthTypeName}
options={$authTypes.map(auth => ({
value: auth.name,
label: auth.title,

View File

@ -41,7 +41,7 @@ const windowsAuthTypes = [
disabledFields: ['port'],
},
{
title: 'Tedious driver',
title: 'NodeJs portable driver (tedious)',
name: 'tedious',
},
];

View File

@ -43,22 +43,43 @@ function extractNativeColumns(meta) {
return res;
}
async function nativeConnect({ server, port, user, password, database, authType }) {
async function connectWithDriver({ server, port, user, password, database, authType }, driver) {
let connectionString = `server=${server}`;
if (port && !server.includes('\\')) connectionString += `,${port}`;
connectionString += ';Driver={SQL Server Native Client 11.0}';
connectionString += `;Driver={${driver}}`;
if (authType == 'sspi') connectionString += ';Trusted_Connection=Yes';
else connectionString += `;UID=${user};PWD=${password}`;
if (database) connectionString += `;Database=${database}`;
return new Promise((resolve, reject) => {
msnodesqlv8.open(connectionString, (err, conn) => {
if (err) reject(err);
conn._connectionType = 'msnodesqlv8';
resolve(conn);
if (err) {
reject(err);
} else {
conn._connectionType = 'msnodesqlv8';
resolve(conn);
}
});
});
}
async function nativeConnect(connection) {
const drivers = ['ODBC Driver 17 for SQL Server', 'SQL Server Native Client 11.0'];
for (let i = 0; i < drivers.length; i += 1) {
try {
const res = await connectWithDriver(connection, drivers[i]);
console.error(`Connected SQL Server with ${drivers[i]} driver`);
return res;
} catch (err) {
if (err.message && err.message.includes('[ODBC Driver Manager]') && i < drivers.length - 1) {
console.error(`Failed connecting with ${drivers[i]} driver, trying next`, err);
continue;
}
throw new Error(`${err}`);
}
}
}
async function nativeQueryCore(pool, sql, options) {
if (sql == null) {
return Promise.resolve({

View File

@ -59,6 +59,7 @@ const driver = {
engine: 'mssql@dbgate-plugin-mssql',
title: 'Microsoft SQL Server',
defaultPort: 1433,
defaultAuthTypeName: 'tedious',
};
module.exports = driver;

View File

@ -7356,13 +7356,14 @@ ms@^2.0.0:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
msnodesqlv8@^2.0.10:
version "2.0.10"
resolved "https://registry.yarnpkg.com/msnodesqlv8/-/msnodesqlv8-2.0.10.tgz#47d05157c2d30e5f48fa0aa550a0353ab56a027c"
integrity sha512-oA46Y8ZQxYEW9M8U+Wg4bI5g8nI2pueIkyameEpxanHqr9d5w4a0Pgk2WvugHiY1UYmN1bPziUdqBgwkBSGrnA==
msnodesqlv8@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/msnodesqlv8/-/msnodesqlv8-2.4.0.tgz#7815b965655a5ccb0635f2f48476b5d6d49e3343"
integrity sha512-CYecwSZS86jE1Nr7sO/cWWfmeg5F+hhFbs8gABGqOsiLWWoylFrOiPfcV3Z4jgDcVWIV6pF2eiBCE/b8KriypA==
dependencies:
nan "^2.14.2"
prebuild-install "^6.0.0"
node-abi "^2.30.0"
prebuild-install "^6.1.2"
mute-stream@0.0.8:
version "0.0.8"
@ -7477,6 +7478,13 @@ node-abi@^2.21.0:
dependencies:
semver "^5.4.1"
node-abi@^2.30.0:
version "2.30.1"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.30.1.tgz#c437d4b1fe0e285aaf290d45b45d4d7afedac4cf"
integrity sha512-/2D0wOQPgaUWzVSVgRMx+trKJRC2UG4SUc4oCJoXx9Uxjtp0Vy3/kt7zcbxHF8+Z/pK3UloLWzBISg72brfy1w==
dependencies:
semver "^5.4.1"
node-abi@^2.7.0:
version "2.19.3"
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.19.3.tgz#252f5dcab12dad1b5503b2d27eddd4733930282d"
@ -8378,27 +8386,6 @@ prebuild-install@6.0.1:
tunnel-agent "^0.6.0"
which-pm-runs "^1.0.0"
prebuild-install@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.0.0.tgz#669022bcde57c710a869e39c5ca6bf9cd207f316"
integrity sha512-h2ZJ1PXHKWZpp1caLw0oX9sagVpL2YTk+ZwInQbQ3QqNd4J03O6MpFNmMTJlkfgPENWqe5kP0WjQLqz5OjLfsw==
dependencies:
detect-libc "^1.0.3"
expand-template "^2.0.3"
github-from-package "0.0.0"
minimist "^1.2.3"
mkdirp-classic "^0.5.3"
napi-build-utils "^1.0.1"
node-abi "^2.7.0"
noop-logger "^0.1.1"
npmlog "^4.0.1"
pump "^3.0.0"
rc "^1.2.7"
simple-get "^3.0.3"
tar-fs "^2.0.0"
tunnel-agent "^0.6.0"
which-pm-runs "^1.0.0"
prebuild-install@^6.0.1:
version "6.1.2"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.1.2.tgz#6ce5fc5978feba5d3cbffedca0682b136a0b5bff"
@ -8419,6 +8406,25 @@ prebuild-install@^6.0.1:
tar-fs "^2.0.0"
tunnel-agent "^0.6.0"
prebuild-install@^6.1.2:
version "6.1.4"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.1.4.tgz#ae3c0142ad611d58570b89af4986088a4937e00f"
integrity sha512-Z4vpywnK1lBg+zdPCVCsKq0xO66eEV9rWo2zrROGGiRS4JtueBOdlB1FnY8lcy7JsUud/Q3ijUxyWN26Ika0vQ==
dependencies:
detect-libc "^1.0.3"
expand-template "^2.0.3"
github-from-package "0.0.0"
minimist "^1.2.3"
mkdirp-classic "^0.5.3"
napi-build-utils "^1.0.1"
node-abi "^2.21.0"
npmlog "^4.0.1"
pump "^3.0.0"
rc "^1.2.7"
simple-get "^3.0.3"
tar-fs "^2.0.0"
tunnel-agent "^0.6.0"
prelude-ls@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"