diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-10-29 09:37:01 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-10-29 09:43:56 +0100 |
commit | 82ce157844f38ac144e2185786f8875df07a7a37 (patch) | |
tree | 17787a102cfde0c257811704c84b07f85ef29309 /activerecord/lib/active_record | |
parent | e595d91ac2c07371b441f8b04781e7c03ac44135 (diff) | |
download | rails-82ce157844f38ac144e2185786f8875df07a7a37.tar.gz rails-82ce157844f38ac144e2185786f8875df07a7a37.tar.bz2 rails-82ce157844f38ac144e2185786f8875df07a7a37.zip |
fix MySQL enum type lookup with values matching another type. Closes #17402.
The MySQLAdapter type map used the lowest priority for enum types.
This was the result of a recent refactoring and lead to some broken lookups
for enums with values that match other types. Like `8bit`.
This patch restores the priority to what we had before the refactoring.
/cc @sgrif
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index c5dd93ee89..9077a9cfe3 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -656,12 +656,6 @@ module ActiveRecord def initialize_type_map(m) # :nodoc: super - m.register_type(%r(enum)i) do |sql_type| - limit = sql_type[/^enum\((.+)\)/i, 1] - .split(',').map{|enum| enum.strip.length - 2}.max - Type::String.new(limit: limit) - end - m.register_type %r(tinytext)i, Type::Text.new(limit: 2**8 - 1) m.register_type %r(tinyblob)i, Type::Binary.new(limit: 2**8 - 1) m.register_type %r(text)i, Type::Text.new(limit: 2**16 - 1) @@ -682,6 +676,12 @@ module ActiveRecord m.alias_type %r(set)i, 'varchar' m.alias_type %r(year)i, 'integer' m.alias_type %r(bit)i, 'binary' + + m.register_type(%r(enum)i) do |sql_type| + limit = sql_type[/^enum\((.+)\)/i, 1] + .split(',').map{|enum| enum.strip.length - 2}.max + Type::String.new(limit: limit) + end end # MySQL is too stupid to create a temporary table for use subquery, so we have |