Sha256: ad4fbdd7de352468c339cc3b2a944bb4fa7e5f833e3cc9149c93c3ad9b6beebe

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

require 'rom/schema'
require 'rom/support/constants'

module ROM
  module SQL
    class Schema < ROM::Schema
      # @!attribute [r] primary_key_name
      #   @return [Symbol] The name of the primary key. This is set because in
      #                    most of the cases relations don't have composite pks
      attr_reader :primary_key_name

      # @!attribute [r] primary_key_names
      #   @return [Array<Symbol>] A list of all pk names
      attr_reader :primary_key_names

      def initialize(*)
        super
        @primary_key_name = nil
        @primary_key_names = EMPTY_ARRAY
      end

      # @api private
      def finalize!(*)
        super do
          if primary_key.size > 0
            @primary_key_name = primary_key[0].meta[:name]
            @primary_key_names = primary_key.map { |type| type.meta[:name] }
          end
        end
      end
    end
  end
end

require 'rom/sql/schema/dsl'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-sql-0.9.1 lib/rom/sql/schema.rb
rom-sql-0.9.0 lib/rom/sql/schema.rb
rom-sql-0.8.0 lib/rom/sql/schema.rb