aboutsummaryrefslogtreecommitdiff
path: root/src/guff/database.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/database.cr')
-rw-r--r--src/guff/database.cr11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/guff/database.cr b/src/guff/database.cr
index 0e41b75..9201a38 100644
--- a/src/guff/database.cr
+++ b/src/guff/database.cr
@@ -123,9 +123,14 @@ module Guff
end
def transaction(&block)
- query("BEGIN")
- block.call
- query("COMMIT")
+ begin
+ query("BEGIN")
+ block.call
+ query("COMMIT")
+ rescue e
+ query("ROLLBACK")
+ raise e
+ end
end
private def run(