As I could not get a definite answer at lighthouse (http://rails.lighthouseapp.com/projects/8994/tickets/432-mysql-adapter-with-mediumt-support), whether my assumption about rails' incorrect handling of mysql integer data types was right or not, I now turn to this mailing list.
About a month ago I wrote a patch posted here:
A couple of weeks later Jeremy Kemper commited this:
However, I'm personally not sure he has done everything correct.
Example (taken from Jeremy's commit):
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
For instance, doesn't this mean that rails will choose mediumint as data type for storing integers with a length of 3? That should be smallint! Smallint holds (if signed) -32768 to 32767 so it would easy hold an integer with length of 3 and even 4. Using mediumint here just wastes disk space and increase mysql memory consumption without any reason.
As I understand rails and mysql data types, it should rather be something like (as I've written in my patch):
when 0..2; 'tinyint'
when 2..4; 'smallint'
when 5..6; 'mediumint'
when 7..9; 'int'
when 9..20; 'bigint'
Or am I missing something here? If I am - sorry for my newbie-ism, this is my first time trying to contribute to open source.