aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@envy8.local>2008-04-25 16:33:00 -0500
committerDavid Heinemeier Hansson <david@envy8.local>2008-04-25 16:33:00 -0500
commita37546517dad9f6d9a7de6e1dba4d960909d71e8 (patch)
treea96de198754909ac7fb131e4eee49adf6189b2d3 /activerecord/lib
parent1959db324653d5db345b935c9d2696c544d836af (diff)
downloadrails-a37546517dad9f6d9a7de6e1dba4d960909d71e8.tar.gz
rails-a37546517dad9f6d9a7de6e1dba4d960909d71e8.tar.bz2
rails-a37546517dad9f6d9a7de6e1dba4d960909d71e8.zip
Added that the MySQL adapter should map integer to either smallint, int, or bigint depending on the :limit just like PostgreSQL [DHH]
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/mysql_adapter.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index 6432c3cfee..2cc4157d16 100755
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -463,6 +463,22 @@ module ActiveRecord
execute "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(new_column_name)} #{current_type}"
end
+ # Maps logical Rails types to MySQL-specific data types.
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil)
+ return super unless type.to_s == 'integer'
+
+ case limit
+ when 0..3
+ "smallint(#{limit})"
+ when 4..8
+ "int(#{limit})"
+ when 9..20
+ "bigint(#{limit})"
+ else
+ 'int(11)'
+ end
+ end
+
# SHOW VARIABLES LIKE 'name'
def show_variable(name)