Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction strategy fails with Sequel #2

Open
brauliobo opened this issue Feb 13, 2017 · 5 comments
Open

Transaction strategy fails with Sequel #2

brauliobo opened this issue Feb 13, 2017 · 5 comments

Comments

@brauliobo
Copy link

Backtrace:

NoMethodError: undefined method `pop' for nil:NilClass
  /home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/sequel/transaction.rb:31:in `clean'
  /home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/base.rb:46:in `clean_with'
  /home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:91:in `block in clean_with'
  /home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:91:in `each'
  /home/braulio/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:91:in `clean_with'
  /home/braulio/Projects/olery/scheduler/spec/support/database_cleaner.rb:7:in `block (2 levels) in <top (required)>'

Multiple threads being used

@brauliobo brauliobo changed the title Transaction fails with Sequel Transaction strategy fails with Sequel Feb 13, 2017
@kaikuchn
Copy link

I just ran into the same problem. In my case it's because Sequel::DATABASES was empty when calling DatabaseCleaner.start.

Thus I simply had to initialise the connection to my database before calling DatabaseCleaner.start

@botandrose botandrose transferred this issue from DatabaseCleaner/database_cleaner Feb 18, 2020
@jeffvincent
Copy link
Contributor

Ran into this as well. Updated implementation and it is working as expected:

class Minitest::Spec
  before :each do
    DatabaseCleaner[:sequel].start
  end

  after :each do
    DatabaseCleaner[:sequel].clean
  end
end

@botandrose
Copy link
Contributor

@jeffvincent It sounds like maybe this situation could be addressed in the README? What do you think?

@jeffvincent
Copy link
Contributor

Totally agree! tbh, I wasn't confident enough in my solution. Was expecting to hear about all kinds of terrible externalities I caused by doing things this way :)

An update to the README would certainly help future-me. I'm happy to create PR, if you think that's a good idea.

@botandrose
Copy link
Contributor

@jeffvincent Yes, please do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants