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

Commit 7e06e0c9 by Jan Aagaard Meier

Removed a couple of places with transaction: null, added CLS as dev-dependency a…

…nd fixed cls test for sqlite
1 parent 3dd80fde
...@@ -832,9 +832,9 @@ module.exports = (function() { ...@@ -832,9 +832,9 @@ module.exports = (function() {
, where; , where;
if (countOrOptions === undefined) { if (countOrOptions === undefined) {
countOrOptions = { by: 1, transaction: null }; countOrOptions = { by: 1 };
} else if (typeof countOrOptions === 'number') { } else if (typeof countOrOptions === 'number') {
countOrOptions = { by: countOrOptions, transaction: null }; countOrOptions = { by: countOrOptions };
} }
countOrOptions = Utils._.extend({ countOrOptions = Utils._.extend({
...@@ -892,9 +892,9 @@ module.exports = (function() { ...@@ -892,9 +892,9 @@ module.exports = (function() {
}); });
if (countOrOptions === undefined) { if (countOrOptions === undefined) {
countOrOptions = { by: 1, transaction: null }; countOrOptions = { by: 1 };
} else if (typeof countOrOptions === 'number') { } else if (typeof countOrOptions === 'number') {
countOrOptions = { by: countOrOptions, transaction: null }; countOrOptions = { by: countOrOptions };
} }
if (countOrOptions.by === undefined) { if (countOrOptions.by === undefined) {
......
...@@ -46,7 +46,6 @@ module.exports = (function() { ...@@ -46,7 +46,6 @@ module.exports = (function() {
var self = this; var self = this;
options = Utils._.extend({ options = Utils._.extend({
transaction: null,
raw: true raw: true
}, options || {}); }, options || {});
...@@ -285,7 +284,6 @@ module.exports = (function() { ...@@ -285,7 +284,6 @@ module.exports = (function() {
QueryInterface.prototype.showAllTables = function(options) { QueryInterface.prototype.showAllTables = function(options) {
var self = this; var self = this;
options = Utils._.extend({ options = Utils._.extend({
transaction: null,
raw: true, raw: true,
type: QueryTypes.SHOWTABLES type: QueryTypes.SHOWTABLES
}, options || {}); }, options || {});
......
...@@ -1075,25 +1075,23 @@ module.exports = (function() { ...@@ -1075,25 +1075,23 @@ module.exports = (function() {
} }
return new Promise(transactionResolver); return new Promise(transactionResolver);
} else { } else if (ns) {
if (ns) { var context = ns.createContext();
var context = ns.createContext();
return ns.bind(function () { return ns.bind(function () {
var ret = transaction.prepareEnvironment().return(transaction); var ret = transaction.prepareEnvironment().return(transaction);
ret.then = function (didFulfill, didReject, didProgress) { ret.then = function (didFulfill, didReject, didProgress) {
// We manually pass a context here, because the right context has to be available even though the .then callback is not strictly within the same callback chain // We manually pass a context here, because the right context has to be available even though the .then callback is not strictly within the same callback chain
didFulfill = ns.bind(didFulfill, context); didFulfill = ns.bind(didFulfill, context);
return Sequelize.Promise.prototype.then.call(this, didFulfill, didReject, didProgress); return Sequelize.Promise.prototype.then.call(this, didFulfill, didReject, didProgress);
}; };
return ret; return ret;
}, context)(); }, context)();
} else { } else {
return transaction.prepareEnvironment().return(transaction); return transaction.prepareEnvironment().return(transaction);
}
} }
}; };
...@@ -1104,7 +1102,7 @@ module.exports = (function() { ...@@ -1104,7 +1102,7 @@ module.exports = (function() {
if (last && Utils._.isPlainObject(last) && last.hasOwnProperty('logging')) { if (last && Utils._.isPlainObject(last) && last.hasOwnProperty('logging')) {
options = last; options = last;
// remove options from set of logged arguments // remove options from set of logged arguments
args.splice(args.length-1, 1); args.splice(args.length-1, 1);
} else { } else {
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
"validator": "~3.22.1" "validator": "~3.22.1"
}, },
"devDependencies": { "devDependencies": {
"continuation-local-storage": "3.1.2",
"chai-as-promised": "^4.1.1", "chai-as-promised": "^4.1.1",
"sqlite3": "~3.0.0", "sqlite3": "~3.0.0",
"mysql": "~2.5.0", "mysql": "~2.5.0",
......
...@@ -13,8 +13,10 @@ chai.config.includeStack = true; ...@@ -13,8 +13,10 @@ chai.config.includeStack = true;
describe(Support.getTestDialectTeaser("Continuation local storage"), function () { describe(Support.getTestDialectTeaser("Continuation local storage"), function () {
before(function () { before(function () {
this.sequelize = Support.createSequelizeInstance({ return Support.prepareTransactionTest(Support.createSequelizeInstance({
namespace: cls.createNamespace('sequelize') namespace: cls.createNamespace('sequelize')
})).bind(this).then(function (sequelize) {
this.sequelize = sequelize;
}); });
}); });
...@@ -91,7 +93,7 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function () ...@@ -91,7 +93,7 @@ describe(Support.getTestDialectTeaser("Continuation local storage"), function ()
}); });
}); });
// Wait for 500 ms - should be enough time to get everything set up // Wait for 400 ms - should be enough time to get everything set up
return Promise.delay(400).bind(this).then(function () { return Promise.delay(400).bind(this).then(function () {
expect(transactionSetup).to.be.ok; expect(transactionSetup).to.be.ok;
expect(transactionEnded).not.to.be.ok; expect(transactionEnded).not.to.be.ok;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!