Sha256: 1177e10d35ac1af9f05151974d496a723a562c95339b980e0c5f7208944738a3

Contents?: true

Size: 564 Bytes

Versions: 5

Compression:

Stored size: 564 Bytes

Contents

RSpec.describe ROM::Relation, '#exists' do
  include_context 'users and tasks'

  let(:tasks) { container.relations.tasks }
  let(:users) { container.relations.users }

  with_adapters do
    it 'returns true if subquery has at least one tuple' do
      subquery = tasks.where(tasks[:user_id].qualified => users[:id].qualified)
      expect(users.where { exists(subquery) }.count).to eql(2)
    end

    it 'returns false if subquery is empty' do
      subquery = tasks.where(false)
      expect(users.where { exists(subquery) }.count).to eql(0)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rom-sql-1.3.5 spec/unit/relation/exists_spec.rb
rom-sql-1.3.4 spec/unit/relation/exists_spec.rb
rom-sql-2.0.0.beta2 spec/unit/relation/exists_spec.rb
rom-sql-2.0.0.beta1 spec/unit/relation/exists_spec.rb
rom-sql-1.3.3 spec/unit/relation/exists_spec.rb