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

Commit 816f20be by Pelle Jacobs Committed by Sushant

fix(mssql): optimize formatError RegEx (#11725)

1 parent bc87076a
Showing with 4 additions and 4 deletions
...@@ -251,7 +251,7 @@ class Query extends AbstractQuery { ...@@ -251,7 +251,7 @@ class Query extends AbstractQuery {
formatError(err) { formatError(err) {
let match; let match;
match = err.message.match(/Violation of (?:UNIQUE|PRIMARY) KEY constraint '((.|\s)*)'. Cannot insert duplicate key in object '.*'.(:? The duplicate key value is \((.*)\).)?/); match = err.message.match(/Violation of (?:UNIQUE|PRIMARY) KEY constraint '([^']*)'. Cannot insert duplicate key in object '.*'.(:? The duplicate key value is \((.*)\).)?/);
match = match || err.message.match(/Cannot insert duplicate key row in object .* with unique index '(.*)'/); match = match || err.message.match(/Cannot insert duplicate key row in object .* with unique index '(.*)'/);
if (match && match.length > 1) { if (match && match.length > 1) {
let fields = {}; let fields = {};
...@@ -261,12 +261,12 @@ class Query extends AbstractQuery { ...@@ -261,12 +261,12 @@ class Query extends AbstractQuery {
if (uniqueKey && !!uniqueKey.msg) { if (uniqueKey && !!uniqueKey.msg) {
message = uniqueKey.msg; message = uniqueKey.msg;
} }
if (match[4]) { if (match[3]) {
const values = match[4].split(',').map(part => part.trim()); const values = match[3].split(',').map(part => part.trim());
if (uniqueKey) { if (uniqueKey) {
fields = _.zipObject(uniqueKey.fields, values); fields = _.zipObject(uniqueKey.fields, values);
} else { } else {
fields[match[1]] = match[4]; fields[match[1]] = match[3];
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!