Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2254

.clone() does not clone the .__empty attribute

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.11
    • Affects Version/s: None
    • Component/s: Query Operations
    • None

      It is an edge case but when slicing a cursor with for instance [1:1], cloning the cursor would lead to a different result (initial cursor would be empty, cloned cursor won't be empty)

      collection.count()
      cursor1 = collection.find()[1:1]
      
      assert cursor1._Cursor__empty is True
      assert cursor1._Cursor__limit == 0
      assert cursor1._Cursor__skip == 1
      
      cursor2 = cursor1.clone()
      assert cursor2._Cursor__empty is True    # raises AssertionError, its False
      assert cursor2._Cursor__skip == 1
      assert cursor2._Cursor__limit == 0

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            bast.gerard@gmail.com Bastien Grard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: