Open fcarreiro opened 7 years ago
Hi @fcarreiro
Actually my initial intention was to have similar exceptions as in Sequelize. But I couldn't "squeeze" all these errors out for my needed MySQL. The only thing that would be meaningful to have general Errors classes that all dialect handlers utilize.
The code can be improved to determine by the error message if it was a ForeignKeyError etc.
It took me a while but I found how ActiveRecord does it. Maybe it's a good place to start?
Its a good find! I will take a look
Great :) However, I think ActiveRecord does most checks (I mean, validations) manually to avoid relying on the DB. If I'm not mistaken, it does extra queries to check for uniqueness and does type-checks before inserting/updating :/
Hi all! I got here looking for a way to uniformly handle Bookshelf (and knex) uniqueness and other constraints errors. It is something that knex is certainly missing and I like were this lib is going.
My question/comment/suggestion is: is there a plan to be more fine-grained in the handling of errors? For example, as they do in Sequelize: http://docs.sequelizejs.com/en/v3/api/errors/
Cheers!
UPDATE: I realize now that Sequelize validations are at the model level, not the DB level, if I understood correctly (more like what can be acchieved with Joi). In any case, I hope what I am referring to is clear: to uniformly parse errors triggered by uniqueness and other constraints in the DB.