Sha256: 782ec53e35a8da3525a63c22da941615996e281b06a0d73347089eca98899d2a

Contents?: true

Size: 1.41 KB

Versions: 32

Compression:

Stored size: 1.41 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, generated: nil, **)
          super
          @serial = serial
          @generated = generated
        end

        def serial?
          @serial
        end

        def virtual?
          # We assume every generated column is virtual, no matter the concrete type
          @generated.present?
        end

        def has_default?
          super && !virtual?
        end

        def array
          sql_type_metadata.sql_type.end_with?("[]")
        end
        alias :array? :array

        def enum?
          type == :enum
        end

        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

32 entries across 32 versions & 1 rubygems

Version Path
activerecord-cipherstash-pg-adapter-0.8.5 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.8.4 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.8.3 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.8.2 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.8.1 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.8.0 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.19 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.18 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.17 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.16 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.15 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.14 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.12 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.11 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.10 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.9 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.8 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.7 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.6 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb
activerecord-cipherstash-pg-adapter-0.7.5 lib/active_record/connection_adapters/7.0/cipherstash_pg/column.rb