fix: add cursor iteration support to psycopg2 MockCursor for django.contrib.postgres #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where Django apps with
django.contrib.postgresinINSTALLED_APPSwould crash during startup in REPLAY mode withTypeError: 'MockCursor' object is not iterable.Django's postgres extension iterates over cursor results to register type handlers (hstore, citext, etc.):
The
MockCursorclass was missing__iter__and__next__methods required for this iteration pattern.Changes
__iter__and__next__methods toMockCursorclass for REPLAY mode cursor iteration__iter__and__next__methods toInstrumentedCursorclass for RECORD mode cursor iteration (uses stored_tusk_rowsafter_finalize_query_spancaptures rows)django.contrib.postgresto thedjango-postgresstack test to validate the fix/db/cursor-iterationtest endpoint that exercisesfor row in cursorsyntax