Skip to content

Commit ce5c338

Browse files
author
Jason Murad
committed
move "has zero" to destroy/hook check up earlier
1 parent f0f3f75 commit ce5c338

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/query-interface.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,14 @@ QueryInterface.prototype.delete = function(instance, tableName, identifier, opti
648648
transaction: options.transaction,
649649
logging: options.logging
650650
}).then(function (instances) {
651+
// Check for hasOne relationship with non-existing associate ("has zero")
652+
if (!instances) {
653+
return Promise.resolve();
654+
}
655+
651656
if (!Array.isArray(instances)) instances = [instances];
652657

653658
return Promise.each(instances, function (instance) {
654-
if (!instance) {
655-
return Promise.resolve();
656-
}
657-
658659
return instance.destroy({
659660
transaction: options.transaction,
660661
logging: options.logging

0 commit comments

Comments
 (0)