﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20393	django.db.models.query.QuerySet.__repr__ should not have side-effects	justin@…	nobody	"In trying to track down some timeouts and strange queries in our apps we saw some strange queries being run by django. We were querying for a single record with a FOR UPDATE, getting an error, then django would run the same query 3 times but with a limit of 21 and then fetch all of the records, each time.

Eventually I tracked this down to our error-handling middleware calling repr() on a QuerySet, which then queried the database. `__repr__` is supposed to be a string-representation of an object in its current state and should not gave side-effects like making database queries, especially in the case where the query uses FOR UPDATE or similar logic.

I suggest changing `django.db.models.query.QuerySet.__repr__` to only touch the cached records and not use the local iterator, which can and will query the DB, potentially causing issues like this."	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	wontfix	QuerySet, repr, side-effect		Unreviewed	1	0	0	0	0	0
