Flowdock
method

initialize_type_map

Importance_0
v6.0.0 - Show latest stable - 0 notes - Class: AbstractMysqlAdapter
initialize_type_map(m = type_map) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 526
        def initialize_type_map(m = type_map)
          super

          register_class_with_limit m, %(char), MysqlString

          m.register_type %(tinytext),   Type::Text.new(limit: 2**8 - 1)
          m.register_type %(tinyblob),   Type::Binary.new(limit: 2**8 - 1)
          m.register_type %(text),       Type::Text.new(limit: 2**16 - 1)
          m.register_type %(blob),       Type::Binary.new(limit: 2**16 - 1)
          m.register_type %(mediumtext), Type::Text.new(limit: 2**24 - 1)
          m.register_type %(mediumblob), Type::Binary.new(limit: 2**24 - 1)
          m.register_type %(longtext),   Type::Text.new(limit: 2**32 - 1)
          m.register_type %(longblob),   Type::Binary.new(limit: 2**32 - 1)
          m.register_type %(^float),     Type::Float.new(limit: 24)
          m.register_type %(^double),    Type::Float.new(limit: 53)

          register_integer_type m, %(^bigint),    limit: 8
          register_integer_type m, %(^int),       limit: 4
          register_integer_type m, %(^mediumint), limit: 3
          register_integer_type m, %(^smallint),  limit: 2
          register_integer_type m, %(^tinyint),   limit: 1

          m.register_type %(^tinyint\(1\)), Type::Boolean.new if emulate_booleans
          m.alias_type %(year),          "integer"
          m.alias_type %(bit),           "binary"

          m.register_type(%(enum)) do |sql_type|
            limit = sql_type[/^enum\s*\((.+)\)/, 1]
              .split(",").map { |enum| enum.strip.length - 2 }.max
            MysqlString.new(limit: limit)
          end

          m.register_type(%(^set)) do |sql_type|
            limit = sql_type[/^set\s*\((.+)\)/, 1]
              .split(",").map { |set| set.strip.length - 1 }.sum - 1
            MysqlString.new(limit: limit)
          end
        end
Register or log in to add new notes.