amatsuda / database_rewinder

minimalist's tiny and ultra-fast database cleaner
MIT License
806 stars 92 forks source link

Support activerecord-import gem #37

Open teohm opened 8 years ago

teohm commented 8 years ago

Hi, any plan to support activerecord-import gem?

We use activerecord-import in production code, and use DatabaseRewinder.clean in our tests.

When we run tests on activerecord-import related codes to perform bulk inserts, DatabaseRewinder#record_inserted_table is not being called at all.

Do you think it's possible to track bulk INSERT SQL statement executed by activerecord-import gem? I'm happy to submit a PR but I need some guides to figure out which part needs to be changed 🙇

naari3 commented 4 years ago

if you are using Rails (< 5.0) and Postgres, updating to Rails 5.1 will make DatabaseRewinder#record_inserted_table work properly.

because Rails 5.1 select_rows and select_values now call exec_query that overrided from here ( https://github.com/amatsuda/database_rewinder/blob/master/lib/database_rewinder/active_record_monkey.rb )