From db4430609e22816f4a3a8ecdbf61e9b51cde2579 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Tue, 2 Mar 2021 12:03:01 +0100 Subject: [PATCH] feat(MySQL): support to new mysql8 authentication, closes #45 --- package.json | 2 +- src/main/libs/clients/MySQLClient.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 94a84260..ecc04ec0 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "keytar": "^7.3.0", "moment": "^2.29.1", "mssql": "^6.2.3", - "mysql": "^2.18.1", + "mysql2": "^2.2.5", "pg": "^8.5.1", "source-map-support": "^0.5.16", "spectre.css": "^0.5.9", diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index b90bc67d..6f93c5f7 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -1,5 +1,5 @@ 'use strict'; -import mysql from 'mysql'; +import mysql from 'mysql2'; import { AntaresCore } from '../AntaresCore'; import dataTypes from 'common/data-types/mysql'; @@ -43,8 +43,8 @@ export class MySQLClient extends AntaresCore { } _getType (field) { - let name = this.types[field.type]; - let length = field.length; + let name = this.types[field.columnType]; + let length = field.columnLength; if (['DATE', 'TIME', 'YEAR', 'DATETIME'].includes(name)) length = field.decimals; @@ -52,11 +52,12 @@ export class MySQLClient extends AntaresCore { if (name === 'TIMESTAMP') length = 0; - if (name === 'CHAR' && field.charsetNr === 63)// if binary - name = 'BINARY'; - - if (name === 'VARCHAR' && field.charsetNr === 63)// if binary - name = 'VARBINARY'; + if (field.charsetNr === 63) { // if binary + if (name === 'CHAR') + name = 'BINARY'; + else if (name === 'VARCHAR') + name = 'VARBINARY'; + } if (name === 'BLOB') { switch (length) { @@ -1232,10 +1233,9 @@ export class MySQLClient extends AntaresCore { name: field.orgName, alias: field.name, orgName: field.orgName, - schema: field.db, + schema: field.schema, table: field.table, tableAlias: field.table, - zerofill: field.zerofill, orgTable: field.orgTable, type: type.name, length: type.length