diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2015-09-19 16:05:34 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2015-09-19 16:05:34 -0700 |
commit | 5837de5360b9a38ca5b07f26b1d03b1ce4763f17 (patch) | |
tree | 03375e471ed6e3568c86a93d963456585c1d2760 /activerecord/lib | |
parent | ac2b312219faf67d08a4fb3fd622ecb4c9bc3623 (diff) | |
parent | 206cf5193808b41c45fd287e5134dffa961a88de (diff) | |
download | rails-5837de5360b9a38ca5b07f26b1d03b1ce4763f17.tar.gz rails-5837de5360b9a38ca5b07f26b1d03b1ce4763f17.tar.bz2 rails-5837de5360b9a38ca5b07f26b1d03b1ce4763f17.zip |
Merge pull request #20645 from kamipo/fix_mysql_set_type_bug
Fix undesired type lookup with `SET` in MySQL
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 7 |
1 files changed, 6 insertions, 1 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 f0004e398e..0564bfaf8e 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -814,7 +814,6 @@ module ActiveRecord register_integer_type m, %r(^tinyint)i, limit: 1 m.alias_type %r(tinyint\(1\))i, 'boolean' if emulate_booleans - m.alias_type %r(set)i, 'varchar' m.alias_type %r(year)i, 'integer' m.alias_type %r(bit)i, 'binary' @@ -823,6 +822,12 @@ module ActiveRecord .split(',').map{|enum| enum.strip.length - 2}.max MysqlString.new(limit: limit) end + + m.register_type(%r(^set)i) do |sql_type| + limit = sql_type[/^set\((.+)\)/i, 1] + .split(',').map{|set| set.strip.length - 1}.sum - 1 + MysqlString.new(limit: limit) + end end def register_integer_type(mapping, key, options) # :nodoc: |