Compare commits

...

3 Commits

@ -1,3 +1,7 @@
## 2.0.1 (July 25, 2017)
* __Patch:__ Made the error message for composite UNIQUE constraint violations slightly more readable, by wrapping multiple columns and values in a set of brackets.
## 2.0.0 (July 14, 2017) ## 2.0.0 (July 14, 2017)
* __BREAKING:__ A `UniqueConstraintViolationError` may now contain different values, depending on whether the violated constraint was a composite across multiple columns or not. For single-column `UNIQUE` constraints, the `value` and `column` properties will still be present as before; however, for a composite constraint, those properties will be undefined and `values` and `columns` will be set instead. * __BREAKING:__ A `UniqueConstraintViolationError` may now contain different values, depending on whether the violated constraint was a composite across multiple columns or not. For single-column `UNIQUE` constraints, the `value` and `column` properties will still be present as before; however, for a composite constraint, those properties will be undefined and `values` and `columns` will be set instead.

@ -1,6 +1,6 @@
{ {
"name": "database-error", "name": "database-error",
"version": "2.0.0", "version": "2.0.1",
"description": "Turns errors from database libraries into more useful error objects", "description": "Turns errors from database libraries into more useful error objects",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

@ -25,7 +25,7 @@ module.exports = {
if (columnValue.includes(",")) { if (columnValue.includes(",")) {
columns = splitValues(columnValue); columns = splitValues(columnValue);
messageColumn = `columns ${columns.map(column => `'${column}'`).join(", ")}`; messageColumn = `columns [${columns.map(column => `'${column}'`).join(", ")}]`;
isComposite = true; isComposite = true;
} else { } else {
column = columnValue; column = columnValue;
@ -35,7 +35,7 @@ module.exports = {
if (valueValue.includes(",")) { if (valueValue.includes(",")) {
values = splitValues(valueValue); values = splitValues(valueValue);
messageValue = `Values ${values.map(value => `'${value}'`).join(", ")} already exist`; messageValue = `Values [${values.map(value => `'${value}'`).join(", ")}] already exist`;
} else { } else {
value = valueValue; value = valueValue;
messageValue = `Value '${value}' already exists`; messageValue = `Value '${value}' already exists`;

Loading…
Cancel
Save