Opened 8 years ago

Closed 8 years ago

#6807 closed (fixed)

execute_sql in django/db/models/sql/ 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: UI/UX:


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, which hung on "Running post-sync handlers for application string_lookup". When I changed the sentinel to a tuple, 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 8 years ago.
Sets iterator sentinel to proper sentinel type for sqlite and mysql backends.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by tpherndon

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

comment:1 Changed 8 years ago by mtredinnick

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 8 years ago by mtredinnick

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

(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