From 0200c7c78be1efb5a2bee38ec2a93df6be4abbba Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 20 May 2021 07:42:25 +0200 Subject: [PATCH] further optimalization of frontend plugins --- .../src/frontend/Dumper.js | 5 ++--- .../src/frontend/driver.js | 2 +- .../src/frontend/MsSqlDumper.js | 19 ++++++++++++------- .../src/frontend/driver.js | 2 +- .../src/frontend/Dumper.js | 2 +- .../src/frontend/drivers.js | 2 +- .../src/frontend/Dumper.js | 2 +- .../src/frontend/drivers.js | 2 +- .../src/frontend/Dumper.js | 5 ++--- .../src/frontend/driver.js | 2 +- 10 files changed, 23 insertions(+), 20 deletions(-) diff --git a/plugins/dbgate-plugin-mongo/src/frontend/Dumper.js b/plugins/dbgate-plugin-mongo/src/frontend/Dumper.js index afcc6473..0df29d93 100644 --- a/plugins/dbgate-plugin-mongo/src/frontend/Dumper.js +++ b/plugins/dbgate-plugin-mongo/src/frontend/Dumper.js @@ -1,6 +1,5 @@ -const { SqlDumper } = require('dbgate-tools'); +const SqlDumper = require('dbgate-tools/lib/SqlDumper'); -class Dumper extends SqlDumper { -} +class Dumper extends SqlDumper {} module.exports = Dumper; diff --git a/plugins/dbgate-plugin-mongo/src/frontend/driver.js b/plugins/dbgate-plugin-mongo/src/frontend/driver.js index aa905f1c..ef958353 100644 --- a/plugins/dbgate-plugin-mongo/src/frontend/driver.js +++ b/plugins/dbgate-plugin-mongo/src/frontend/driver.js @@ -1,4 +1,4 @@ -const { driverBase } = require('dbgate-tools'); +const driverBase = require('dbgate-tools/lib/driverBase'); const Dumper = require('./Dumper'); const mongoIdRegex = /^[0-9a-f]{24}$/; diff --git a/plugins/dbgate-plugin-mssql/src/frontend/MsSqlDumper.js b/plugins/dbgate-plugin-mssql/src/frontend/MsSqlDumper.js index 8b6459b8..b61fa569 100644 --- a/plugins/dbgate-plugin-mssql/src/frontend/MsSqlDumper.js +++ b/plugins/dbgate-plugin-mssql/src/frontend/MsSqlDumper.js @@ -1,4 +1,4 @@ -const { SqlDumper } = require('dbgate-tools'); +const SqlDumper = require('dbgate-tools/lib/SqlDumper'); class MsSqlDumper extends SqlDumper { autoIncrement() { @@ -67,12 +67,12 @@ class MsSqlDumper extends SqlDumper { dropDefault(col) { if (col.defaultConstraint) { - this.putCmd("^alter ^table %f ^drop ^constraint %i", col, col.defaultConstraint); + this.putCmd('^alter ^table %f ^drop ^constraint %i', col, col.defaultConstraint); } } guessDefaultName(col) { - return col.defaultConstraint || `DF${col.schemaName || 'dbo'}_${col.pureName}_col.columnName` + return col.defaultConstraint || `DF${col.schemaName || 'dbo'}_${col.pureName}_col.columnName`; } createDefault(col) { @@ -80,7 +80,7 @@ class MsSqlDumper extends SqlDumper { const defsql = col.defaultValue; if (!defsql) { const defname = this.guessDefaultName(col); - this.putCmd("^alter ^table %f ^add ^constraint %i ^default %s for %i", col, defname, defsql, col.columnName); + this.putCmd('^alter ^table %f ^add ^constraint %i ^default %s for %i', col, defname, defsql, col.columnName); } } @@ -89,8 +89,14 @@ class MsSqlDumper extends SqlDumper { } renameConstraint(cnt, newname) { - if (cnt.constraintType == 'index') this.putCmd("^execute sp_rename '%f.%i', '%s', 'INDEX'", cnt, cnt.constraintName, newname); - else this.putCmd("^execute sp_rename '%f', '%s', 'OBJECT'", { schemaName: cnt.schemaName, pureName: cnt.constraintName }, newname); + if (cnt.constraintType == 'index') + this.putCmd("^execute sp_rename '%f.%i', '%s', 'INDEX'", cnt, cnt.constraintName, newname); + else + this.putCmd( + "^execute sp_rename '%f', '%s', 'OBJECT'", + { schemaName: cnt.schemaName, pureName: cnt.constraintName }, + newname + ); } } @@ -109,5 +115,4 @@ MsSqlDumper.prototype.changeTriggerSchema = MsSqlDumper.prototype.changeObjectSc MsSqlDumper.prototype.renameTable = MsSqlDumper.prototype.renameObject; MsSqlDumper.prototype.changeTableSchema = MsSqlDumper.prototype.changeObjectSchema; - module.exports = MsSqlDumper; diff --git a/plugins/dbgate-plugin-mssql/src/frontend/driver.js b/plugins/dbgate-plugin-mssql/src/frontend/driver.js index 19ecd6fd..247704f3 100644 --- a/plugins/dbgate-plugin-mssql/src/frontend/driver.js +++ b/plugins/dbgate-plugin-mssql/src/frontend/driver.js @@ -1,4 +1,4 @@ -const { driverBase } = require('dbgate-tools'); +const driverBase = require('dbgate-tools/lib/driverBase'); const MsSqlDumper = require('./MsSqlDumper'); /** @type {import('dbgate-types').SqlDialect} */ diff --git a/plugins/dbgate-plugin-mysql/src/frontend/Dumper.js b/plugins/dbgate-plugin-mysql/src/frontend/Dumper.js index 993cf824..91813fa7 100644 --- a/plugins/dbgate-plugin-mysql/src/frontend/Dumper.js +++ b/plugins/dbgate-plugin-mysql/src/frontend/Dumper.js @@ -1,4 +1,4 @@ -const { SqlDumper } = require('dbgate-tools'); +const SqlDumper = require('dbgate-tools/lib/SqlDumper'); class Dumper extends SqlDumper { /** @param type {import('dbgate-types').TransformType} */ diff --git a/plugins/dbgate-plugin-mysql/src/frontend/drivers.js b/plugins/dbgate-plugin-mysql/src/frontend/drivers.js index 4aa2df0e..9c4d5b53 100644 --- a/plugins/dbgate-plugin-mysql/src/frontend/drivers.js +++ b/plugins/dbgate-plugin-mysql/src/frontend/drivers.js @@ -1,4 +1,4 @@ -const { driverBase } = require('dbgate-tools'); +const driverBase = require('dbgate-tools/lib/driverBase'); const Dumper = require('./Dumper'); /** @type {import('dbgate-types').SqlDialect} */ diff --git a/plugins/dbgate-plugin-postgres/src/frontend/Dumper.js b/plugins/dbgate-plugin-postgres/src/frontend/Dumper.js index fb86e4c4..0205cd82 100644 --- a/plugins/dbgate-plugin-postgres/src/frontend/Dumper.js +++ b/plugins/dbgate-plugin-postgres/src/frontend/Dumper.js @@ -1,4 +1,4 @@ -const { SqlDumper } = require('dbgate-tools'); +const SqlDumper = require('dbgate-tools/lib/SqlDumper'); class Dumper extends SqlDumper { /** @param type {import('dbgate-types').TransformType} */ diff --git a/plugins/dbgate-plugin-postgres/src/frontend/drivers.js b/plugins/dbgate-plugin-postgres/src/frontend/drivers.js index 4924333a..22c7c836 100644 --- a/plugins/dbgate-plugin-postgres/src/frontend/drivers.js +++ b/plugins/dbgate-plugin-postgres/src/frontend/drivers.js @@ -1,4 +1,4 @@ -const { driverBase } = require('dbgate-tools'); +const driverBase = require('dbgate-tools/lib/driverBase'); const Dumper = require('./Dumper'); /** @type {import('dbgate-types').SqlDialect} */ diff --git a/plugins/dbgate-plugin-sqlite/src/frontend/Dumper.js b/plugins/dbgate-plugin-sqlite/src/frontend/Dumper.js index afcc6473..0df29d93 100644 --- a/plugins/dbgate-plugin-sqlite/src/frontend/Dumper.js +++ b/plugins/dbgate-plugin-sqlite/src/frontend/Dumper.js @@ -1,6 +1,5 @@ -const { SqlDumper } = require('dbgate-tools'); +const SqlDumper = require('dbgate-tools/lib/SqlDumper'); -class Dumper extends SqlDumper { -} +class Dumper extends SqlDumper {} module.exports = Dumper; diff --git a/plugins/dbgate-plugin-sqlite/src/frontend/driver.js b/plugins/dbgate-plugin-sqlite/src/frontend/driver.js index 1d614be4..1bd0d31e 100644 --- a/plugins/dbgate-plugin-sqlite/src/frontend/driver.js +++ b/plugins/dbgate-plugin-sqlite/src/frontend/driver.js @@ -1,4 +1,4 @@ -const { driverBase } = require('dbgate-tools'); +const driverBase = require('dbgate-tools/lib/driverBase'); const Dumper = require('./Dumper'); function getDatabaseFileLabel(databaseFile) {