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

Commit d46a84ff by Verdier Committed by Jan Aagaard Meier

lowercase onDelete option before cheking its value

1 parent b4ac961b
# Next
- [FIXED] Apply scopes to `aggregate` [#4764](https://github.com/sequelize/sequelize/issues/4764)
- [ADDED/FIXED] Lower case `onDelete` option to allow the use of `onDelete: 'CASCADE', hooks: true`.
# 3.13.0
- [FIXED] timestamp columns are no longer undefined for associations loaded with `separate`. [#4740](https://github.com/sequelize/sequelize/issues/4740)
......
......@@ -629,13 +629,15 @@ QueryInterface.prototype.delete = function(instance, tableName, identifier, opti
// Check for a restrict field
if (!!instance.Model && !!instance.Model.associations) {
var keys = Object.keys(instance.Model.associations)
, length = keys.length;
, length = keys.length
, association;
for (var i = 0; i < length; i++) {
if (instance.Model.associations[keys[i]].options && instance.Model.associations[keys[i]].options.onDelete) {
if (instance.Model.associations[keys[i]].options.onDelete === 'cascade' && instance.Model.associations[keys[i]].options.useHooks === true) {
cascades.push(instance.Model.associations[keys[i]].accessors.get);
}
association = instance.Model.associations[keys[i]];
if (association.options && association.options.onDelete &&
association.options.onDelete.toLowerCase() === 'cascade' &&
association.options.useHooks === true) {
cascades.push(association.accessors.get);
}
}
}
......
......@@ -1122,7 +1122,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
title: DataTypes.STRING
});
this.Projects.hasOne(this.Tasks, {onDelete: 'cascade', hooks: true});
this.Projects.hasOne(this.Tasks, {onDelete: 'CASCADE', hooks: true});
this.Tasks.belongsTo(this.Projects);
return this.sequelize.sync({ force: true });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!