I have this code on migration file t.column :some_integer, :integer, :limit => 4 t.column :other_integer, :integer, :limit => 8 on mysql, I checked the datatype: some_integer INT(4) other_integer INT(8) but when I tried to enter a really big number to both fields (5 billion which is bigger than INT(4) ) both got truncated to 2147483647 which is the max for INT(4), and it''s the same when I use :limit=>2 or :limit => 1 is this mysql issue? I''m using mysql 4.1 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Wang
2007-Apr-01 00:50 UTC
Re: integer limit on migration doesn''t have any effect?
Reynard wrote:> > I have this code on migration file > > t.column :some_integer, :integer, :limit => 4 > t.column :other_integer, :integer, :limit => 8 > > on mysql, I checked the datatype: > some_integer INT(4) > other_integer INT(8) > > but when I tried to enter a really big number to both fields (5 > billion which is bigger than INT(4) ) > both got truncated to 2147483647 which is the max for INT(4), and it''s > the same when I use :limit=>2 or :limit => 1 > > is this mysql issue? I''m using mysql 4.1If you insert some values directly in MySQL do you have the same problem? -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes it seems like mysql considers INT(n) the same as INTEGER (at least on version 4.1 on mybox) try doing this from mysql console create table test (num INT(2)); it will create num as INTEGER not tinyint or smallint if you want to specifically use smallint, tinyint, or bigint you just have to specify t.column :big_integer, :bigint t.column :small_integer, :smallint t.column :tiny_integer, :tinyint so the :limit option is useless on mysql, is this correct? - reynard On Mar 31, 8:50 pm, Michael Wang <rails-u...-JtyympAsP2K7zZZRDBGcUA@public.gmane.org> wrote:> Reynard wrote: > > > I have this code onmigrationfile > > > t.column :some_integer, :integer, :limit=> 4 > > t.column :other_integer, :integer, :limit=> 8 > > > on mysql, I checked the datatype: > > some_integer INT(4) > > other_integer INT(8) > > > but when I tried to enter a really big number to both fields (5 > > billion which is bigger than INT(4) ) > > both got truncated to 2147483647 which is the max for INT(4), and it''s > > the same when I use :limit=>2 or :limit=> 1 > > > is this mysql issue? I''m using mysql 4.1 > > If you insert some values directly in MySQL do you have the same problem? > > -- > Michael Wang--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---