Class: ActiveRecord::ConnectionAdapters::Mysql2Column

Inherits:
Column
  • Object
show all
Defined in:
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb

Constant Summary collapse

BOOL =
"tinyint(1)"

Constants inherited from Column

Column::FALSE_VALUES, Column::TRUE_VALUES

Instance Attribute Summary

Attributes inherited from Column

#coder, #default, #limit, #name, #null, #precision, #primary, #scale, #sql_type, #type

Instance Method Summary collapse

Methods inherited from Column

binary_to_string, #human_name, #initialize, #klass, #number?, string_to_binary, #string_to_binary, string_to_date, string_to_dummy_time, string_to_time, #text?, #type_cast, #type_cast_code, value_to_boolean, value_to_decimal

Constructor Details

This class inherits a constructor from ActiveRecord::ConnectionAdapters::Column

Instance Method Details

#extract_default(default) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb', line 28

def extract_default(default)
  if sql_type =~ /blob/i || type == :text
    if default.blank?
      return null ? nil : ''
    else
      raise ArgumentError, "#{type} columns cannot have a default value: #{default.inspect}"
    end
  elsif missing_default_forged_as_empty_string?(default)
    nil
  else
    super
  end
end

#has_default?Boolean

Returns:

  • (Boolean)


42
43
44
45
# File 'activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb', line 42

def has_default?
  return false if sql_type =~ /blob/i || type == :text #mysql forbids defaults on blob and text columns
  super
end