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::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



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

def extract_default(default)
  if type == :binary || 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)


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

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