Class: ActiveRecord::ConnectionAdapters::Column
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Subclasses: | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Instance Chain: 
          self,
           Deduplicable | |
| Inherits: | Object | 
| Defined in: | activerecord/lib/active_record/connection_adapters/column.rb | 
Overview
An abstract definition of a column in a table.
Class Method Summary
- 
    
      .new(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil)  ⇒ Column 
    
    constructor
    Internal use only
    Instantiates a new column in the table. 
Instance Attribute Summary
- #limit readonly
- #precision readonly
- #scale readonly
- #sql_type readonly
- #type readonly
- 
    
      #auto_incremented_by_db?  ⇒ Boolean 
    
    readonly
    Internal use only
    whether the column is auto-populated by the database using a sequence. 
- #auto_populated? ⇒ Boolean readonly Internal use only
- #bigint? ⇒ Boolean readonly Internal use only
- #collation readonly Internal use only
- #comment readonly Internal use only
- #default readonly Internal use only
- #default_function readonly Internal use only
- #has_default? ⇒ Boolean readonly Internal use only
- #name readonly Internal use only
- #null readonly Internal use only
- #sql_type_metadata readonly Internal use only
- #virtual? ⇒ Boolean readonly Internal use only
Instance Method Summary
- #==(other) (also: #eql?) Internal use only
- #encode_with(coder) Internal use only
- 
    
      #eql?(other)  
    
    Internal use only
    Alias for #==. 
- #hash Internal use only
- 
    
      #human_name  
    
    Internal use only
    Returns the human name of the column name. 
- #init_with(coder) Internal use only
- #deduplicated private Internal use only
Deduplicable - Included
| #-@ | Alias for Deduplicable#deduplicate. | 
| #deduplicate, #deduplicated | |
Constructor Details
    .new(name, default, sql_type_metadata = nil, null = true, default_function = nil, collation: nil, comment: nil)  ⇒ Column 
  
  
    This method is for internal use only.
  
Instantiates a new column in the table.
#name is the column’s name, such as supplier_id in supplier_id bigint. #default is the type-casted default value, such as new in sales_stage varchar(20) default 'new'. #sql_type_metadata is various information about the type of the column #null determines if this column allows NULL values.
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 20
def initialize(name, default, = nil, null = true, default_function = nil, collation: nil, comment: nil, **) @name = name.freeze @sql_type_metadata = @null = null @default = default @default_function = default_function @collation = collation @comment = comment end
Instance Attribute Details
    #auto_incremented_by_db?  ⇒ Boolean  (readonly)
  
  
    This method is for internal use only.
  
whether the column is auto-populated by the database using a sequence
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 67
def auto_incremented_by_db? false end
    #auto_populated?  ⇒ Boolean  (readonly)
  
  
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 71
def auto_populated? auto_incremented_by_db? || default_function end
    #bigint?  ⇒ Boolean  (readonly)
  
  
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 34
def bigint? /\Abigint\b/.match?(sql_type) end
#collation (readonly)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 10
attr_reader :name, :default, :, :null, :default_function, :collation, :comment
#comment (readonly)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 10
attr_reader :name, :default, :, :null, :default_function, :collation, :comment
#default (readonly)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 10
attr_reader :name, :default, :, :null, :default_function, :collation, :comment
#default_function (readonly)
    This method is for internal use only.
  
  [ GitHub ]
    #has_default?  ⇒ Boolean  (readonly)
  
  
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 30
def has_default? !default.nil? || default_function end
#limit (readonly)
[ GitHub ]#name (readonly)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 10
attr_reader :name, :default, :, :null, :default_function, :collation, :comment
#null (readonly)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 10
attr_reader :name, :default, :, :null, :default_function, :collation, :comment
#precision (readonly)
[ GitHub ]#scale (readonly)
[ GitHub ]#sql_type (readonly)
[ GitHub ]#sql_type_metadata (readonly)
    This method is for internal use only.
  
  [ GitHub ]
#type (readonly)
[ GitHub ]
    #virtual?  ⇒ Boolean  (readonly)
  
  
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 99
def virtual? false end
Instance Method Details
#==(other) Also known as: #eql?
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 75
def ==(other) other.is_a?(Column) && name == other.name && default == other.default && == other. && null == other.null && default_function == other.default_function && collation == other.collation && comment == other.comment end
#deduplicated (private)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 104
def deduplicated @name = -name @sql_type_metadata = .deduplicate if @default = -default if default @default_function = -default_function if default_function @collation = -collation if collation @comment = -comment if comment super end
#encode_with(coder)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 56
def encode_with(coder) coder["name"] = @name coder["sql_type_metadata"] = @sql_type_metadata coder["null"] = @null coder["default"] = @default coder["default_function"] = @default_function coder["collation"] = @collation coder["comment"] = @comment end
#eql?(other)
    This method is for internal use only.
  
Alias for #==.
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 85
alias :eql? :==
#hash
    This method is for internal use only.
  
  [ GitHub ]
#human_name
    This method is for internal use only.
  
Returns the human name of the column name.
Examples
Column.new('sales_stage', ...).human_name # => 'Sales stage'# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 42
def human_name Base.human_attribute_name(@name) end
#init_with(coder)
    This method is for internal use only.
  
  [ GitHub ]
# File 'activerecord/lib/active_record/connection_adapters/column.rb', line 46
def init_with(coder) @name = coder["name"] @sql_type_metadata = coder["sql_type_metadata"] @null = coder["null"] @default = coder["default"] @default_function = coder["default_function"] @collation = coder["collation"] @comment = coder["comment"] end