不要怂,就是干,撸起袖子干!

Commit 687d23a9 by Ali Taheri Moghaddar Committed by Sushant

Ease dialect require for webpack (#6388)

1 parent 58573c19
...@@ -16,7 +16,11 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -16,7 +16,11 @@ class ConnectionManager extends AbstractConnectionManager {
this.sequelize = sequelize; this.sequelize = sequelize;
this.sequelize.config.port = this.sequelize.config.port || 1433; this.sequelize.config.port = this.sequelize.config.port || 1433;
try { try {
this.lib = require(sequelize.config.dialectModulePath || 'tedious'); if (sequelize.config.dialectModulePath) {
this.lib = require(sequelize.config.dialectModulePath);
} else {
this.lib = require('tedious');
}
} catch (err) { } catch (err) {
if (err.code === 'MODULE_NOT_FOUND') { if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install tedious package manually'); throw new Error('Please install tedious package manually');
...@@ -53,7 +57,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -53,7 +57,7 @@ class ConnectionManager extends AbstractConnectionManager {
} }
// The 'tedious' driver needs domain property to be in the main Connection config object // The 'tedious' driver needs domain property to be in the main Connection config object
if(config.dialectOptions.domain) { if (config.dialectOptions.domain) {
connectionConfig.domain = config.dialectOptions.domain; connectionConfig.domain = config.dialectOptions.domain;
} }
......
...@@ -21,7 +21,11 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -21,7 +21,11 @@ class ConnectionManager extends AbstractConnectionManager {
if (this.sequelize.options.host === 'localhost') delete this.sequelize.options.host; if (this.sequelize.options.host === 'localhost') delete this.sequelize.options.host;
try { try {
this.lib = require(sequelize.config.dialectModulePath || 'sqlite3').verbose(); if (sequelize.config.dialectModulePath) {
this.lib = require(sequelize.config.dialectModulePath).verbose();
} else {
this.lib = require('sqlite3').verbose();
}
} catch (err) { } catch (err) {
if (err.code === 'MODULE_NOT_FOUND') { if (err.code === 'MODULE_NOT_FOUND') {
throw new Error('Please install sqlite3 package manually'); throw new Error('Please install sqlite3 package manually');
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!