Sha256: f3baf5590b8699c42bb4b733d3688a637648a26074afd97b4bb4b530537f4068

Contents?: true

Size: 887 Bytes

Versions: 3

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  # :stopdoc:
  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(/\[\]$/, "")
      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-6.0.0.beta3 lib/active_record/connection_adapters/postgresql/type_metadata.rb
activerecord-6.0.0.beta2 lib/active_record/connection_adapters/postgresql/type_metadata.rb
activerecord-6.0.0.beta1 lib/active_record/connection_adapters/postgresql/type_metadata.rb