Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Modules
const _ = require('lodash'),
isGeneratorFunction = require('is-generator').fn;
const bluebird = require('bluebird');

// Exports

Expand Down Expand Up @@ -40,7 +41,7 @@ function replaceFieldNames(sql, identifiers, model) {
// Replace identifiers
sql = sql.replace(
new RegExp(`\\*${identifier}(?![a-zA-Z0-9_])`, 'g'),
queryInterface.quoteIdentifier(fieldName)
queryInterface.queryGenerator.quoteIdentifier(fieldName)
);
});
return sql;
Expand All @@ -53,7 +54,7 @@ function replaceTableNames(sql, identifiers, sequelize) {
const tableName = model.getTableName();
sql = sql.replace(
new RegExp(`\\*${identifier}(?![a-zA-Z0-9_])`, 'g'),
tableName.schema ? tableName.toString() : queryInterface.quoteIdentifier(tableName)
tableName.schema ? tableName.toString() : queryInterface.queryGenerator.quoteIdentifier(tableName)
);
});
return sql;
Expand Down Expand Up @@ -100,7 +101,7 @@ function addToFields(fieldName, options) {

// Return `co` and `coAll` functions, using `Sequelize.Promise` (i.e. Bluebird)
function makeCo(Sequelize) {
const co = Sequelize.Promise.coroutine;
const co = bluebird.coroutine;

function coAll(obj) {
_.forIn(obj, (value, key) => {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"dependencies": {
"is-generator": "^1.0.3",
"lodash": "^4.17.11",
"semver-select": "^1.1.0"
"semver-select": "^1.1.0",
"bluebird": "^3.7.2"
},
"devDependencies": {
"@overlookmotel/eslint-config": "^2.1.2",
Expand All @@ -36,7 +37,7 @@
"pg": "^7.10.0",
"pg-hstore": "^2.3.2",
"pg-native": "^3.0.0",
"sequelize": "^5.7.5",
"sequelize": "^6.3.4",
"sqlite3": "^4.0.6",
"tedious": "^6.1.1"
},
Expand Down
21 changes: 13 additions & 8 deletions test/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const fs = require('fs'),
path = require('path'),
_ = require('lodash'),
bluebird = require('bluebird'),
Sequelize = require('sequelize'),
DataTypes = require('sequelize/lib/data-types'),
chai = require('chai'),
Expand All @@ -15,10 +16,10 @@ require('../lib/index')(Sequelize);
chai.use(chaiAsPromised);

// Make sure errors get thrown when testing
Sequelize.Promise.onPossiblyUnhandledRejection((e) => {
bluebird.Promise.onPossiblyUnhandledRejection((e) => {
throw e;
});
Sequelize.Promise.longStackTraces();
bluebird.Promise.longStackTraces();

const Support = {
Sequelize,
Expand Down Expand Up @@ -47,11 +48,11 @@ const Support = {
if (dialect === 'sqlite') {
const p = path.join(__dirname, 'tmp', 'db.sqlite');

return new Sequelize.Promise(((resolve) => {
return new bluebird.Promise(((resolve) => {
// We cannot promisify exists, since exists does not follow node callback convention -
// first argument is a boolean, not an error / null
if (fs.existsSync(p)) {
resolve(Sequelize.Promise.promisify(fs.unlink)(p));
resolve(bluebird.Promise.promisify(fs.unlink)(p));
} else {
resolve();
}
Expand All @@ -69,7 +70,7 @@ const Support = {
if (callback) {
callback(sequelize);
} else {
return Sequelize.Promise.resolve(sequelize);
return bluebird.Promise.resolve(sequelize);
}
},

Expand Down Expand Up @@ -115,9 +116,13 @@ const Support = {
if (sequelize.modelManager.models) sequelize.modelManager.models = [];
sequelize.models = {};

return sequelize
.getQueryInterface()
.dropAllEnums();
const dialect = Support.getTestDialect();

if (dialect === 'postgres') {
return sequelize
.getQueryInterface()
.dropAllEnums();
}
});
},

Expand Down