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:
Direct Known Subclasses
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
#coder, #default, #default_function, #limit, #name, #null, #precision, #primary, #scale, #sql_type, #type
Instance Method Summary collapse
-
#adapter ⇒ Object
Must return the relevant concrete adapter.
- #blob_or_text_column? ⇒ Boolean
- #case_sensitive? ⇒ Boolean
- #extract_default(default) ⇒ Object
- #has_default? ⇒ Boolean
-
#initialize(name, default, sql_type = nil, null = true, collation = nil, strict = false, extra = "") ⇒ Column
constructor
A new instance of Column.
Methods inherited from Column
#binary?, binary_to_string, #human_name, #klass, #number?, #string_to_binary, string_to_binary, string_to_dummy_time, string_to_time, #text?, #type_cast, #type_cast_code, #type_cast_for_write, value_to_boolean, value_to_date, value_to_decimal, value_to_integer
Constructor Details
#initialize(name, default, sql_type = nil, null = true, collation = nil, strict = false, extra = "") ⇒ Column
Returns a new instance of Column.
30 31 32 33 34 35 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 30 def initialize(name, default, sql_type = nil, null = true, collation = nil, strict = false, extra = "") @strict = strict @collation = collation @extra = extra super(name, default, sql_type, null) end |
Instance Attribute Details
#collation ⇒ Object (readonly)
Returns the value of attribute collation.
28 29 30 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 28 def collation @collation end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
28 29 30 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 28 def extra @extra end |
#strict ⇒ Object (readonly)
Returns the value of attribute strict.
28 29 30 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 28 def strict @strict end |
Instance Method Details
#adapter ⇒ Object
Must return the relevant concrete adapter
61 62 63 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 61 def adapter raise NotImplementedError end |
#blob_or_text_column? ⇒ Boolean
56 57 58 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 56 def blob_or_text_column? sql_type =~ /blob/i || type == :text end |
#case_sensitive? ⇒ Boolean
65 66 67 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 65 def case_sensitive? collation && !collation.match(/_ci$/) end |
#extract_default(default) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 37 def extract_default(default) if blob_or_text_column? if default.blank? null || strict ? 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
51 52 53 54 |
# File 'lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 51 def has_default? return false if blob_or_text_column? #mysql forbids defaults on blob and text columns super end |