Sha256: ba42b81e013aa23cb0f756f5cc933d6658775d503e918d805246205b048334d6

Contents?: true

Size: 1.1 KB

Versions: 30

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require "active_support/core_ext/object/blank"

module ActiveRecord
  module ConnectionAdapters
    module CipherStashPG
      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.delete_suffix("[]")
        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
    CipherStashPGColumn = CipherStashPG::Column # :nodoc:
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.7.4 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.3 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.2 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.1 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.0 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.6.1 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.6.0 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.5.0 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.4.0 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.3.0 lib/active_record/connection_adapters/6.1/cipherstash_pg/column.rb