Hi,
I''m using active record with mysql on windows, to write a data
processing script to take data from text files and insert them into the
DB (standalone, not within rails). When inserting many records into the
DB in quick succession, I sometimes find that the PK is not getting set
in the domain object after inserting a new record in the DB. I find
myself doing this:
addrs.each do |addr|
postcode.name=addr.postcode
postcode.save!
if postcode.id == nil
postcode=Postcode.find_by_name(addr.postcode)
end
address.postcode=postcode
address.line1=addr.line1
etc...
note that the ID sometimes gets set, but sometimes it doesn''t, hence
the
check on the PK immediately after the save. I tried wrapping the call to
save! with a transaction:
Postcode.transaction
postcode.save!
end
but this didn''t seem to help.
Any ideas as to why this is happening? I''m using activerecord 1.14.4
and
MySQL 5.0 in windows.
Thanks,
Elie
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---