diff --git a/lib/stretchy/relations/finder_methods.rb b/lib/stretchy/relations/finder_methods.rb index a11fa1f..509618e 100644 --- a/lib/stretchy/relations/finder_methods.rb +++ b/lib/stretchy/relations/finder_methods.rb @@ -47,7 +47,9 @@ def count def count! @values[:count] = true @values.delete(:size) - spawn.results + spawned = spawn + spawned.order_values.clear + spawned.results end end diff --git a/spec/stretchy/querying_spec.rb b/spec/stretchy/querying_spec.rb index 89c3b07..9c8ef58 100644 --- a/spec/stretchy/querying_spec.rb +++ b/spec/stretchy/querying_spec.rb @@ -61,6 +61,10 @@ expect(described_class.count).to be_a(Integer) expect(described_class.count).to eq(19) end + + it 'removes order from count' do + expect(described_class.order(age: :asc).count).to eq(19) + end end context '.where' do