Permalink
Browse files

tiny types should only be integers when the length is <= 1. fixes #10620

  • Loading branch information...
1 parent 09a16ef commit 99860582b2b1c0fc42bf84c52aac57b243d42678 @tenderlove tenderlove committed May 16, 2013
Showing with 9 additions and 3 deletions.
  1. +9 โˆ’3 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -393,6 +393,14 @@ def self.alias_type(new, old)
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 @@ def exec_without_stmt(sql, name = 'SQL') # :nodoc:
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)

4 comments on commit 9986058

Contributor

phinze replied May 16, 2013

๐Ÿ’Ÿ

Owner

rafaelfranca replied May 16, 2013

@tenderlove should this be backported to 4-0-stable and 4-0-0? Also it is missing a CHANGELOG entry

Owner

tenderlove replied May 16, 2013

@rafaelfranca it's not a regression from 3.2. I think we should backport this to 4-0-stable, but not 4-0-0. I'd rather we only put critical fixes in 4-0-0.

Owner

rafaelfranca replied May 16, 2013

๐Ÿ‘

Please sign in to comment.