Skip to content

Commit 0ff7a59

Browse files
committed
RUBY-650 catch adding multiple options
1 parent 19f4758 commit 0ff7a59

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/mongo/cursor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def query_opts
386386
def add_option(opt)
387387
check_modifiable
388388

389-
if (opt == OP_QUERY_EXHAUST) && (@limit != 0)
389+
if exhaust?(opt) && (@limit != 0)
390390
raise MongoArgumentError, "Exhaust option is incompatible with limit."
391391
end
392392

@@ -633,8 +633,8 @@ def close_cursor_if_query_complete
633633
# Check whether the exhaust option is set
634634
#
635635
# @return [true, false] The state of the exhaust flag.
636-
def exhaust?
637-
!(@options & OP_QUERY_EXHAUST).zero?
636+
def exhaust?(opts = options)
637+
!(opts & OP_QUERY_EXHAUST).zero?
638638
end
639639

640640
def check_modifiable

test/functional/cursor_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def test_exhaust_after_limit_error
9696
assert_raise MongoArgumentError do
9797
c.add_option(OP_QUERY_EXHAUST)
9898
end
99+
100+
assert_raise MongoArgumentError do
101+
c.add_option(OP_QUERY_EXHAUST + OP_QUERY_SLAVE_OK)
102+
end
99103
end
100104

101105
def test_limit_after_exhaust_error

0 commit comments

Comments
 (0)