Skip to content

Commit f0b16e6

Browse files
committed
Revert "this jruby bug was fixed back in 2013, so we can remove this workaround. see DatabaseCleaner/database_cleaner#256"
This reverts commit 0ec3be3.
1 parent 94cffaf commit f0b16e6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

lib/database_cleaner/sequel/transaction.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
module DatabaseCleaner
44
module Sequel
55
class Transaction < Base
6+
def self.check_fiber_brokenness
7+
if !@checked_fiber_brokenness && Fiber.new { Thread.current }.resume != Thread.current
8+
raise RuntimeError, "This ruby engine's Fibers are not compatible with Sequel's connection pool. " +
9+
"To work around this, please use DatabaseCleaner.cleaning with a block instead of " +
10+
"DatabaseCleaner.start and DatabaseCleaner.clean"
11+
end
12+
@checked_fiber_brokenness = true
13+
end
14+
615
def start
16+
self.class.check_fiber_brokenness
17+
718
@fibers ||= []
819
db = self.db
920
f = Fiber.new do
@@ -19,6 +30,10 @@ def clean
1930
f = @fibers.pop
2031
f.resume
2132
end
33+
34+
def cleaning
35+
self.db.transaction(:rollback => :always, :savepoint => true, :auto_savepoint => true) { yield }
36+
end
2237
end
2338
end
2439
end

0 commit comments

Comments
 (0)