Quoting Foon <[email protected]>:
> 
> 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.
>

In creating the test DB, the unsigned is lost.  Rails doesn't support
unsigned.

> 
> 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...
> 

Again, the development DB is 'bigint unsigned', the test DB is 'bigint'
(defaulting to signed).  Try your console example again with:

Ruby script/console test

How to fix it in a Rails way fashion?  I don't know, I simply switched from 64
bit hash codes to 63 bit ones.  The doubling of collision frequency is not a
problem.  If you really have to have 64 unsigned integers, store them in a
string column type and convert.

Jeffrey

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to