Opened 7 years ago

Closed 6 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: UI/UX:


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@…> 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by arien <regexbot@…>


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

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 6 years ago by guettli

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 6 years ago by guettli

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.