Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-21 Thread David Cramer
I'm -1 against any change to this. In most use cases, it's not as simple as resorting your python results, or refiltering them, as you have sliced the queryset and the query needs to be executed again to retrieve proper results. On Apr 17, 11:18 am, Travis Parker <[EMAIL PROTECTED]> wrote: > > I'

Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-17 Thread Travis Parker
> I'd be very surprised if .filter or .order_by would do completely > different things based on whether a queryset is already filled or not. > Currently queryset constructing methods are not completely opaque > abstractions of "filtering" and "ordering", and it's good. I think > simplicity here wi

Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-15 Thread Ivan Sagalaev
Travis Parker wrote: > I was just recently optimizing database usage in a django app and > found myself managing these things myself (sorted(qs) instead of > qs.order_by(), filter(filterer, qs) instead of qs.filter()) because I > didn't want the database to get hit again when modifying already-use

Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-15 Thread Travis Parker
It has been brought to my attention that the specific ordering of order_by is potentially different for different backends; it seems that it must be sent to the database for consistency - in other words: qs = Model.objects.all() # ...something that evaluates qs qs.objects.order_by('

Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-15 Thread Malcolm Tredinnick
On Tue, 2008-04-15 at 19:33 -0700, Travis Parker wrote: > > Because every time you modify a QuerySet you are changing the results > > that will be returned. Calling filter() will restrict the results. > > Calling order_by() will change the order the results are returned in. > > And so on. Thus, t

Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-15 Thread Travis Parker
> Because every time you modify a QuerySet you are changing the results > that will be returned. Calling filter() will restrict the results. > Calling order_by() will change the order the results are returned in. > And so on. Thus, the cache of the queyrset that was cloned is invalid > for the new

Re: QuerySet cache maintained through QuerySet-returning methods?

2008-04-15 Thread Malcolm Tredinnick
On Tue, 2008-04-15 at 18:50 -0700, Travis Parker wrote: > Is there a reason that QuerySet methods like order_by() or filter() > don't simply pass on an appropriately modified version of their own > cache to the new QuerySet? Because every time you modify a QuerySet you are changing the results t

QuerySet cache maintained through QuerySet-returning methods?

2008-04-15 Thread Travis Parker
Is there a reason that QuerySet methods like order_by() or filter() don't simply pass on an appropriately modified version of their own cache to the new QuerySet? I was just recently optimizing database usage in a django app and found myself managing these things myself (sorted(qs) instead of qs.