Skip to content

Commit 6bacd69

Browse files
committed
fixes #35
1 parent 043b846 commit 6bacd69

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/mongo/cursor.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ defmodule Mongo.Cursor do
9191
end
9292

9393
state(docs: docs) = state -> {docs, state(state, docs: [])}
94+
{:error, error} -> raise error ## In case of an error, we should raise the error
9495
end
9596
end
9697

test/mongo/cursor_test.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@ defmodule Mongo.CursorTest do
2020
assert {:ok, _} = Mongo.insert_many(c.pid, coll, docs)
2121
assert [%{"foo" => 42}, %{"foo" => 42}] = Mongo.find(c.pid, coll, %{}, limit: 2) |> Enum.to_list |> Enum.map(fn m -> Map.pop(m, "_id") |> elem(1) end)
2222
end
23+
24+
# issue #35: Crash executing find function without enough permission
25+
test "matching errors in the next function of the stream api", c do
26+
# this is not valid, so we get an exception
27+
assert_raise Mongo.Error, fn ->
28+
Mongo.find(c.pid, "test", [_id: ["$gth": 1]]) |> Enum.to_list()
29+
end
30+
end
31+
2332
end

0 commit comments

Comments
 (0)