From 45d76a6bd55686bad74ff8de90e87d4414625c3d Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 26 Apr 2022 09:50:51 -0500 Subject: [PATCH] Wrap the connection yielded from a transaction --- lib/postgres.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/postgres.rb b/lib/postgres.rb index bbaeea1..ba7af8b 100644 --- a/lib/postgres.rb +++ b/lib/postgres.rb @@ -15,4 +15,10 @@ class Postgres < SimpleDelegator rows.field_names_as(field_names_as)&.first || default end end + + def transaction(*args) + super(*args) do |db| + yield self.class.new(db) + end + end end -- 2.45.2