Re: Clearing prefetch related on add(), change(), remove()

2016-06-08 Thread Josh Smeaton
Usually, yes. I'm not sure refresh_from_db works on related managers though. I ran into a similar issue writing unit test fixtures just last week and refresh_from_db didn't fix the problem. On Thursday, 9 June 2016 02:46:25 UTC+10, bliy...@rentlytics.com wrote: > > To be clear, I think the

Re: Clearing prefetch related on add(), change(), remove()

2016-06-08 Thread bliyanage
To be clear, I think the way to force the refresh of an orm object is to use the `refresh_from_db` method. Is that functionally equivalent? -Ben On Tuesday, June 7, 2016 at 6:12:30 AM UTC-7, Marc Tamlyn wrote: > > I may be "too close" to knowing the implementation of this feature to be > able

Re: Clearing prefetch related on add(), change(), remove()

2016-06-08 Thread bliyanage
I am for the clearing of the cache--that behavior seems weird. If you didn't want the cache to clear you would probably be using a different orm object to do your query. Just to be clear, after clearing the cache, any future requests against that data will be lazily evaluated right? -Ben On

Re: Clearing prefetch related on add(), change(), remove()

2016-06-08 Thread Marc Tamlyn
I didn't know queryset.update did clear the internal cache. In that case it's pretty reasonable. I think it should only clear a .all() cache though, not any prefetched set. On 7 June 2016 at 22:38, Florian Apolloner wrote: > Same feeling as Carl here. I was probably the

Re: Clearing prefetch related on add(), change(), remove()

2016-06-07 Thread Florian Apolloner
Same feeling as Carl here. I was probably the first to get asked whether or not this was a bug or not on IRC and my initial thought was also "wtf, that is clearly a bug" -- hence I asked Yoong Kang Lim to open a ticket. Cheers, Florian On Tuesday, June 7, 2016 at 7:47:29 PM UTC+2, Carl Meyer

Re: Clearing prefetch related on add(), change(), remove()

2016-06-07 Thread Carl Meyer
On 06/07/2016 06:11 AM, Marc Tamlyn wrote: > I may be "too close" to knowing the implementation of this feature to be > able to comment on whether the behaviour is surprising to most people, > but it doesn't surprise me. It's certainly analogous to that when you do > `MyModel.objects.create()` it

Re: Clearing prefetch related on add(), change(), remove()

2016-06-07 Thread Marc Tamlyn
I may be "too close" to knowing the implementation of this feature to be able to comment on whether the behaviour is surprising to most people, but it doesn't surprise me. It's certainly analogous to that when you do `MyModel.objects.create()` it doesn't change an already executed queryset.

Clearing prefetch related on add(), change(), remove()

2016-06-07 Thread Yoong Kang Lim
Hi all, I'd like to bring up ticket #26706: https://code.djangoproject.com/ticket/26706 Related managers have methods such as add(), change() and remove() that change database objects. When a prefetch_related is done prior to calling these methods, it does not clear the cache. When the related