Forum: Ruby on Rails integer limit on migration doesn't have any effect?

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.
Be2b66038e24ecc43fb890ab9ce6c635?d=identicon&s=25 Reynard (Guest)
on 2007-03-31 00:29
(Received via mailing list)
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
Dfd6f9989147955682701da8227df8b4?d=identicon&s=25 Michael Wang (Guest)
on 2007-04-01 02:51
(Received via mailing list)
Reynard wrote:
> 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
Be2b66038e24ecc43fb890ab9ce6c635?d=identicon&s=25 Reynard (Guest)
on 2007-04-04 21:17
(Received via mailing list)
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
This topic is locked and can not be replied to.