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.
70 71 72 73 74 75 76 77 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 70 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.
68 69 70 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 68 def collation @collation end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
68 69 70 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 68 def extra @extra end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
68 69 70 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 68 def strict @strict end |
Instance Method Details
#==(other) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 100 def ==(other) super && collation == other.collation && strict == other.strict && extra == other.extra end |
#blob_or_text_column? ⇒ Boolean
92 93 94 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 92 def blob_or_text_column? sql_type =~ /blob/i || type == :text end |
#case_sensitive? ⇒ Boolean
96 97 98 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 96 def case_sensitive? collation && !collation.match(/_ci$/) end |
#extract_default ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 79 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
87 88 89 90 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 87 def has_default? return false if blob_or_text_column? # MySQL forbids defaults on blob and text columns super end |