-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael Koziarski wrote: > On 7/17/06, James Adam <[EMAIL PROTECTED]> wrote: > >> Since the behaviour is different from that of create (i.e. no object >> instances are returned), why not just define a new method which >> clearly indicates it's aptitude for inserting large amounts of data? >> Model.import(hashes) or something... > > > The behaviour is *significantly* different from create as no > validations are performed. I'd second the opinion that this isn't > really a 'create' scenario, it's much more of an import.
Yeah I agree with you and James on this. It does seem much more of an import. I will rename the method that uses my functionality. I also agree with returning the records that don't validate (when validation is performed). > > I'm still not convinced that a workaround like this is the right way > to solve these 'bulk load' / ETL scenarios. Why not use your > database's import tools or some really lightweight SQL wrappers? I don't think people should have to shell out to run mysqlimport or run a cronjob to process generated SQL files, just to load 1000 records or more in an efficient manner. And I am trying to use lightweight SQL wrappers by adding this functionality to AR. It is a very real requirement that users want to upload data feeds, whether CSV, tab-based or something else entirely. I prefer writing my whole system using AR. I use Rails for the frontend, and then I use other ruby programs for mass (>100,000 records) of data processing at a time. To me it is simple, elegant and just as efficient by running code like: stats = MyModel.insert array_of_hashes, :on_duplicate_key_update=> [:project_number, :description, :est_due_date ] Rather then writing code like: sql = generate_sql_for_projects( array_of_hashes ) File.open( "projects.sql", "w" ) `mysqlimport -fields a b c -etc.... projects.sql` Keeping things simple keeps it flexible for maintenance and customer requests. AR is so well thought out and designed, this seems like a core feature that is just simply missing. Thoughts? Zach -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEu8GfMyx0fW1d8G0RAhC0AJ9baTQQisI7l/4F3JfSRz+B7F2hoACdEc+p Pwgc4x36zYl7FsvcBOZ+SZA= =cMO9 -----END PGP SIGNATURE----- _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core