Skip to content

Commit

Permalink
fixed #101
Browse files Browse the repository at this point in the history
  • Loading branch information
zookzook committed Aug 8, 2021
1 parent ea780d9 commit b7aa63c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mongo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ defmodule Mongo do

cmd = filter_nils(cmd)

drop = ~w(limit hint single_batch read_concern max min collation return_key show_record_id tailable no_cursor_timeout await_data batch_size projection comment max_time skip sort)a
drop = ~w(limit hint single_batch read_concern max min collation return_key show_record_id tailable no_cursor_timeout await_data projection comment skip sort)a
opts = Keyword.drop(opts, drop)
try do
get_stream(topology_pid, cmd, opts)
Expand Down
32 changes: 32 additions & 0 deletions test/mongo/batch_size_text.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
defmodule Mongo.BatchSizeTest do

require Logger

use CollectionCase

test "find, using :batch_size of 100 options", %{pid: top, catcher: catcher} do

coll = unique_collection()
n = 10_000
Mongo.delete_many(top, coll, %{})

Enum.each(1..n, fn i ->
Mongo.insert_one(top, coll, %{index: i}, [w: 0])
end)

assert {:ok, n} == Mongo.count(top, coll, %{})

assert n == top
|> Mongo.find(coll, %{}, batch_size: 100)
|> Enum.to_list()
|> Enum.count()

get_mores = catcher
|> EventCatcher.succeeded_events()
|> Enum.map(fn event -> event.command_name end)
|> Enum.filter(fn command_name -> command_name == :getMore end)
|> Enum.count()

assert 100 == get_mores
end
end

0 comments on commit b7aa63c

Please sign in to comment.