From f0b16e637b86e937f876cd78daa3979cd4575102 Mon Sep 17 00:00:00 2001 From: Joe Bew Date: Tue, 26 Oct 2021 14:27:36 +0200 Subject: [PATCH 1/2] Revert "this jruby bug was fixed back in 2013, so we can remove this workaround. see https://github.com/DatabaseCleaner/database_cleaner/issues/256" This reverts commit 0ec3be3256f57520f671a239c653fcee9eb18475. --- lib/database_cleaner/sequel/transaction.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/database_cleaner/sequel/transaction.rb b/lib/database_cleaner/sequel/transaction.rb index c918a7d..c5aae45 100644 --- a/lib/database_cleaner/sequel/transaction.rb +++ b/lib/database_cleaner/sequel/transaction.rb @@ -3,7 +3,18 @@ module DatabaseCleaner module Sequel class Transaction < Base + def self.check_fiber_brokenness + if !@checked_fiber_brokenness && Fiber.new { Thread.current }.resume != Thread.current + raise RuntimeError, "This ruby engine's Fibers are not compatible with Sequel's connection pool. " + + "To work around this, please use DatabaseCleaner.cleaning with a block instead of " + + "DatabaseCleaner.start and DatabaseCleaner.clean" + end + @checked_fiber_brokenness = true + end + def start + self.class.check_fiber_brokenness + @fibers ||= [] db = self.db f = Fiber.new do @@ -19,6 +30,10 @@ def clean f = @fibers.pop f.resume end + + def cleaning + self.db.transaction(:rollback => :always, :savepoint => true, :auto_savepoint => true) { yield } + end end end end From f1519e2ac0e64fb229e1be2c4cefb9e7a3498d01 Mon Sep 17 00:00:00 2001 From: Joe Bew Date: Wed, 27 Oct 2021 09:53:56 +0200 Subject: [PATCH 2/2] Bump version to 2.0.1 --- lib/database_cleaner/sequel/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/database_cleaner/sequel/version.rb b/lib/database_cleaner/sequel/version.rb index 0871998..ac46dc1 100644 --- a/lib/database_cleaner/sequel/version.rb +++ b/lib/database_cleaner/sequel/version.rb @@ -1,5 +1,5 @@ module DatabaseCleaner module Sequel - VERSION = "2.0.0" + VERSION = "2.0.1" end end