Class: ActiveRecord::ConnectionAdapters::ColumnDefinition
- Defined in:
- activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
Overview
Abstract representation of a column definition. Instances of this type are typically created by methods in TableDefinition, and added to the columns
attribute of said TableDefinition object, in order to be used for generating a number of table creation or table changing SQL statements.
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#default ⇒ Object
Returns the value of attribute default.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#name ⇒ Object
Returns the value of attribute name.
-
#null ⇒ Object
Returns the value of attribute null.
-
#precision ⇒ Object
Returns the value of attribute precision.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Methods inherited from Struct
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def base @base end |
#default ⇒ Object
Returns the value of attribute default
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def default @default end |
#limit ⇒ Object
Returns the value of attribute limit
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def limit @limit end |
#name ⇒ Object
Returns the value of attribute name
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def name @name end |
#null ⇒ Object
Returns the value of attribute null
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def null @null end |
#precision ⇒ Object
Returns the value of attribute precision
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def precision @precision end |
#scale ⇒ Object
Returns the value of attribute scale
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def scale @scale end |
#type ⇒ Object
Returns the value of attribute type
16 17 18 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 16 def type @type end |
Instance Method Details
#sql_type ⇒ Object
22 23 24 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 22 def sql_type base.type_to_sql(type.to_sym, limit, precision, scale) rescue type end |
#string_to_binary(value) ⇒ Object
18 19 20 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 18 def string_to_binary(value) value end |
#to_sql ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 26 def to_sql column_sql = "#{base.quote_column_name(name)} #{sql_type}" = {} [:null] = null unless null.nil? [:default] = default unless default.nil? (column_sql, ) unless type.to_sym == :primary_key column_sql end |