diff options
author | Dan McGee <dan@archlinux.org> | 2012-04-18 15:05:43 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-05-02 09:37:46 -0500 |
commit | badc535aeb1d310a9b8aa59aade07045e6eae653 (patch) | |
tree | af644de8b034d45ba296ab39da93b359312a38ca /main | |
parent | f3e0adcb2fc9a26e2ad9337a47550a37590074d9 (diff) |
Ensure order_by default value is cleared when using distinct()
Otherwise the queryset returns nonsensical results. I find the design of
this less than obvious but so be it; we can ensure the results work
regardless of a default ordering on the model.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r-- | main/models.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/main/models.py b/main/models.py index c532ed56..398cb88b 100644 --- a/main/models.py +++ b/main/models.py @@ -13,7 +13,7 @@ from .utils import cache_function, set_created_field, utc_now class TodolistManager(models.Manager): def incomplete(self): - return self.filter(todolistpkg__complete=False).distinct() + return self.filter(todolistpkg__complete=False).order_by().distinct() class PackageManager(models.Manager): def flagged(self): @@ -378,7 +378,7 @@ class PackageDepend(models.Model): '''Return providers of this dep. Does *not* include exact matches as it checks the Provision names only, use get_best_satisfier() instead.''' pkgs = Package.objects.normal().filter( - provides__name=self.depname).distinct() + provides__name=self.depname).order_by().distinct() if arches is not None: pkgs = pkgs.filter(arch__in=arches) @@ -432,7 +432,8 @@ class Todolist(models.Model): @property def package_names(self): # depends on packages property returning a queryset - return self.packages.values_list('pkg__pkgname', flat=True).distinct() + return self.packages.values_list( + 'pkg__pkgname', flat=True).order_by().distinct() class Meta: db_table = 'todolists' |