Forum: Ruby on Rails Be careful of BIGINT primary key fields in MySQL. Will cause problems with ActiveRecord create (but

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
chrisf (Guest)
on 2009-03-08 00:28
(Received via mailing list)
The MySQL/Ruby library doesn't properly handle inserts into tables
with the primary key being a BIGINT

If the ID returned to the MySQL/Ruby library is LARGER than the INT
range, the value is returned to Ruby truncated and incorrect. This is
then passed up to ActiveRecord and into the id field of your model.
The actual INSERT worked properly and when do you an ActiveRecord find
for the object, it will have the proper id (assuming you find it via
another method other than the truncated id returned).

http://rubyforge.org/tracker/index.php?func=detail...

Where it gets really messy is if you have associations on the model
you are creating, the ID that is returned to AR is incorrect and it
inserts it into the associated models that get auto-saved.
This topic is locked and can not be replied to.