File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
lib/database_cleaner/active_record Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,16 @@ module DatabaseCleaner
44 module ActiveRecord
55 class Transaction < Base
66 def start
7+ connection = if ::ActiveRecord . version >= Gem ::Version . new ( "7.2" )
8+ connection_class . lease_connection
9+ else
10+ connection_class . connection
11+ end
12+
713 # Hack to make sure that the connection is properly set up before cleaning
8- connection_class . connection . transaction { }
14+ connection . transaction { }
915
10- connection_class . connection . begin_transaction joinable : false
16+ connection . begin_transaction joinable : false
1117 end
1218
1319
Original file line number Diff line number Diff line change @@ -30,7 +30,13 @@ def clean
3030 private
3131
3232 def connection
33- @connection ||= ConnectionWrapper . new ( connection_class . connection )
33+ @connection ||= ConnectionWrapper . new (
34+ if ::ActiveRecord . version >= Gem ::Version . new ( "7.2" )
35+ connection_class . lease_connection
36+ else
37+ connection_class . connection
38+ end
39+ )
3440 end
3541
3642 def tables_to_truncate ( connection )
@@ -246,4 +252,3 @@ def tables_with_schema
246252 private_constant :ConnectionWrapper
247253 end
248254end
249-
You can’t perform that action at this time.
0 commit comments