Opened 11 years ago

Closed 11 years ago

#5883 closed (fixed)

CursorDebugWrapper should implement __iter__

Reported by: eibaan Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


According to PEP 249, a database cursor can be iterable. The CursorDebugWrapper however cannot correctly delegate this. To fix this, a method

def __iter__(self):
    return iter(self.cursor)

added to that class enables support for cursor iteration if DEBUG is enabled. This method should be added to django/db/backends/

Attachments (1)

5883.diff (953 bytes) - added by arien <regexbot@…> 11 years ago.

Download all attachments as: .zip

Change History (5)

Changed 11 years ago by arien <regexbot@…>

Attachment: 5883.diff added


comment:1 Changed 11 years ago by arien <regexbot@…>

Has patch: set

The logical thing to do would be to make all cursors iterable.

The postgresql backend uses a UnicodeCursorWrapper which isn't iterable around a psycopg1 cursor; all other backends have iterable cursors.

The patch fixes both issues.

comment:2 Changed 11 years ago by Thomas Güttler

Triage Stage: UnreviewedAccepted

comment:3 Changed 11 years ago by Thomas Güttler

Triage Stage: AcceptedReady for checkin

comment:4 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [7259]) Fixed #5883 -- Added iter methods to the debug cursor and the postgresql backend cursor.

Note: See TracTickets for help on using tickets.
Back to Top