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

Commit 0b9ddfa4 by Jan Aagaard Meier

Add support for 2233 for pg and sqlite

1 parent 95af31e9
......@@ -226,6 +226,14 @@ module.exports = (function() {
var match;
switch (err.code) {
case '23503':
match = err.message.match(/violates foreign key constraint \"(.+?)\" on table \"(.+?)\"/);
return new sequelizeErrors.ForeignKeyConstraintError({
fields: null,
index: match[1],
table: match[2],
parent: err
});
case '23505':
match = err.detail.match(/Key \((.*?)\)=\((.*?)\) already exists/);
......
......@@ -197,6 +197,13 @@ module.exports = (function() {
});
}
match = err.message.match(/FOREIGN KEY constraint failed/);
if (match !== null) {
return new sequelizeErrors.ForeignKeyConstraintError({
parent :err
});
}
return err;
case 'SQLITE_BUSY':
return new sequelizeErrors.TimeoutError(err);
......
......@@ -137,6 +137,7 @@ error.ForeignKeyConstraintError = function (options) {
this.message = options.message;
this.fields = options.fields;
this.table = options.table;
this.value = options.value;
this.index = options.index;
};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!