public this repo is viewable by everyone
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added that the MySQL adapter should map integer to either smallint, int, 
or bigint depending on the :limit just like PostgreSQL [DHH]
David Heinemeier Hansson (author)
20 days ago
commit  a37546517dad9f6d9a7de6e1dba4d960909d71e8
tree    a96de198754909ac7fb131e4eee49adf6189b2d3
parent  1959db324653d5db345b935c9d2696c544d836af
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Added that the MySQL adapter should map integer to either smallint, int, or bigint depending on the :limit just like PostgreSQL [DHH]
0
+
0
 * Change validates_uniqueness_of :case_sensitive option default back to true (from [9160]). Love your database columns, don't LOWER them. [rick]
0
 
0
 * Add support for interleaving migrations by storing which migrations have run in the new schema_migrations table. Closes #11493 [jordi]
...
463
464
465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
467
468
...
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
0
@@ -463,6 +463,22 @@ module ActiveRecord
0
         execute "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(new_column_name)} #{current_type}"
0
       end
0
 
0
+ # Maps logical Rails types to MySQL-specific data types.
0
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil)
0
+ return super unless type.to_s == 'integer'
0
+
0
+ case limit
0
+ when 0..3
0
+ "smallint(#{limit})"
0
+ when 4..8
0
+ "int(#{limit})"
0
+ when 9..20
0
+ "bigint(#{limit})"
0
+ else
0
+ 'int(11)'
0
+ end
0
+ end
0
+
0
 
0
       # SHOW VARIABLES LIKE 'name'
0
       def show_variable(name)

Comments

  • matthuhiggins 19 days ago

    I would replace:
    :integer => { :name => "int"}, :limit => 11 },
    with:
    :integer => { :name => "int"},
    Otherwise, the default case of ‘int(11)’ is never executed.