Skip to content

Commit 2e2b5a1

Browse files
committed
MONGOID-4118: Count must be cast to integer
1 parent eb88df6 commit 2e2b5a1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/mongo/collection/view/readable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def count(options = {})
138138
cmd[:limit] = options[:limit] if options[:limit]
139139
cmd[:maxTimeMS] = options[:max_time_ms] if options[:max_time_ms]
140140
read_with_retry do
141-
database.command(cmd, options).n
141+
database.command(cmd, options).n.to_i
142142
end
143143
end
144144

spec/mongo/collection/view/readable_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@
227227
it 'returns the count of matching documents' do
228228
expect(view.count).to eq(1)
229229
end
230+
231+
it 'returns an integer' do
232+
expect(view.count).to be_a(Integer)
233+
end
230234
end
231235

232236
context 'when no selector is provided' do

0 commit comments

Comments
 (0)