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

Commit cfce3a75 by Holger

* some code cleanup (after linting)

1 parent 14266ec7
......@@ -23,17 +23,17 @@ ConnectionManager.prototype.getConnection = function(options) {
var self = this;
options = options || {};
options.uuid = options.uuid || 'default';
options.inMemory = ((self.sequelize.options.storage || ':memory:') == ':memory:')?1:0;
options.inMemory = ((self.sequelize.options.storage || ':memory:') === ':memory:')?1:0;
if (self.connections[options.inMemory||options.uuid]) return Promise.resolve(self.connections[options.inMemory||options.uuid]);
if (self.connections[options.inMemory || options.uuid]) return Promise.resolve(self.connections[options.inMemory || options.uuid]);
return new Promise(function (resolve, reject) {
self.connections[options.inMemory||options.uuid] = new self.lib.Database(self.sequelize.options.storage || ':memory:', function(err) {
self.connections[options.inMemory || options.uuid] = new self.lib.Database(self.sequelize.options.storage || ':memory:', function(err) {
if (err) {
if (err.code === 'SQLITE_CANTOPEN') return reject('Failed to find SQL server. Please double check your settings.');
return reject(err);
}
resolve(self.connections[options.inMemory||options.uuid]);
resolve(self.connections[options.inMemory || options.uuid]);
});
}).tap(function (connection) {
if (self.sequelize.options.foreignKeys !== false) {
......
......@@ -591,7 +591,7 @@ module.exports = (function() {
).then(function (connection) {
var query = new self.dialect.Query(connection, self, callee, options);
return query.run(sql).finally(function() {
if (options.transaction || connection.filename == ":memory:") return;
if (options.transaction || (connection.filename === ":memory:")) return;
return self.connectionManager.releaseConnection(connection);
});
});
......
......@@ -55,41 +55,41 @@ describe(Support.getTestDialectTeaser("Transaction"), function () {
});
});
if (dialect == 'sqlite'){
it('provides persistent transactions', function (done) {
var sequelize = new Support.Sequelize('database', 'username', 'password', {dialect: 'sqlite'});
var User = sequelize.define('user', {
username: Support.Sequelize.STRING,
awesome: Support.Sequelize.BOOLEAN
});
return sequelize.transaction()
.then(function(t) {
return sequelize.sync({transaction:t})
.then(function( ) {
return t;
});
})
.then(function(t) {
return User.create({}, {transaction:t})
.then(function( ) {
t.commit();
});
})
.then(function( ) {
return sequelize.transaction();
})
.then(function(t) {
return User.findAll({}, {transaction:t});
})
.then(function(users) {
return expect(users.length).to.equal(2);
})
.then(function(object) {
done();
});
});
}
if (dialect === 'sqlite'){
it('provides persistent transactions', function (done) {
var sequelize = new Support.Sequelize('database', 'username', 'password', {dialect: 'sqlite'}),
User = sequelize.define('user', {
username: Support.Sequelize.STRING,
awesome: Support.Sequelize.BOOLEAN
});
return sequelize.transaction()
.then(function(t) {
return sequelize.sync({transaction:t})
.then(function( ) {
return t;
});
})
.then(function(t) {
return User.create({}, {transaction:t})
.then(function( ) {
t.commit();
});
})
.then(function( ) {
return sequelize.transaction();
})
.then(function(t) {
return User.findAll({}, {transaction:t});
})
.then(function(users) {
return expect(users.length).to.equal(2);
})
.then(function(object) {
done();
});
});
}
if (dialect !== 'sqlite') {
describe('row locking', function () {
this.timeout(10000);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!