Class: ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column
- Defined in:
- lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Column
Column::FALSE_VALUES, Column::TRUE_VALUES
Instance Attribute Summary collapse
-
#collation ⇒ Object
readonly
Returns the value of attribute collation.
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#strict ⇒ Object
readonly
Returns the value of attribute strict.
Attributes inherited from Column
#cast_type, #default, #default_function, #name, #null, #sql_type
Instance Method Summary collapse
- #==(other) ⇒ Object
- #blob_or_text_column? ⇒ Boolean
- #case_sensitive? ⇒ Boolean
- #extract_default ⇒ Object
- #has_default? ⇒ Boolean
-
#initialize(name, default, cast_type, sql_type = nil, null = true, collation = nil, strict = false, extra = "") ⇒ Column
constructor
A new instance of Column.
Methods inherited from Column
#hash, #human_name, #with_type
Constructor Details
#initialize(name, default, cast_type, sql_type = nil, null = true, collation = nil, strict = false, extra = "") ⇒ Column
Returns a new instance of Column.
64 65 66 67 68 69 70 71 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 64 def initialize(name, default, cast_type, sql_type = nil, null = true, collation = nil, strict = false, extra = "") @strict = strict @collation = collation @extra = extra super(name, default, cast_type, sql_type, null) assert_valid_default(default) extract_default end |
Instance Attribute Details
#collation ⇒ Object (readonly)
Returns the value of attribute collation.
62 63 64 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 62 def collation @collation end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
62 63 64 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 62 def extra @extra end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
62 63 64 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 62 def strict @strict end |
Instance Method Details
#==(other) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 94 def ==(other) super && collation == other.collation && strict == other.strict && extra == other.extra end |
#blob_or_text_column? ⇒ Boolean
86 87 88 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 86 def blob_or_text_column? sql_type =~ /blob/i || type == :text end |
#case_sensitive? ⇒ Boolean
90 91 92 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 90 def case_sensitive? collation && !collation.match(/_ci$/) end |
#extract_default ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 73 def extract_default if blob_or_text_column? @default = null || strict ? nil : '' elsif missing_default_forged_as_empty_string?(@default) @default = nil end end |
#has_default? ⇒ Boolean
81 82 83 84 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 81 def has_default? return false if blob_or_text_column? # MySQL forbids defaults on blob and text columns super end |