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

Commit 0c114c36 by Jan Aagaard Meier

Removed all queryAndEmit calls from the regular queryinterface

1 parent 80503f1f
......@@ -5,6 +5,7 @@ Notice: All 1.7.x changes are present in 2.0.x aswell
- Sequelize now returns promises instead of its custom event emitter from most calls. This affects methods that return multiple values (like `findOrCreate` or `findOrInitialize`). If your current callbacks do not accept the 2nd success parameter you might be seeing an array as the first param. Either use `.spread()` for these methods or add another argument to your callback: `.success(instance)` -> `.success(instance, created)`.
- `.success()`/`.done()` and any other non promise methods are now deprecated (we will keep the codebase around for a few versions though). on('sql') persists for debugging purposes.
- Model association calls (belongsTo/hasOne/hasMany) are no longer chainable. (this is to support being able to pass association references to include rather than model/as combinations)
- `QueryInterface` no longer emits events
# v2.0.0-dev11
### Caution: This release contains many changes and is highly experimental
......
......@@ -102,7 +102,7 @@ Hooks.runHooks = function() {
})
if (fn) {
promise.spread(function () {
promise = promise.spread(function () {
fn.apply(self, [null].concat(Array.prototype.slice.apply(arguments)));
}, fn);
}
......
......@@ -648,17 +648,15 @@ module.exports = (function() {
// This semi awkward syntax where we can't return the chain directly but have to return the last .then() call is to allow sql proxying
return self.Model.runHooks(self.Model.options.hooks.beforeDestroy, self).then(function () {
var query
, identifier
var identifier
if (self.Model._timestampAttributes.deletedAt && options.force === false) {
self.dataValues[self.Model._timestampAttributes.deletedAt] = new Date()
query = self.save(options)
return self.save(options)
} else {
identifier = self.__options.hasPrimaryKeys ? self.primaryKeyValues : { id: self.id };
query = self.QueryInterface.delete(self, self.QueryInterface.QueryGenerator.addSchema(self.Model), identifier, options)
return self.QueryInterface.delete(self, self.QueryInterface.QueryGenerator.addSchema(self.Model), identifier, options)
}
return query;
}).then(function (results) {
return self.Model.runHooks(self.Model.options.hooks.afterDestroy, self).return(results);
});
......
......@@ -170,7 +170,7 @@ module.exports = (function() {
type: QueryTypes.SELECT
}, options || {})
return self.QueryInterface.queryAndEmit([result.toSql(), self, options], 'snafu')
return self.sequelize.query(result.toSql(), self, options)
}
return result
......@@ -393,7 +393,7 @@ module.exports = (function() {
if (options.force) {
return self.drop(options).then(function () {
return doQuery().return(self);
return doQuery().return(self)
});
} else {
return doQuery().return(this)
......@@ -1143,7 +1143,7 @@ module.exports = (function() {
}
if(this.sequelize.options.dialect === 'postgres' && options.ignoreDuplicates) {
return this.sequelize.Promise.reject(new Error('Postgres does not support the \'ignoreDuplicates\' option.'))
return Utils.Promise.reject(new Error('Postgres does not support the \'ignoreDuplicates\' option.'))
}
var self = this
......
......@@ -361,9 +361,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
Task.create({ title: 'task' }).success(function(task) {
task.setUser(user).success(function() {
// Should fail due to FK restriction
user.destroy().then(function () {
assert(false);
}, function(err) {
user.destroy().catch(function(err) {
expect(err).to.be.ok;
Task.findAll().success(function(tasks) {
expect(tasks).to.have.length(1)
......
......@@ -98,10 +98,10 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
if (dialect === 'mariadb') {
expect(err.message).to.match(/Access denied for user/)
} else if (dialect === 'postgres') {
// When the test is run with only it produces:
// Error: Error: Failed to authenticate for PostgresSQL. Please double check your settings.
// When its run with all the other tests it produces:
// Error: invalid port number: "99999"
// When the test is run with only it produces:
// Error: Error: Failed to authenticate for PostgresSQL. Please double check your settings.
// When its run with all the other tests it produces:
// Error: invalid port number: "99999"
expect(err.message).to.match(/invalid port number/)
} else {
expect(err.message).to.match(/Failed to authenticate/)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!