Skip to content

Commit c320430

Browse files
committed
allow setting Onyx::SQL::Repository#db with DB::Transaction instances
1 parent ec866c9 commit c320430

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/onyx-sql/repository.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ module Onyx::SQL
3232
def initialize(@db : ::DB::Database | ::DB::Connection, @logger : Logger = Logger::Standard.new)
3333
end
3434

35+
def db=(transaction : ::DB::Transaction)
36+
self.db = transaction.connection
37+
end
38+
3539
protected def postgresql?
3640
{% if Object.all_subclasses.any? { |sc| sc.stringify == "PG::Driver" } %}
3741
return db.is_a?(PG::Driver)

0 commit comments

Comments
 (0)