This project is archived and is in readonly mode.
TableDefinition.column ignores :limit for integer types
-
Carlos Paramio
I realized that this fails because there isn't any integer type on MySQL with a size of 20 bytes:
ActiveRecord::Base.connection.type_to_sql(:integer, 20) ActiveRecord::ActiveRecordError: No integer type has byte size 20
Please close this ticket.
-
CancelProfileIsBroken
- Tag changed from 2.2.2, activerecord, limit, schema to 2.2.2, activerecord, bugmash, limit, schema
-
Rajesh
+1 for closing this ticket
ActiveRecord::Base.connection.type_to_sql(:integer, 20)
ActiveRecord::ActiveRecordError: No integer type has byte size 20from /Users/rajesh/src/property/trunk/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:535:in `type_to_sql'but following work fine
ActiveRecord::Base.connection.type_to_sql(:integer, 4) => "int(11)" ActiveRecord::Base.connection.type_to_sql(:integer, 8) => "bigint"
-
Hugo Peixoto
In mysql, I'm able to create a table with int(20):
mysql> create table test(id int(20)); mysql> show columns from test; +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id | int(20) | YES | | NULL | | +-------+---------+------+-----+---------+-------+If I insert large values (like 9999999999999999999) they won't be saved.
mysql> insert into test VALUES (9999999999999999999); mysql> select id from test; +------------+ | id | +------------+ | 2147483647 | +------------+ 1 row in set (0.00 sec)int(20) only does something if you use it in conjunction with ZEROFILL,
in which the mysql interactive tools will print out something like this:mysql> drop table test; mysql> create table test(id int(20) zerofill); mysql> insert into test VALUES (9999999999999999999); mysql> select id from test; +----------------------+ | id | +----------------------+ | 00000000004294967295 | +----------------------+Odd behaviour, but since it doesn't change the storage size, I'd say it's irrelevant for rails purpose. I say +1 for closing this ticket.
-
CancelProfileIsBroken
- Tag changed from 2.2.2, activerecord, bugmash, limit, schema to 2.2.2, activerecord, limit, schema
- State changed from new to invalid
Not worth changing Rails core unless we see some use case and patch that isn't mysql-specific.