zdennis/ar-extensions

Can't do bulk insert

chamnap opened this issue · 3 comments

I'm using rails 2.3.2 with ar-extensions 0.9.2 (MySQL version: 5.0.75-0ubuntu10.3 (Ubuntu))

I'm trying to use the import() method on my AR models, and it works but it still run a single insert query for each record. It's very wired my models call supports_import? always return false.

When I faked that method, it raises an error undefined method 'sql_for_on_duplicate_key_update'.
Can you explain how to insert bulk records?

Thanks

When I used ar-extensions I had to explicitly require the adapter for the database like this:

require 'ar-extensions/adapters/mysql'
require 'ar-extensions/import/mysql'

But since the extension has not been changed for a long time now I don't know if it still works with newer versions of ruby.

Yeah, thanks. It just works in my irb, but not work in my rake task 'uninitialized constant ActiveRecord::ConnectionAdapters::MysqlAdapter'. I wonder how could it be?

Alright, I fixed this by adding: ENV['LOAD_ADAPTER_EXTENSIONS'] = 'mysql' before require those two files.