Sha256: 4ebed1f74475bc4b0359b6be87529aa5ec0961f85e3fde64f6139bcab0ff6143

Contents?: true

Size: 599 Bytes

Versions: 23

Compression:

Stored size: 599 Bytes

Contents

RSpec.describe ROM::Relation, '#having' do
  subject(:relation) do
    relations[:users]
      .inner_join(:tasks, user_id: :id)
      .qualified
      .select_group(:id, :name)
      .select_append { int::count(:tasks).as(:task_count) }
  end

  include_context 'users and tasks'

  with_adapters :postgres do
    before do
      conn[:tasks].insert(id: 3, user_id: 2, title: "Joe's another task")
    end

    it 'restricts a relation using HAVING clause' do
      expect(relation.having { count(id.qualified) >= 2 }.to_a).
        to eq([{ id: 2, name: 'Joe', task_count: 2 }])
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

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