Wrap the connection yielded from a transaction

Stephen Paul Weber created

Change summary

lib/postgres.rb | 6 ++++++
1 file changed, 6 insertions(+)

Detailed changes

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