不要怂,就是干,撸起袖子干!

Commit 163235e0 by Mick Hansen

Merge pull request #2806 from seegno/bugfix/add-unique-keys-check

Add unique keys check to postgres
2 parents 589357ac c7e930b8
Showing with 8 additions and 6 deletions
......@@ -275,12 +275,14 @@ module.exports = (function() {
field + ' must be unique', 'unique violation', field, value));
});
Utils._.forOwn(this.callee.__options.uniqueKeys, function(constraint) {
if (Utils._.isEqual(constraint.fields, Object.keys(fields)) && !!constraint.msg) {
message = constraint.msg;
return false;
}
});
if (this.callee.__options && this.callee.__options.uniqueKeys) {
Utils._.forOwn(this.callee.__options.uniqueKeys, function(constraint) {
if (Utils._.isEqual(constraint.fields, Object.keys(fields)) && !!constraint.msg) {
message = constraint.msg;
return false;
}
});
}
return new sequelizeErrors.UniqueConstraintError({
message: message,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!