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
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def base @base end |
#default ⇒ Object
Returns the value of attribute default
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def default @default end |
#limit ⇒ Object
Returns the value of attribute limit
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def limit @limit end |
#name ⇒ Object
Returns the value of attribute name
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def name @name end |
#null ⇒ Object
Returns the value of attribute null
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def null @null end |
#precision ⇒ Object
Returns the value of attribute precision
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def precision @precision end |
#scale ⇒ Object
Returns the value of attribute scale
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def scale @scale end |
#type ⇒ Object
Returns the value of attribute type
266 267 268 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 266 def type @type end |
Instance Method Details
#sql_type ⇒ Object
268 269 270 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 268 def sql_type base.type_to_sql(type.to_sym, limit, precision, scale) rescue type end |
#to_sql ⇒ Object
272 273 274 275 276 277 278 279 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 272 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 |