Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1246

Cursor.All() should end implicit session

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.1
    • Affects Version/s: None
    • Component/s: CRUD
    • None
    • Fully Compatible

      Currently Collection.Find() returns a Cursor and an error.

      The new Cursor.All() method is very helpful, because it allows to load the cursor to a slice.

      However I see 1 major problem: the cursor "API" is exposed to the user, and he must take care of closing it. If I understand correctly, if you don't close it, there is a leak.

      As a developer and reviewer, it's very easy to miss a cursor that isn't closed.

      It would be simpler/safer for a user that calls .All() to close the cursor automatically.

      I see 2 solutions:

            Assignee:
            alice.thum@mongodb.com Alice Thum
            Reporter:
            pierrre Pierre Durand
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: