From 54d78c7258ebb1378e35acaf1fb1ebc40bf09a8c Mon Sep 17 00:00:00 2001 From: Luiggi Anguiano Date: Tue, 1 Dec 2015 15:12:12 -0200 Subject: [PATCH] temporary fix for a collateral effect Check if record is undefined before proceed with validation. Memory adapter is generating undefined items in collection. --- lib/database.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/database.js b/lib/database.js index b2406d0..d075711 100644 --- a/lib/database.js +++ b/lib/database.js @@ -447,7 +447,8 @@ Database.prototype.enforceUniqueness = function(collectionName, values, updatedI if(!attrDef.unique) continue; for (var index in this.data[collectionName]) { - + if (typeof this.data[collectionName][index] === "undefined" || this.data[collectionName][index] === null) continue; + // Ignore uniqueness check on undefined values // (they shouldn't have been stored anyway) if (_.isUndefined(values[attrName])) continue;