Fix uniqueness validation (mongo ids)

This commit is contained in:
Anatoliy Chakkaev 2013-01-23 03:22:48 +07:00
parent d03dbfcb99
commit 59e80e8454
1 changed files with 1 additions and 1 deletions

View File

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