Skip to content

truncate_option to allow CASCADE mode alongside the default RESTRICT #118

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

pat
Copy link
Contributor

@pat pat commented Jan 6, 2025

This is largely the hard work of @theGeorgous in #99, alongside the initiative of @nnishimura in #115 to rebase. I've added a couple of tests and ensured the argument is being passed through correctly.

Please attribute credit to @thegeorgeous - I just jumped in with these tweaks to help ensure it can be merged in as easily as possible.

@macosgrove
Copy link

@etagwerker This PR also fixes my issue upgrading to Rails 7.1, but this one has passing tests. Please merge as soon as possible.

This was referenced May 12, 2025
Copy link
Member

@etagwerker etagwerker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pat Looks good, thanks!

@etagwerker etagwerker merged commit a164b66 into DatabaseCleaner:main May 13, 2025
1 check passed
@mlarraz
Copy link

mlarraz commented May 14, 2025

We have a gem that has an unconstrained dependency on database_cleaner and started failing CI after the latest release. It doesn't seem like we're doing anything out of the ordinary:

Failure/Error: DatabaseCleaner.clean_with(:truncation, pre_count: true)
ArgumentError:
  wrong number of arguments (given 1, expected 2)
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-active_record-2.2.1/lib/database_cleaner/active_record/truncation.rb:197:in `truncate_tables'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-active_record-2.2.1/lib/database_cleaner/active_record/truncation.rb:204:in `pre_count_truncate_tables'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-active_record-2.2.1/lib/database_cleaner/active_record/truncation.rb:24:in `block in clean'
# /workdir/vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.5.1/lib/active_record/connection_adapters/postgresql/referential_integrity.rb:19:in `disable_referential_integrity'
# /usr/local/lib/ruby/3.3.0/delegate.rb:87:in `method_missing'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-active_record-2.2.1/lib/database_cleaner/active_record/truncation.rb:22:in `clean'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaner.rb:65:in `clean_with'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:40:in `block in clean_with'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:40:in `each'
# /workdir/vendor/bundle/ruby/3.3.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:40:in `clean_with'
# /usr/local/lib/ruby/3.3.0/forwardable.rb:240:in `clean_with'
# /workdir/spec/support/database_cleaner.rb:6:in `block (2 levels) in <top (required)>'

Seems like maybe some call sites were missed when changing the method signature in this PR?

@etagwerker
Copy link
Member

@mlarraz Thanks for bringing this up! I created #120 to keep track of it.

@etagwerker etagwerker mentioned this pull request May 15, 2025
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.

5 participants