#27 new
Jonas Grimfelt

Fail to import record with explicit record ID

Reported by Jonas Grimfelt | July 6th, 2009 @ 10:38 AM

Example:

attributes = [:id, :name, :classification, :parent_id]
values = [[1,"guppy", "fish", 1], [2, "goldfish", "fish", 1], [3, "parrot fish", "fish", 1]]
Animals.import attributes, values

Problems/Oddities:

  • For one value the record gets inserted with a random ID (generated where?)
  • For multiple values only the first one gets inserted - with incorrect ID

Note: Tested both Sqlite and Postgres

Comments and changes to this ticket

  • Jonas Grimfelt

    Jonas Grimfelt July 6th, 2009 @ 01:03 PM

    Ignore this, it's an Rails ActiveRecord issue...a bit stupid convention not being able to save ID without before_filters. =/

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

ActiveRecord::Extension (aka ar-extensions) is a plugin to extend and
enhance the functionality of ActiveRecord. It starts by adding better
find support for ActiveRecord. It then adds mass data import
capabilities which are highly efficient and lastly it supports to_csv
functionality.

It also introduces a cool concept of creating easily extendable pieces
of ActiveRecord functionality, so developers don't have to understand
ActiveRecord internals or have the fear of breaking ActiveRecord
itself.

People watching this ticket

Pages