Django

Code

Ticket #5883 (closed: fixed)

Opened 1 year ago

Last modified 9 months ago

CursorDebugWrapper should implement __iter__

Reported by: eibaan Assigned to: nobody
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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/utils.py.

Attachments

5883.diff (0.9 kB) - added by arien <regexbot@gmail.com> on 11/06/07 20:45:04.
patch

Change History

11/06/07 20:45:04 changed by arien <regexbot@gmail.com>

  • attachment 5883.diff added.

patch

11/06/07 21:02:56 changed by arien <regexbot@gmail.com>

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

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.

03/06/08 10:11:25 changed by guettli

  • stage changed from Unreviewed to Accepted.

03/06/08 10:31:44 changed by guettli

  • stage changed from Accepted to Ready for checkin.

03/17/08 09:15:16 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #5883 (CursorDebugWrapper should implement __iter__)




Change Properties
Action