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
#bigint?, #human_name
#deduplicate
Constructor Details
#initialize(serial: nil, generated: nil) ⇒ Column
Returns a new instance of Column.
11
12
13
14
15
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 11
def initialize(*, serial: nil, generated: nil, **)
super
@serial = serial
@generated = generated
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
55
56
57
58
59
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 55
def ==(other)
other.is_a?(Column) &&
super &&
serial? == other.serial?
end
|
#array ⇒ Object
Also known as:
array?
30
31
32
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 30
def array
sql_type_metadata.sql_type.end_with?("[]")
end
|
#encode_with(coder) ⇒ Object
49
50
51
52
53
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 49
def encode_with(coder)
coder["serial"] = @serial
coder["generated"] = @generated
super
end
|
#enum? ⇒ Boolean
35
36
37
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 35
def enum?
type == :enum
end
|
#has_default? ⇒ Boolean
26
27
28
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 26
def has_default?
super && !virtual?
end
|
#hash ⇒ Object
62
63
64
65
66
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 62
def hash
Column.hash ^
super.hash ^
serial?.hash
end
|
#init_with(coder) ⇒ Object
43
44
45
46
47
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 43
def init_with(coder)
@serial = coder["serial"]
@generated = coder["generated"]
super
end
|
#serial? ⇒ Boolean
17
18
19
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 17
def serial?
@serial
end
|
#sql_type ⇒ Object
39
40
41
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 39
def sql_type
super.delete_suffix("[]")
end
|
#virtual? ⇒ Boolean
21
22
23
24
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 21
def virtual?
@generated.present?
end
|