Hi, I am working on a project for which I have to store unsigned integer values up to 2^64 - 1. Even bigger values would be valuable but 2^64-1 is the minimum required.
My Rails project uses a MySQL database. And guess what ? It supports unsigned bigint data type whose maximum value is 2^64 - 1. Sounds good, except that Rails migration doesn't handle unsigned integer datatypes very well. After some googling, I came up with a solution to this issue: t.column :value, 'bigint unsigned' Fine. Both my test and development databases are now ready to store values from 0 to 2^64 - 1. Really ? Yes they are. Manual SQL requests proved it. Back to Rails writing a unit test to check that one of my calculation method returns the expected result. This result is part of my fixtures and is defined as follows: dummy_object_in_fixture: id: 1 value: <%= 2**64 - 1 %> And here comes the trouble : my model's function returns the expected value (2^64 - 1) but the test fails nevertheless since the value stored in my test database is 9223372036854775807 (which equals 2^63 - 1, i.e. the max value for a signed bigint) instead of 18446744073709551615 (which equals 2^64 - 1, i.e. the max value for an unsigned bigint) which I actually typed in in my fixtures. Back to MySQL Query Browser to check my database and it appears that running my tests changed my column datatype from unsigned bigint to signed bigint !? Has anyone ever heard of such a behaviour ? What is it due to and how could I finally use unsigned bigint in my app and its tests ? I tried to persist values as big as 2^64 - 1 through the "ruby script/ console" utility on my development database and it works as a charm. Which is good news but confuses me even more... Thanks for your help --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

