#20393: django.db.models.query.QuerySet.__repr__ should not have side-effects
-------------------------------------+-------------------------------------
     Reporter:  justin@…             |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Database layer       |                  Version:  1.4
  (models, ORM)                      |               Resolution:  wontfix
     Severity:  Normal               |             Triage Stage:
     Keywords:  QuerySet, repr,      |  Unreviewed
  side-effect                        |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by patrys):

 What if we changed `__repr__` to be safe (only print query params) and
 allowed a slice with `Ellipsis` to return a list of first N elements,
 possibly executing the query if not evaluated earlier?

 Example:

 {{{
 >>> x = Foo.objects.filter(age__gte=5)
 <QuerySet(Foo, …)>
 >>> x[...]
 [<Foo>, <Foo>, <Foo>, <Foo>, '11 more...']
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20393#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/079.76ced1481e2b594e73584104f8bb83fc%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to