123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::PostgreSQL::Column

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveRecord::ConnectionAdapters::Column
Defined in: activerecord/lib/active_record/connection_adapters/postgresql/column.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(serial: nil, identity: nil, generated: nil) ⇒ Column

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 9

def initialize(*, serial: nil, identity: nil, generated: nil, **)
  super
  @serial = serial
  @identity = identity
  @generated = generated
end

Instance Attribute Details

#array (readonly) Also known as: #array?

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 37

def array
  .sql_type.end_with?("[]")
end

#array? (readonly)

Alias for #array.

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 40

alias :array? :array

#auto_incremented_by_db?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 24

def auto_incremented_by_db?
  serial? || identity?
end

#enum?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 42

def enum?
  type == :enum
end

#fmod (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 7

delegate :oid, :fmod, to: :

#has_default?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 33

def has_default?
  super && !virtual?
end

#identity?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 16

def identity?
  @identity
end

#oid (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 7

delegate :oid, :fmod, to: :

#serial?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 20

def serial?
  @serial
end

#virtual?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 28

def virtual?
  # We assume every generated column is virtual, no matter the concrete type
  @generated.present?
end

Instance Method Details

#==(other) Also known as: #eql?

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 64

def ==(other)
  other.is_a?(Column) &&
    super &&
    identity? == other.identity? &&
    serial? == other.serial?
end

#encode_with(coder)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 57

def encode_with(coder)
  coder["serial"] = @serial
  coder["identity"] = @identity
  coder["generated"] = @generated
  super
end

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 70

alias :eql? :==

#hash

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 72

def hash
  Column.hash ^
    super.hash ^
    identity?.hash ^
    serial?.hash
end

#init_with(coder)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 50

def init_with(coder)
  @serial = coder["serial"]
  @identity = coder["identity"]
  @generated = coder["generated"]
  super
end

#sql_type

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/postgresql/column.rb', line 46

def sql_type
  super.delete_suffix("[]")
end