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

Commit 239da95e by Ruben Bridgewater

Fix foreign database language failures

1 parent 95a5c0d8
......@@ -112,7 +112,7 @@ module.exports = (function() {
case 1062:
match = err.message.match(/Duplicate entry '(.*)' for key '?((.|\s)*?)'?$/);
var values = match[1].split('-')
var values = match ? match[1].split('-') : undefined
, fields = {}
, message = 'Validation error'
, uniqueKey = this.callee && this.callee.__options.uniqueKeys[match[2]];
......@@ -142,7 +142,7 @@ module.exports = (function() {
return new sequelizeErrors.ForeignKeyConstraintError({
fields: null,
index: match[3],
index: match ? match[3] : undefined,
parent: err
});
......@@ -151,7 +151,7 @@ module.exports = (function() {
return new sequelizeErrors.ForeignKeyConstraintError({
fields: null,
index: match[1],
index: match ? match[1] : undefined,
parent: err
});
......
......@@ -354,8 +354,10 @@ module.exports = (function() {
switch (code) {
case '23503':
index = errMessage.match(/violates foreign key constraint \"(.+?)\"/)[1];
table = errMessage.match(/on table \"(.+?)\"/)[1];
index = errMessage.match(/violates foreign key constraint \"(.+?)\"/);
index = index ? index[1] : undefined;
table = errMessage.match(/on table \"(.+?)\"/);
table = table ? table[1] : undefined;
return new sequelizeErrors.ForeignKeyConstraintError({
fields: null,
......@@ -404,7 +406,9 @@ module.exports = (function() {
case '23P01':
match = errDetail.match(/Key \((.*?)\)=\((.*?)\)/);
fields = Utils._.zipObject(match[1].split(', '), match[2].split(', '));
if (match) {
fields = Utils._.zipObject(match[1].split(', '), match[2].split(', '));
}
message = 'Exclusion constraint error';
return new sequelizeErrors.ExclusionConstraintError({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!