Class: ActiveRecord::ConnectionAdapters::MysqlColumn

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

Overview

:nodoc:

Constant Summary

Constants inherited from Column

Column::FALSE_VALUES, Column::TRUE_VALUES

Instance Attribute Summary

Attributes inherited from Column

#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_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



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/active_record/connection_adapters/mysql_adapter.rb', line 81

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)


95
96
97
98
# File 'lib/active_record/connection_adapters/mysql_adapter.rb', line 95

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