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

Use begin_transaction if connection responds to it (AR 4) #189

Merged
merged 1 commit into from Mar 4, 2013

Conversation

dchelimsky
Copy link
Contributor

Supports ActiveRecord-4.0.0.beta1

Fixes #188 and #187.
Based on the suggestion from @sjmadsen in #187.

I have not run the full test suite successfully (don't have everything set up), so let's see what travis says.

Supports ActiveRecord-4.0.0.beta1
@dchelimsky
Copy link
Contributor Author

OK - we won't see what travis says because I don't think you have the PR bot set up :)

@bmabey I can tell you that this solves #188 for me, but I don't know what else it breaks. If anybody else has the time/inclination/setup to verify this works and doesn't break anything else, I'd be most appreciative.

@bmabey
Copy link
Contributor

bmabey commented Mar 3, 2013

Thanks @dchelimsky! The bot is set up and it has given this PR green. @sjmadsen, would you mind testing this PR on your Postgres setup?

@sjmadsen
Copy link

sjmadsen commented Mar 4, 2013

@bmabey This PR solves #187 for me. Thanks @dchelimsky!

@dchelimsky
Copy link
Contributor Author

@sjmadsen all I did was implement your suggestion :) You're welcome!

bmabey added a commit that referenced this pull request Mar 4, 2013
Use begin_transaction if connection responds to it (AR 4)
@bmabey bmabey merged commit 0f6af3e into DatabaseCleaner:master Mar 4, 2013
@bmabey
Copy link
Contributor

bmabey commented Mar 4, 2013

FYI, I've released v1.0.0.RC1 with this in it. I'll have some existing rails 3.0 users take it for a spin before releasing the final gem. Thanks again!

@dchelimsky dchelimsky deleted the fix-188 branch March 4, 2013 13:08
@dchelimsky dchelimsky restored the fix-188 branch March 4, 2013 13:08
@sigvei
Copy link

sigvei commented Mar 7, 2013

This works great, except when switching strategies. I do this in spec_helper:

  config.before(:each) do
    DatabaseCleaner.strategy = case Capybara.current_driver
                               when :rack_test ; :transaction
                               else ; :truncation
                               end
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end

All tests up to the selenium ones, which use truncation, succeed. But when the strategy is switched back to transaction for the remaining "normal" tests, I get the ActiveRecord::StatementInvalid: SQLite3::SQLException: cannot start a transaction within a transaction: begin transaction.

This is with v1.0.0.RC1, by the way.

@dchelimsky
Copy link
Contributor Author

@sigvei does the same spec_helper.rb work for you with database_cleaner 0.9.1?

@dchelimsky
Copy link
Contributor Author

@bmabey any word on @sigvei's issue?

@bmabey
Copy link
Contributor

bmabey commented Apr 3, 2013

Sorry, I haven't taken the time to look into @sigvei's issue yet. @sigvei, what version of AR are you using exactly?

@bmabey
Copy link
Contributor

bmabey commented Apr 3, 2013

@sigvei A base project with your setup on a bare rails project with the exact same dependencies would help me debug this. If you have the time please put one up on github so I can take a look.

Also, I've merged in some other changes dealing with new AR changes so please try the latest from git to see if they have resolved your issue.

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

Successfully merging this pull request may close these issues.

Nested transactions are causing an exception with Rails 4 beta + sqlite
4 participants