On Thu, Jan 19, 2012 at 1:27 PM, Adrian Holovaty <adr...@holovaty.com>wrote:
> On Thu, Jan 19, 2012 at 12:15 PM, Carl Meyer <c...@oddbird.net> wrote: > > I don't think Adrian is proposing anything as extensive as #17. What > > he's proposing (IIUC) wouldn't change the semantics of your sample code > > at all. All it would do is prepopulate the FK field on the results of a > > reverse-FK query, so the innermost "book.author" here doesn't need to do > > a query: > > > > for author in Author.objects.all(): > > for book in author.books.all(): > > book.author > > > > There wouldn't be any action-at-a-distance with other Book instances. > > Right, what Carl said -- no action-at-a-distance, just mere cache > population on each related object. I don't think there would be a risk > of backwards-incompatible side effects. > > It would certainly be worth at least a note in the release notes, as it is a change. The only situation where I can imagine someone relying on the current behaviour is in regression tests. I can see code like this being in place inside a test suite: def setUp(self): # We need a foo for every test in this test case self.foo = Foo.objects.get(id=1) def test_that_munges_are_really_saved(self): # Munge the bar. This should also set foo.baz to 12 bar = self.foo.bar munge_bar(bar) # check that the Foo really got updated. Before Yestermas, the Foo got updated # in memory, but the changes weren't being saved to the db self.assertEqual(bar.foo.baz, 12) This code would have been written with the current behaviour in place, and then completely forgotten about, buried in a suite of tests. It's easy to argue that the test code is incorrect, and should be using a different method to check the state of the database, but a test like this could continue to pass even in the event of an actual regression, and the developers wouldn't even know that their test was wrong. At least with a mention in the release notes, [diligent] developers would have been warned, and could check their code for these sorts of assumptions. -- Regards, Ian Clelland <clell...@gmail.com> -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.