Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1086

How to detect the cursor_not_found?

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.3
    • Affects Version/s: 2.2.0
    • Component/s: None
    • Labels:
      None

      By mongo-ruby-driver, How to detect the cursor_not_found?
      as moped…

      lib/moped/protocol/get_more.rb
      
            def failure_exception(reply)
              if reply.cursor_not_found?
                Errors::CursorNotFound.new(self, cursor_id)
              else
                Errors::QueryFailure.new(self, reply.documents.first)
              end
            end
      

      By the following monkey patch, Can't detected the cursor_not_found.

      module Mongo
        module Protocol
          class Reply
            def cursor_not_found?
              flags.include?(:cursor_not_found)
            end
          end
        end
      end
      
      module Mongo
        class Cursor
      
          def fail_cursor_not_found
            if @initial_result.replies.last && @initial_result.replies.last.cursor_not_found?
              fail Mongo::Error::OperationFailure
            end
          end
      
          def more?
            fail_cursor_not_found
            @cursor_id != 0
          end
        end
      end
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            SeijiKawashima Seiji Kawashima [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: