Opened 9 years ago

Closed 9 years ago

#25508 closed Cleanup/optimization (fixed)

Add "QuerySet()" to QuerySet.__repr__ to help debugging

Reported by: Tim Graham Owned by: Tim Graham
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

TransactionTestCase.assertQuerysetEqual can give errors like AssertionError: ['1.8', '1.7', '1.4'] != ['1.8', '1.7', '1.4'] when you compare a list and a QuerySet. Alex proposed to change the repr of QuerySet to QuerySet([...]) and the idea received several +1's in #django-dev.

Change History (5)

comment:1 by Tim Graham, 9 years ago

Has patch: set

comment:2 by Claude Paroz, 9 years ago

Agreed it's a good idea. However, the docs might have to be updated in many places, for example in https://docs.djangoproject.com/en/1.8/topics/db/examples/many_to_many/.
git grep "\[<" gives an indication about where docs might need en update.

comment:3 by Tim Graham, 9 years ago

Thanks for pointing that out and providing the grep hint. Docs are now updated.

comment:4 by Claude Paroz, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In e0837f2c:

Fixed #25508 -- Modified QuerySet.repr() to disambiguate it from a list.

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