From 9bde76865ef2ac7dd680e7d6bb7079a6da303686 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Tue, 13 Dec 2016 16:14:51 -0300 Subject: [PATCH] add todo for corner case of transaction(&block) --- src/db/begin_transaction.cr | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/db/begin_transaction.cr b/src/db/begin_transaction.cr index fea9dfe..c07d785 100644 --- a/src/db/begin_transaction.cr +++ b/src/db/begin_transaction.cr @@ -7,6 +7,15 @@ module DB begin yield tx rescue e + # TODO check if `unless tx.closed?` should be added. + # If it is not added, when an exception occurs after the + # transaction is closed (explicit rollback/commit) + # the call to rollback will trigger an exception. + # Since the code will be in between `#transaction(&block)` + # seems reasonable to raise an error since it might trigger + # a design flaw. Transaction might been commited already. + # Maybe we should wrap e in another exception that clarifies + # this scenario. tx.rollback raise e unless e.is_a?(DB::Rollback) else