Skip to content
This repository was archived by the owner on Aug 13, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Database.prototype.update = function(collectionName, options, values, cb) {
// Filter Data based on Options criteria
var collectionSchema = this.schema[collectionName] || {};
var resultSet = waterlineCriteria(collectionName, this.data, options, collectionSchema);
var resultIds = _.pluck(resultSet.results, 'id');
var resultIds = _.pluck(resultSet.results, getPrimaryKey(collectionSchema));

// Enforce uniqueness constraints, indicating which records are updated
// in case `values` doesn't contain an id.
Expand Down Expand Up @@ -461,11 +461,9 @@ Database.prototype.enforceUniqueness = function(collectionName, values, updatedI
// It isn't actually a uniqueness violation if the record(s)
// we're checking is the same as the record(s) we're updating/creating
if (_.isUndefined(values[pkAttrName])) {
if (updatedIds && updatedIds.indexOf(this.data[collectionName][index][pkAttrName]) > -1) {
continue; // Id was found in the list of records being updated.
}
} else if (values[pkAttrName] === this.data[collectionName][index][pkAttrName]) {
continue; // This is the data of the single record being updated.
} else if (updatedIds && updatedIds.indexOf(this.data[collectionName][index][pkAttrName]) > -1) {
continue; // Id was found in the list of records being updated.
}

var uniquenessError = {
Expand Down