Skip to content

Commit

Permalink
tiny types should only be integers when the length is <= 1. fixes #10620
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 16, 2013
1 parent 09a16ef commit 9986058
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

4 comments on commit 9986058

@phinze
Copy link
Contributor

@phinze phinze commented on 9986058 May 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💟

@rafaelfranca
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tenderlove
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rafaelfranca
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.