Class: ActiveRecord::ConnectionAdapters::PostgreSQL::Column
- Inherits:
-
Column
- Object
- Column
- ActiveRecord::ConnectionAdapters::PostgreSQL::Column
show all
- Defined in:
- lib/active_record/connection_adapters/postgresql/column.rb
Overview
Instance Attribute Summary
Attributes inherited from Column
#collation, #comment, #default, #default_function, #name, #null, #sql_type_metadata
Instance Method Summary
collapse
Methods inherited from Column
#auto_populated?, #bigint?, #human_name
#deduplicate
Constructor Details
#initialize(serial: nil, generated: nil) ⇒ Column
Returns a new instance of Column.
9
10
11
12
13
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 9
def initialize(*, serial: nil, generated: nil, **)
super
@serial = serial
@generated = generated
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
54
55
56
57
58
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 54
def ==(other)
other.is_a?(Column) &&
super &&
serial? == other.serial?
end
|
#array ⇒ Object
Also known as:
array?
29
30
31
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 29
def array
sql_type_metadata.sql_type.end_with?("[]")
end
|
#encode_with(coder) ⇒ Object
48
49
50
51
52
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 48
def encode_with(coder)
coder["serial"] = @serial
coder["generated"] = @generated
super
end
|
#enum? ⇒ Boolean
34
35
36
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 34
def enum?
type == :enum
end
|
#has_default? ⇒ Boolean
25
26
27
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 25
def has_default?
super && !virtual?
end
|
#hash ⇒ Object
61
62
63
64
65
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 61
def hash
Column.hash ^
super.hash ^
serial?.hash
end
|
#init_with(coder) ⇒ Object
42
43
44
45
46
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 42
def init_with(coder)
@serial = coder["serial"]
@generated = coder["generated"]
super
end
|
#serial? ⇒ Boolean
Also known as:
auto_incremented_by_db?
15
16
17
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 15
def serial?
@serial
end
|
#sql_type ⇒ Object
38
39
40
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 38
def sql_type
super.delete_suffix("[]")
end
|
#virtual? ⇒ Boolean
20
21
22
23
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 20
def virtual?
@generated.present?
end
|