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

Commit fbf777fa by Jan Aagaard Meier

Fix that annoying bug introduced by upsert + add changelog entry

1 parent bebb6364
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
- [FEAUTRE] Undestroy method for paranoid models [#2540](https://github.com/sequelize/sequelize/pull/2540) - [FEAUTRE] Undestroy method for paranoid models [#2540](https://github.com/sequelize/sequelize/pull/2540)
- [BUG] Add support for `field` named the same as the attribute in `reload`, `bulkCreate` and `save` [#2348](https://github.com/sequelize/sequelize/issues/2348) - [BUG] Add support for `field` named the same as the attribute in `reload`, `bulkCreate` and `save` [#2348](https://github.com/sequelize/sequelize/issues/2348)
- [BUG] Copy the options object in association getters. [#2311](https://github.com/sequelize/sequelize/issues/2311) - [BUG] Copy the options object in association getters. [#2311](https://github.com/sequelize/sequelize/issues/2311)
<<<<<<< HEAD
- [BUG] `Model#destroy()` now supports `field`, this also fixes an issue with `N:M#removeAssociation` and `field` - [BUG] `Model#destroy()` now supports `field`, this also fixes an issue with `N:M#removeAssociation` and `field`
- [BUG] Customized error message can now be set for unique constraint that was created manually (not with sync, but e.g. with migrations) or that has fields with underscore naming. This was problem at least with postgres before. - [BUG] Customized error message can now be set for unique constraint that was created manually (not with sync, but e.g. with migrations) or that has fields with underscore naming. This was problem at least with postgres before.
- [BUG] Fixed a bug where plain objects like `{ in: [...] }` were not properly converted to SQL when combined with a sequelize method (`fn`, `where` etc.). Closes [#2077](https://github.com/sequelize/sequelize/issues/2077) - [BUG] Fixed a bug where plain objects like `{ in: [...] }` were not properly converted to SQL when combined with a sequelize method (`fn`, `where` etc.). Closes [#2077](https://github.com/sequelize/sequelize/issues/2077)
- [BUG] Made the default for array search in postgres exact comparison instead of overlap - [BUG] Made the default for array search in postgres exact comparison instead of overlap
- [BUG] Allow logging from individual functions even though the global logging setting is false. Closes [#2571](https://github.com/sequelize/sequelize/issues/2571) - [BUG] Allow logging from individual functions even though the global logging setting is false. Closes [#2571](https://github.com/sequelize/sequelize/issues/2571)
- [INTERNALS] Update `inflection` dependency to v1.5.2 - [INTERNALS] Update `inflection` dependency to v1.5.2
- [FEATURE] Support for UPSERT
#### Backwards compatability changes #### Backwards compatability changes
- When eager-loading a many-to-many association, the attributes of the through table are now accessible through an attribute named after the through model rather than the through table name singularized. i.e. `Task.find({include: Worker})` where the table name for through model `TaskWorker` is `TableTaskWorkers` used to produce `{ Worker: { ..., TableTaskWorker: {...} } }`. It now produces `{ Worker: { ..., TaskWorker: {...} } }`. Does not affect models where table name is auto-defined by Sequelize, or where table name is model name pluralized. - When eager-loading a many-to-many association, the attributes of the through table are now accessible through an attribute named after the through model rather than the through table name singularized. i.e. `Task.find({include: Worker})` where the table name for through model `TaskWorker` is `TableTaskWorkers` used to produce `{ Worker: { ..., TableTaskWorker: {...} } }`. It now produces `{ Worker: { ..., TaskWorker: {...} } }`. Does not affect models where table name is auto-defined by Sequelize, or where table name is model name pluralized.
......
...@@ -210,7 +210,7 @@ module.exports = (function() { ...@@ -210,7 +210,7 @@ module.exports = (function() {
} }
return self.handleSelectQuery(rows); return self.handleSelectQuery(rows);
} else if ([QueryTypes.BULKDELETE, QueryTypes.UPSERT].indexOf(self.options.type)) { } else if ([QueryTypes.BULKDELETE, QueryTypes.UPSERT].indexOf(self.options.type) !== -1) {
return result.rowCount; return result.rowCount;
} else if (self.isInsertQuery() || self.isUpdateQuery()) { } else if (self.isInsertQuery() || self.isUpdateQuery()) {
if (!!self.callee && self.callee.dataValues) { if (!!self.callee && self.callee.dataValues) {
......
...@@ -207,16 +207,16 @@ module.exports = (function() { ...@@ -207,16 +207,16 @@ module.exports = (function() {
self.options.uniqueKeys[idxName].name = idxName || false; self.options.uniqueKeys[idxName].name = idxName || false;
} }
if (options.primaryKey === true) { }
self.primaryKeys[attribute] = self.attributes[attribute];
} if (options.primaryKey === true) {
self.primaryKeys[attribute] = self.attributes[attribute];
} }
}); });
// Add head and tail default attributes (id, timestamps) // Add head and tail default attributes (id, timestamps)
addDefaultAttributes.call(this); addDefaultAttributes.call(this);
addOptionalClassMethods.call(this); addOptionalClassMethods.call(this);
// Primary key convenience variables // Primary key convenience variables
this.primaryKeyAttributes = Object.keys(this.primaryKeys); this.primaryKeyAttributes = Object.keys(this.primaryKeys);
this.primaryKeyAttribute = this.primaryKeyAttributes[0]; this.primaryKeyAttribute = this.primaryKeyAttributes[0];
...@@ -252,7 +252,6 @@ module.exports = (function() { ...@@ -252,7 +252,6 @@ module.exports = (function() {
self.Instance.prototype[name] = fct; self.Instance.prototype[name] = fct;
}); });
} }
this.refreshAttributes(); this.refreshAttributes();
findAutoIncrementField.call(this); findAutoIncrementField.call(this);
......
...@@ -49,7 +49,7 @@ describe(Support.getTestDialectTeaser("Self"), function() { ...@@ -49,7 +49,7 @@ describe(Support.getTestDialectTeaser("Self"), function() {
}); });
}); });
it.only('can handle n:m associations', function() { it('can handle n:m associations', function() {
var self = this; var self = this;
var Person = this.sequelize.define('Person', { name: DataTypes.STRING }); var Person = this.sequelize.define('Person', { name: DataTypes.STRING });
...@@ -60,7 +60,6 @@ describe(Support.getTestDialectTeaser("Self"), function() { ...@@ -60,7 +60,6 @@ describe(Support.getTestDialectTeaser("Self"), function() {
var foreignIdentifiers = _.map(_.values(Person.associations), 'foreignIdentifier'); var foreignIdentifiers = _.map(_.values(Person.associations), 'foreignIdentifier');
var rawAttributes = _.keys(this.sequelize.models.Family.rawAttributes); var rawAttributes = _.keys(this.sequelize.models.Family.rawAttributes);
console.log(rawAttributes);
expect(foreignIdentifiers.length).to.equal(2); expect(foreignIdentifiers.length).to.equal(2);
expect(rawAttributes.length).to.equal(4); expect(rawAttributes.length).to.equal(4);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!