Class: ActiveRecord::ConnectionAdapters::ColumnDefinition
- Inherits:
-
Struct
- Object
- Struct
- ActiveRecord::ConnectionAdapters::ColumnDefinition
- Defined in:
- 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
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def base @base end |
#default ⇒ Object
Returns the value of attribute default
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def default @default end |
#limit ⇒ Object
Returns the value of attribute limit
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def limit @limit end |
#name ⇒ Object
Returns the value of attribute name
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def name @name end |
#null ⇒ Object
Returns the value of attribute null
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def null @null end |
#precision ⇒ Object
Returns the value of attribute precision
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def precision @precision end |
#scale ⇒ Object
Returns the value of attribute scale
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def scale @scale end |
#type ⇒ Object
Returns the value of attribute type
269 270 271 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 269 def type @type end |
Instance Method Details
#sql_type ⇒ Object
271 272 273 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 271 def sql_type base.type_to_sql(type.to_sym, limit, precision, scale) rescue type end |
#to_sql ⇒ Object
275 276 277 278 279 280 281 282 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 275 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 |