Skip to content

Commit 0c4ddcd

Browse files
author
Jason Murad
committed
test case for cascade-delete-with-hooks when has-zero-or-one
1 parent ce5c338 commit 0c4ddcd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/integration/associations/has-one.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,21 @@ describe(Support.getTestDialectTeaser('HasOne'), function() {
381381
});
382382
});
383383

384+
it('works when cascading a delete with hooks but there is no associate (i.e. "has zero")', function() {
385+
var Task = this.sequelize.define('Task', { title: Sequelize.STRING })
386+
, User = this.sequelize.define('User', { username: Sequelize.STRING });
387+
388+
User.hasOne(Task, {onDelete: 'cascade', hooks: true});
389+
390+
return User.sync({ force: true }).then(function() {
391+
return Task.sync({ force: true }).then(function() {
392+
return User.create({ username: 'foo' }).then(function(user) {
393+
return user.destroy();
394+
});
395+
});
396+
});
397+
});
398+
384399
// NOTE: mssql does not support changing an autoincrement primary key
385400
if (Support.getTestDialect() !== 'mssql') {
386401
it('can cascade updates', function() {

0 commit comments

Comments
 (0)