Django

Code

Ticket #6807 (closed: fixed)

Opened 9 months ago

Last modified 9 months ago

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

Reported by: tpherndon Assigned to: tpherndon
Milestone: Component: Core framework
Version: queryset-refactor Keywords: qs-rf
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

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

iterator_sentinel.patch (2.1 kB) - added by tpherndon on 03/17/08 17:52:09.
Sets iterator sentinel to proper sentinel type for sqlite and mysql backends.

Change History

03/17/08 17:52:09 changed by tpherndon

  • attachment iterator_sentinel.patch added.

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

03/17/08 21:46:26 changed by mtredinnick

  • needs_better_patch set to 1.
  • has_patch set to 1.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

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.

03/18/08 01:15:30 changed by mtredinnick

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

(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.


Add/Change #6807 (execute_sql in django/db/models/sql/query.py fails with MySQL due to incorrect sentinel)




Change Properties
Action