Class: ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::Column
- Defined in:
- activerecord/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.
Attributes inherited from Column
#coder, #default, #limit, #name, #null, #precision, #primary, #scale, #sql_type, #type
Instance Method Summary collapse
-
#adapter ⇒ Object
Must return the relevant concrete adapter.
- #case_sensitive? ⇒ Boolean
- #extract_default(default) ⇒ Object
- #has_default? ⇒ Boolean
-
#initialize(name, default, sql_type = nil, null = true, collation = nil) ⇒ Column
constructor
A new instance of Column.
Methods inherited from Column
binary_to_string, #human_name, #klass, #number?, string_to_binary, #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
#initialize(name, default, sql_type = nil, null = true, collation = nil) ⇒ Column
Returns a new instance of Column.
10 11 12 13 |
# File 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 10 def initialize(name, default, sql_type = nil, null = true, collation = nil) super(name, default, sql_type, null) @collation = collation end |
Instance Attribute Details
#collation ⇒ Object (readonly)
Returns the value of attribute collation
8 9 10 |
# File 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 8 def collation @collation end |
Instance Method Details
#adapter ⇒ Object
Must return the relevant concrete adapter
35 36 37 |
# File 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 35 def adapter raise NotImplementedError end |
#case_sensitive? ⇒ Boolean
39 40 41 |
# File 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 39 def case_sensitive? collation && !collation.match(/_ci$/) end |
#extract_default(default) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 15 def extract_default(default) if sql_type =~ /blob/i || 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
29 30 31 32 |
# File 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb', line 29 def has_default? return false if sql_type =~ /blob/i || type == :text #mysql forbids defaults on blob and text columns super end |