Class: ActiveRecord::ConnectionAdapters::MySQL::Column

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Column

#collation, #comment, #default, #default_function, #name, #null, #sql_type_metadata, #table_name

Instance Method Summary collapse

Methods inherited from Column

#==, #bigint?, #hash, #human_name

Constructor Details

#initializeColumn

Returns a new instance of Column.


7
8
9
10
11
# File 'activerecord/lib/active_record/connection_adapters/mysql/column.rb', line 7

def initialize(*)
  super
  assert_valid_default
  extract_default
end

Instance Method Details

#auto_increment?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'activerecord/lib/active_record/connection_adapters/mysql/column.rb', line 30

def auto_increment?
  extra == 'auto_increment'
end

#blob_or_text_column?Boolean

Returns:

  • (Boolean)

18
19
20
# File 'activerecord/lib/active_record/connection_adapters/mysql/column.rb', line 18

def blob_or_text_column?
  /\A(?:tiny|medium|long)?blob\b/ === sql_type || type == :text
end

#case_sensitive?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'activerecord/lib/active_record/connection_adapters/mysql/column.rb', line 26

def case_sensitive?
  collation && collation !~ /_ci\z/
end

#has_default?Boolean

Returns:

  • (Boolean)

13
14
15
16
# File 'activerecord/lib/active_record/connection_adapters/mysql/column.rb', line 13

def has_default?
  return false if blob_or_text_column? # MySQL forbids defaults on blob and text columns
  super
end

#unsigned?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'activerecord/lib/active_record/connection_adapters/mysql/column.rb', line 22

def unsigned?
  /\A(?:enum|set)\b/ !~ sql_type && /\bunsigned\b/ === sql_type
end