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, 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?
64
65
66
67
68
69
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 64
def ==(other)
other.is_a?(Column) &&
super &&
identity? == other.identity? &&
serial? == other.serial?
end
|
#array ⇒ Object
Also known as:
array?
37
38
39
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 37
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
57
58
59
60
61
62
|
# File '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
|
#enum? ⇒ Boolean
42
43
44
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 42
def enum?
type == :enum
end
|
#has_default? ⇒ Boolean
33
34
35
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 33
def has_default?
super && !virtual?
end
|
#hash ⇒ Object
72
73
74
75
76
77
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 72
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
50
51
52
53
54
55
|
# File '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
|
#serial? ⇒ Boolean
20
21
22
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 20
def serial?
@serial
end
|
#sql_type ⇒ Object
46
47
48
|
# File 'lib/active_record/connection_adapters/postgresql/column.rb', line 46
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
|