Flowdock
method

initialize_type_map

Importance_0
v4.2.9 - Show latest stable - 0 notes - Class: AbstractMysqlAdapter
initialize_type_map(m) protected

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 684
      def initialize_type_map(m) # :nodoc:
        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.alias_type %(tinyint\(1\)),  'boolean' if emulate_booleans
        m.alias_type %(set),           'varchar'
        m.alias_type %(year),          'integer'
        m.alias_type %(bit),           'binary'

        m.register_type(%(datetime)) do |sql_type|
          precision = extract_precision(sql_type)
          MysqlDateTime.new(precision: precision)
        end

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