Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 99860582b2b1c0fc42bf84c52aac57b243d42678 1 parent 09a16ef
@tenderlove tenderlove authored
View
12 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

@rafaelfranca

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

@tenderlove
Owner

@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.

Please sign in to comment.
Something went wrong with that request. Please try again.