Sha256: a5fabf3eb2780af8c7f063ca4e627581ed60f1a42cc3235aeb9bb0276546e70f

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require "active_record/connection_adapters/deduplicable"

module ActiveRecord
  # :stopdoc:
  module ConnectionAdapters
    class SqlTypeMetadata
      include Deduplicable

      attr_reader :sql_type, :type, :limit, :precision, :scale

      def initialize(sql_type: nil, type: nil, limit: nil, precision: nil, scale: nil)
        @sql_type = sql_type
        @type = type
        @limit = limit
        @precision = precision
        @scale = scale
      end

      def ==(other)
        other.is_a?(SqlTypeMetadata) &&
          sql_type == other.sql_type &&
          type == other.type &&
          limit == other.limit &&
          precision == other.precision &&
          scale == other.scale
      end
      alias eql? ==

      def hash
        SqlTypeMetadata.hash ^
          sql_type.hash ^
          type.hash ^
          limit.hash ^
          precision.hash >> 1 ^
          scale.hash >> 2
      end

      private
        def deduplicated
          @sql_type = -sql_type
          super
        end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activerecord-6.1.3.2 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.3.1 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.3 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.2.1 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.2 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.1 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.0 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.0.rc2 lib/active_record/connection_adapters/sql_type_metadata.rb
activerecord-6.1.0.rc1 lib/active_record/connection_adapters/sql_type_metadata.rb