Opened 17 years ago

Closed 17 years ago

#6807 closed (fixed)

execute_sql in django/db/models/sql/query.py fails with MySQL due to incorrect sentinel

Reported by: tpherndon Owned by: tpherndon
Component: Core (Other) Version: queryset-refactor
Severity: Keywords: qs-rf
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Line 1333: return iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), []) fails under MySQL because the cursor.fetchmany() call returns an empty tuple as sentinel, rather than an empty list. The empty list sentinel is correct for sqlite. I attempted to run runtests.py, which hung on "Running post-sync handlers for application string_lookup". When I changed the sentinel to a tuple, runtests.py ran to completion (four failing tests, but completion) with MySQL, yet hung in the exact same place with sqlite.

Attachments (1)

iterator_sentinel.patch (2.1 KB ) - added by tpherndon 17 years ago.
Sets iterator sentinel to proper sentinel type for sqlite and mysql backends.

Download all attachments as: .zip

Change History (3)

by tpherndon, 17 years ago

Attachment: iterator_sentinel.patch added

Sets iterator sentinel to proper sentinel type for sqlite and mysql backends.

comment:1 by Malcolm Tredinnick, 17 years ago

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Nice catch. But I'd prefer to have a function that just returns the "empty sentinel" value in each case, rather than testing for one or the other.

comment:2 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [7283]) queryset-refactor: Different database backends return different empty sequences
when fetchmany() is exhausted. This change allows for that. Fixed #6807.

Nice debugging from tpherndon.

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