Sha256: 976a44d3a11b9745bbc2a58e42e23e0215204465b6eb9ae47c8fe2df2aeb79fd

Contents?: true

Size: 1.4 KB

Versions: 24

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require "active_support/core_ext/object/blank"

module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      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
    PostgreSQLColumn = PostgreSQL::Column # :nodoc:
  end
end

Version data entries

24 entries across 22 versions & 3 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/postgresql/column.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/postgresql/column.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.2.3/lib/active_record/connection_adapters/postgresql/column.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/postgresql/column.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.4.3 lib/active_record/connection_adapters/postgresql/column.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.4.2 lib/active_record/connection_adapters/postgresql/column.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.4.1 lib/active_record/connection_adapters/postgresql/column.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.4 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.3.1 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.3 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.2.4 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.2.3 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.2.2 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.2.1 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.2 lib/active_record/connection_adapters/postgresql/column.rb
activerecord-7.0.1 lib/active_record/connection_adapters/postgresql/column.rb