Sha256: 022a7ba75e8293065b0d18926985da8e334dd38901e1ce18762c7c5588abacce

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

RSpec.describe ROM::SQL::Schema, :postgres do
  describe '#primary_key' do
    it 'returns primary key attributes' do
      schema_proc = Class.new(ROM::Relation[:sql]).schema do
        attribute :id, ROM::SQL::Types::Serial
      end

      schema = schema_proc.call
      schema.finalize_attributes!.finalize!

      expect(schema.primary_key).to eql([schema[:id]])
    end

    it 'returns empty array when there is no PK defined' do
      schema_proc = Class.new(ROM::Relation[:sql]).schema do
        attribute :id, ROM::SQL::Types::Int
      end

      schema = schema_proc.call
      schema.finalize_attributes!.finalize!

      expect(schema.primary_key).to eql([])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-sql-2.0.0.beta2 spec/unit/schema_spec.rb
rom-sql-2.0.0.beta1 spec/unit/schema_spec.rb