Fail uniqueness check in case of db error

This commit is contained in:
Anatoliy Chakkaev 2013-05-16 20:14:10 +04:00 committed by Raymond Feng
parent 630b991d1d
commit 4c717e4335
1 changed files with 3 additions and 0 deletions

View File

@ -287,6 +287,9 @@ function validateUniqueness(attr, conf, err, done) {
var cond = {where: {}};
cond.where[attr] = this[attr];
this.constructor.all(cond, function (error, found) {
if (error) {
return err();
}
if (found.length > 1) {
err();
} else if (found.length === 1 && (!this.id || !found[0].id || found[0].id.toString() != this.id.toString())) {