Fail uniqueness check in case of db error
This commit is contained in:
parent
630b991d1d
commit
4c717e4335
|
@ -287,6 +287,9 @@ function validateUniqueness(attr, conf, err, done) {
|
||||||
var cond = {where: {}};
|
var cond = {where: {}};
|
||||||
cond.where[attr] = this[attr];
|
cond.where[attr] = this[attr];
|
||||||
this.constructor.all(cond, function (error, found) {
|
this.constructor.all(cond, function (error, found) {
|
||||||
|
if (error) {
|
||||||
|
return err();
|
||||||
|
}
|
||||||
if (found.length > 1) {
|
if (found.length > 1) {
|
||||||
err();
|
err();
|
||||||
} else if (found.length === 1 && (!this.id || !found[0].id || found[0].id.toString() != this.id.toString())) {
|
} else if (found.length === 1 && (!this.id || !found[0].id || found[0].id.toString() != this.id.toString())) {
|
||||||
|
|
Loading…
Reference in New Issue