-
Notifications
You must be signed in to change notification settings - Fork 21.6k
/
column.rb
53 lines (44 loc) · 1.04 KB
/
column.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# frozen_string_literal: true
module ActiveRecord
module ConnectionAdapters
module PostgreSQL
class Column < ConnectionAdapters::Column # :nodoc:
delegate :oid, :fmod, to: :sql_type_metadata
def initialize(*, serial: nil, **)
super
@serial = serial
end
def serial?
@serial
end
def array
sql_type_metadata.sql_type.end_with?("[]")
end
alias :array? :array
def sql_type
super.sub(/\[\]\z/, "")
end
def init_with(coder)
@serial = coder["serial"]
super
end
def encode_with(coder)
coder["serial"] = @serial
super
end
def ==(other)
other.is_a?(Column) &&
super &&
serial? == other.serial?
end
alias :eql? :==
def hash
Column.hash ^
super.hash ^
serial?.hash
end
end
end
PostgreSQLColumn = PostgreSQL::Column # :nodoc:
end
end