From 343786f8cdbf9577e4b6f1ca42b94d4296631675 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Sun, 31 Jan 2010 07:55:43 +0200 Subject: Reintroduce optimized code for Todo listings Now that maintainer is nullable, Django will use a LEFT OUTER JOIN with this code, so orphan packages won't be omitted. Signed-off-by: Dan McGee --- main/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'main') diff --git a/main/models.py b/main/models.py index 98547a35..d0c9c5c4 100644 --- a/main/models.py +++ b/main/models.py @@ -303,10 +303,10 @@ class Todolist(models.Model): @property def packages(self): - # TODO: bug here, because we do foreign keys all wrong the join query fucks up when it - # can't find a foreign key that is missing values, e.g. maintainer == 0. - # Once this is fixed, we can remove the depth argument. - return TodolistPkg.objects.select_related(depth=1).filter(list=self).order_by('pkg') + # select_related() does not use LEFT OUTER JOIN for nullable ForeignKey + # fields. That is why we need to explicitly list the ones we want. + return TodolistPkg.objects.select_related( + 'pkg__repo', 'pkg__arch', 'pkg__maintainer').filter(list=self).order_by('pkg') @property def package_names(self): -- cgit v1.2.3-2-g168b