diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-15 18:03:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-15 18:03:10 -0700 |
commit | 99860582b2b1c0fc42bf84c52aac57b243d42678 (patch) | |
tree | d9fed00367051793f0fd1d7d466a2564eb47bea0 | |
parent | 09a16ef1786f89181b51d5fb2c37fab65fafa976 (diff) | |
download | rails-99860582b2b1c0fc42bf84c52aac57b243d42678.tar.gz rails-99860582b2b1c0fc42bf84c52aac57b243d42678.tar.bz2 rails-99860582b2b1c0fc42bf84c52aac57b243d42678.zip |
tiny types should only be integers when the length is <= 1. fixes #10620
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index f23521430d..1826d88500 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -393,6 +393,14 @@ module ActiveRecord TYPES[new] = TYPES[old] end + def self.find_type(field) + if field.type == Mysql::Field::TYPE_TINY && field.length > 1 + TYPES[Mysql::Field::TYPE_LONG] + else + TYPES.fetch(field.type) { Fields::Identity.new } + end + end + register_type Mysql::Field::TYPE_TINY, Fields::Boolean.new register_type Mysql::Field::TYPE_LONG, Fields::Integer.new alias_type Mysql::Field::TYPE_LONGLONG, Mysql::Field::TYPE_LONG @@ -425,9 +433,7 @@ module ActiveRecord if field.decimals > 0 types[field.name] = Fields::Decimal.new else - types[field.name] = Fields::TYPES.fetch(field.type) { - Fields::Identity.new - } + types[field.name] = Fields.find_type field end } result_set = ActiveRecord::Result.new(types.keys, result.to_a, types) |