Class: ActiveRecord::ConnectionAdapters::MysqlColumn
- Defined in:
- lib/connection_adapters/mysql_adapter.rb
Overview
:nodoc:
Constant Summary collapse
- @@auto_increment =
"auto_increment"
Instance Attribute Summary collapse
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
Instance Method Summary collapse
-
#base_initialize ⇒ Object
Capture the value of the “EXTRA” column in the column metadata table.
-
#default_specified? ⇒ Boolean
Until MySQL properly handles default values, I assume that a default value of NULL or empty string means that a default value has not been specified for the column.
- #generated? ⇒ Boolean
-
#initialize(name, default, sql_type = nil, null = true, extra = nil) ⇒ MysqlColumn
constructor
A new instance of MysqlColumn.
Constructor Details
#initialize(name, default, sql_type = nil, null = true, extra = nil) ⇒ MysqlColumn
Returns a new instance of MysqlColumn.
13 14 15 16 |
# File 'lib/connection_adapters/mysql_adapter.rb', line 13 def initialize(name, default, sql_type = nil, null = true, extra = nil) base_initialize(name, default, sql_type, null) @extra = extra end |
Instance Attribute Details
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
6 7 8 |
# File 'lib/connection_adapters/mysql_adapter.rb', line 6 def extra @extra end |
Instance Method Details
#base_initialize ⇒ Object
Capture the value of the “EXTRA” column in the column metadata table. This can be used to generate validations
12 |
# File 'lib/connection_adapters/mysql_adapter.rb', line 12 alias :base_initialize :initialize |
#default_specified? ⇒ Boolean
Until MySQL properly handles default values, I assume that a default value of NULL or empty string means that a default value has not been specified for the column.
We really only care about this when the column is NOT NULL, in which case it should be safe to assume that no one would define the column as NOT NULL and then explicitly set the empty string as the default value. …Right?
28 29 30 |
# File 'lib/connection_adapters/mysql_adapter.rb', line 28 def default_specified? !(default.nil? || default.blank?) end |
#generated? ⇒ Boolean
18 19 20 |
# File 'lib/connection_adapters/mysql_adapter.rb', line 18 def generated? @extra == @@auto_increment end |