Class: ActiveRecord::ConnectionAdapters::RdbColumn
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::RdbColumn
- Defined in:
- lib/active_record/connection_adapters/rdb_column.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#sub_type ⇒ Object
readonly
Returns the value of attribute sub_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, rdb_options = {}) ⇒ RdbColumn
constructor
A new instance of RdbColumn.
- #limit ⇒ Object
- #precision ⇒ Object
- #scale ⇒ Object
- #sql_type ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, rdb_options = {}) ⇒ RdbColumn
Returns a new instance of RdbColumn.
25 26 27 28 29 30 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 25 def initialize(name, default, = nil, null = true, table_name = nil, = {}) @domain, @sub_type = .values_at(:domain, :sub_type) name = name.dup name.downcase! super(name, parse_default(default), , null, table_name) end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
23 24 25 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 23 def domain @domain end |
#sub_type ⇒ Object (readonly)
Returns the value of attribute sub_type.
23 24 25 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 23 def sub_type @sub_type end |
Class Method Details
.sql_type_for(field) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 5 def sql_type_for(field) sql_type = field[:sql_type] sub_type = field[:sql_subtype] sql_type << case sql_type when /(numeric|decimal)/i "(#{field[:precision]},#{field[:scale].abs})" when /(int|float|double|char|varchar|bigint)/i "(#{field[:length]})" else '' end sql_type << ' sub_type text' if /blob/i.match?(sql_type) && sub_type == 1 sql_type end |
Instance Method Details
#limit ⇒ Object
48 49 50 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 48 def limit @sql_type_metadata[:limit] end |
#precision ⇒ Object
40 41 42 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 40 def precision @sql_type_metadata[:precision] end |
#scale ⇒ Object
44 45 46 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 44 def scale @sql_type_metadata[:scale] end |
#sql_type ⇒ Object
32 33 34 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 32 def sql_type @sql_type_metadata[:sql_type] end |
#type ⇒ Object
36 37 38 |
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 36 def type @sql_type_metadata[:type] end |