Class: ActiveRecord::ConnectionAdapters::PostgreSQL::Column
- Inherits:
-
ConnectionAdapters::Column
- Object
- ConnectionAdapters::Column
- ActiveRecord::ConnectionAdapters::PostgreSQL::Column
- Defined in:
- lib/active_record/connection_adapters/postgresql/column.rb
Overview
:nodoc:
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #array ⇒ Object (also: #array?)
- #auto_incremented_by_db? ⇒ Boolean
- #encode_with(coder) ⇒ Object
- #enum? ⇒ Boolean
- #has_default? ⇒ Boolean
- #hash ⇒ Object
- #identity? ⇒ Boolean
- #init_with(coder) ⇒ Object
-
#initialize(serial: nil, identity: nil, generated: nil) ⇒ Column
constructor
A new instance of Column.
- #serial? ⇒ Boolean
- #sql_type ⇒ Object
- #virtual? ⇒ Boolean
- #virtual_stored? ⇒ Boolean
Constructor Details
#initialize(serial: nil, identity: nil, generated: nil) ⇒ Column
Returns a new instance of Column.
9 10 11 12 13 14 |
# File '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 Method Details
#==(other) ⇒ Object Also known as: eql?
68 69 70 71 72 73 74 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 68 def ==(other) other.is_a?(Column) && super && identity? == other.identity? && serial? == other.serial? && virtual? == other.virtual? end |
#array ⇒ Object Also known as: array?
41 42 43 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 41 def array .sql_type.end_with?("[]") end |
#auto_incremented_by_db? ⇒ Boolean
24 25 26 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 24 def auto_incremented_by_db? serial? || identity? end |
#encode_with(coder) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 61 def encode_with(coder) coder["serial"] = @serial coder["identity"] = @identity coder["generated"] = @generated super end |
#enum? ⇒ Boolean
46 47 48 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 46 def enum? type == :enum end |
#has_default? ⇒ Boolean
37 38 39 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 37 def has_default? super && !virtual? end |
#hash ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 77 def hash Column.hash ^ super.hash ^ identity?.hash ^ serial?.hash ^ virtual?.hash end |
#identity? ⇒ Boolean
16 17 18 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 16 def identity? @identity end |
#init_with(coder) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 54 def init_with(coder) @serial = coder["serial"] @identity = coder["identity"] @generated = coder["generated"] super end |
#serial? ⇒ Boolean
20 21 22 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 20 def serial? @serial end |
#sql_type ⇒ Object
50 51 52 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 50 def sql_type super.delete_suffix("[]") end |
#virtual? ⇒ Boolean
28 29 30 31 |
# File '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 |
#virtual_stored? ⇒ Boolean
33 34 35 |
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 33 def virtual_stored? @generated == "s" end |