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?, #fetch_cast_type, #human_name
#deduplicate
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
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 68
def ==(other)
other.is_a?(Column) &&
super &&
identity? == other.identity? &&
serial? == other.serial?
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_metadata.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
76
77
78
79
80
81
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 76
def hash
Column.hash ^
super.hash ^
identity?.hash ^
serial?.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?
@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
|