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

.clone() does not clone the .__empty attribute

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.11
    • Component/s: Query Operations
    • Labels:
      None

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: