blob: b252a76caa1233de4b6a0e0ca16353f3c40f0143 (
plain) (
blame)
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
|
# frozen_string_literal: true
module ActiveRecord
module ConnectionAdapters
class PostgreSQLTypeMetadata < DelegateClass(SqlTypeMetadata)
undef to_yaml if method_defined?(:to_yaml)
attr_reader :oid, :fmod, :array
def initialize(type_metadata, oid: nil, fmod: nil)
super(type_metadata)
@type_metadata = type_metadata
@oid = oid
@fmod = fmod
@array = /\[\]$/.match?(type_metadata.sql_type)
end
def sql_type
super.gsub(/\[\]$/, "".freeze)
end
def ==(other)
other.is_a?(PostgreSQLTypeMetadata) &&
attributes_for_hash == other.attributes_for_hash
end
alias eql? ==
def hash
attributes_for_hash.hash
end
protected
def attributes_for_hash
[self.class, @type_metadata, oid, fmod]
end
end
end
end
|