Class: ActiveRecord::ConnectionAdapters::Column

Class | ActiveRecord::ConnectionAdapters::Column
In: | lib/active_record/connection_adapters/abstract/schema_definitions.rb
Parent: | Object

An abstract definition of a column in a table.

### Methods

binary_to_string extract_default fallback_string_to_date fallback_string_to_time fast_string_to_date fast_string_to_time human_name klass microseconds new new_date new_time number? 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

### Classes and Modules

Module ActiveRecord::ConnectionAdapters::Column::Format

### Attributes

default | [R] |
limit | [R] |
name | [R] |
null | [R] |
precision | [R] |
primary | [RW] |
scale | [R] |
sql_type | [R] |
type | [R] |

### Public Class methods

binary_to_string(value)

Used to convert from BLOBs to Strings

new(name, default, sql_type = nil, null = true)

Instantiates a new column in the table.

`name` is the column‘s name, as in `supplier_id` int(11). `default` is the type-casted default value, such as `sales_stage varchar(20) default ‘new‘`. `sql_type` is only used to extract the column‘s length, if necessary. For example, `company_name varchar(60)`. `null` determines if this column allows `NULL` values.

string_to_binary(value)

Used to convert from Strings to BLOBs

string_to_date(string)
string_to_dummy_time(string)
string_to_time(string)
value_to_boolean(value)

convert something to a boolean

value_to_decimal(value)

convert something to a BigDecimal

### Protected Class methods

fallback_string_to_date(string)
fallback_string_to_time(string)
fast_string_to_date(string)
fast_string_to_time(string)

Doesn‘t handle time zones.

microseconds(time)

‘0.123456’ -> 123456 ‘1.123456’ -> 123456

new_date(year, mon, mday)
new_time(year, mon, mday, hour, min, sec, microsec)

### Public Instance methods

extract_default(default)
human_name()

Returns the human name of the column name.

##### Examples

     Column.new('sales_stage', ...).human_name #=> 'Sales stage'

klass()

Returns the Ruby class that corresponds to the abstract data type.

number?()
text?()
type_cast(value)

Casts value (which is a String) to an appropriate instance.

type_cast_code(var_name)

[Validate]