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

Commit 6804e27b by DivX.Hu Committed by Sushant

fix(mysql): improve unique key violation handling (#9724)

1 parent 458960d7
Showing with 4 additions and 2 deletions
......@@ -204,13 +204,15 @@ class Query extends AbstractQuery {
let fields = {};
let message = 'Validation error';
const values = match ? match[1].split('-') : undefined;
const uniqueKey = this.model && this.model.uniqueKeys[match[2]];
const fieldKey = match ? match[2] : undefined;
const fieldVal = match ? match[1] : undefined;
const uniqueKey = this.model && this.model.uniqueKeys[fieldKey];
if (uniqueKey) {
if (uniqueKey.msg) message = uniqueKey.msg;
fields = _.zipObject(uniqueKey.fields, values);
} else {
fields[match[2]] = match[1];
fields[fieldKey] = fieldVal;
}
const errors = [];
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!