Please sign in to comment.
In Model#save and destroy, don't rollback transactions you didn't ini…
…tiate This fixes the issue where an outer transaction is present, and use_transactions is set for the model instance, and one of the before hooks returns false. With the recent commits, that would rollback the outer transaction. This required refactoring so that save_failure now always raises, it doesn't check raise_on_save_failure. Model#save and destroy now use checked_save_failure, which ignore the error raised by save_failure if raise_on_save_failure is true. While refactoring, I decided it was no longer worth using save_failure to handle validation failures, so the validation failures don't call it. before_validation hook callers only call it if raise_on_save_failure is true, since they aren't wrapped by check_save_failure. This breaks backwards compatibility for callers of save_failure, which is a private method. While here, add checked_transaction private method that uses transactions if necessary.
- Loading branch information...
Showing with 51 additions and 21 deletions.