database_cleaner-active_record icon indicating copy to clipboard operation
database_cleaner-active_record copied to clipboard

Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing.

Results 55 database_cleaner-active_record issues
Sort by recently updated
recently updated
newest added

It's sometimes necessary to add `pg_catalog` explicitly to the search path (if you don't want it added implicitly at the beginning of the search path). It then gets picked up...

Hi, I can find on `README.md` that we can use some options ```ruby DatabaseCleaner[:active_record].strategy = :truncation, only: ["users"] ``` This syntax is not ruby valid. How do you specify options...

I created a script to demonstrate this behavior: ``` #!/usr/bin/env ruby begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your bundler"...

DatabaseCleaner treats CockroachDB as PostgreSQL (which makes sense because CockroachDB emulated PostgreSQL to some extent). It uses the `RESTART IDENTITY` clause in the `TRUNCATE TABLE` query, which isn't supported by...

We have an application that needs to support multiple database engines, so our `Gemfile` contains multiple JDBC adapters as so: ``` gem 'activerecord-jdbcpostgresql-adapter', '~>1.3.7' gem 'activerecord-jdbcmssql-adapter', '~>1.3.7' gem 'activerecord-jdbcmysql-adapter', '~>1.3.7'...

AR has adapters for a lot more than Sqlite, MySQL, and PostgreSQL. Can we test our code that works against those, too? What does the AR repo do about this?

I have a method like this: ``` def make_foo(bar, params) foo = nil self.transaction do foo = self.create!(name: bar) rescue nil end unless foo self.transaction do foo = Something.find_by(name: bar).update(params)...

When _both_ MySQL and Postgres ActiveRecord models are used, and when testing MySQL-backed code, Truncation strategy includes _BOTH_ ::DatabaseCleaner::ActiveRecord::MysqlAdapter and ::DatabaseCleaner::ActiveRecord::PostgreSQLAdapter into ::DatabaseCleaner::ActiveRecord::AbstractAdapter, which, in turn, gets included into ActiveRecord::AbstractAdapter....

For large databases, this is _way_ faster than disabling/enabling all the triggers. `set session_replication_role='replica';`

If there is more than one connection in the connection pool DatabaseCleaner will only begin the transaction on one of the connections. https://github.com/rails/rails/blob/master/activerecord/lib/active_record/fixtures.rb#L979 Any ActiveRecord call afterwards will use the...