File tree Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -68,14 +68,19 @@ class << self
6868 # KillCursorsCommand.update_cursors(spec, ids)
6969 #
7070 # @return [ Hash ] The specification.
71- # @return [ Array ] The ids to update with.
71+ # @return [ Array<Integer> ] The ids to update with.
7272 #
7373 # @since 2.3.0
7474 def update_cursors ( spec , ids )
75+ # Ruby 2.5+ can & BSON::Int64 instances.
76+ # Ruby 2.4 and earlier cannot.
77+ # Convert stored ids to Ruby integers for compatibility with
78+ # older Rubies.
79+ ids = get_cursors_list ( spec ) & ids
7580 ids = ids . map do |cursor_id |
7681 BSON ::Int64 . new ( cursor_id )
7782 end
78- spec [ :selector ] . merge! ( cursors : spec [ :selector ] [ :cursors ] & ids )
83+ spec [ :selector ] . merge! ( cursors : ids )
7984 end
8085
8186 # Get the list of cursor ids from a spec generated by this Builder.
Original file line number Diff line number Diff line change @@ -63,14 +63,19 @@ class << self
6363 # OpKillCursors.update_cursors(spec, ids)
6464 #
6565 # @return [ Hash ] The specification.
66- # @return [ Array ] The ids to update with.
66+ # @return [ Array<Integer> ] The ids to update with.
6767 #
6868 # @since 2.3.0
6969 def update_cursors ( spec , ids )
70+ # Ruby 2.5+ can & BSON::Int64 instances.
71+ # Ruby 2.4 and earlier cannot.
72+ # Convert stored ids to Ruby integers for compatibility with
73+ # older Rubies.
74+ ids = get_cursors_list ( spec ) & ids
7075 ids = ids . map do |cursor_id |
7176 BSON ::Int64 . new ( cursor_id )
7277 end
73- spec . merge! ( cursor_ids : spec [ :cursor_ids ] & ids )
78+ spec . merge! ( cursor_ids : ids )
7479 end
7580
7681 # Get the list of cursor ids from a spec generated by this Builder.
Original file line number Diff line number Diff line change 318318 Mongo ::Collection ::View . new (
319319 authorized_collection ,
320320 { } ,
321- :batch_size => 2
321+ :batch_size => 2 ,
322322 )
323323 end
324324
329329
330330 it 'schedules a kill cursors op' do
331331 cluster . instance_variable_get ( :@periodic_executor ) . flush
332- expect {
332+ expect do
333333 cursor . to_a
334- } . to raise_exception ( Mongo ::Error ::OperationFailure , /[cC]ursor.*not found/ )
334+ end . to raise_exception ( Mongo ::Error ::OperationFailure , /[cC]ursor.*not found/ )
335335 end
336336
337337 context 'when the cursor is unregistered before the kill cursors operations are executed' do
You can’t perform that action at this time.
0 commit comments