Sha256: 7b40b17035b0f1c3fa3ddecf779b9680912815d9ab10fe518151323f69a39930

Contents?: true

Size: 648 Bytes

Versions: 23

Compression:

Stored size: 648 Bytes

Contents

RSpec.describe ROM::Relation, '#primary_key' do
  subject(:relation) { container.relations.users }

  include_context 'users and tasks'

  with_adapters do
    context 'with schema' do
      it 'returns configured primary key from the schema' do
        conf.relation(:users) do
          schema do
            attribute :name, ROM::SQL::Types::String.meta(primary_key: true)
          end
        end

        expect(relation.primary_key).to be(:name)
      end
    end

    context 'without schema' do
      it 'returns :id by default' do
        conf.relation(:users)

        expect(relation.primary_key).to be(:id)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/unit/relation/primary_key_spec.rb
rom-sql-1.3.4 spec/unit/relation/primary_key_spec.rb
rom-sql-1.3.3 spec/unit/relation/primary_key_spec.rb
rom-sql-1.3.2 spec/unit/relation/primary_key_spec.rb
rom-sql-1.3.1 spec/unit/relation/primary_key_spec.rb
rom-sql-1.3.0 spec/unit/relation/primary_key_spec.rb
rom-sql-1.2.2 spec/unit/relation/primary_key_spec.rb
rom-sql-1.2.1 spec/unit/relation/primary_key_spec.rb
rom-sql-1.2.0 spec/unit/relation/primary_key_spec.rb
rom-sql-1.1.2 spec/unit/relation/primary_key_spec.rb
rom-sql-1.1.1 spec/unit/relation/primary_key_spec.rb
rom-sql-1.1.0 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.3 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.2 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.1 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.0 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.0.rc2 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.0.rc1 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.0.beta3 spec/unit/relation/primary_key_spec.rb
rom-sql-1.0.0.beta2 spec/unit/relation/primary_key_spec.rb