summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-18 15:05:43 -0500
committerDan McGee <dan@archlinux.org>2012-05-02 09:37:46 -0500
commitbadc535aeb1d310a9b8aa59aade07045e6eae653 (patch)
treeaf644de8b034d45ba296ab39da93b359312a38ca
parentf3e0adcb2fc9a26e2ad9337a47550a37590074d9 (diff)
downloadarchweb-badc535aeb1d310a9b8aa59aade07045e6eae653.tar.gz
archweb-badc535aeb1d310a9b8aa59aade07045e6eae653.zip
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>
-rw-r--r--devel/views.py6
-rw-r--r--main/models.py7
-rw-r--r--news/views.py3
-rw-r--r--packages/utils.py3
-rw-r--r--todolists/views.py4
5 files changed, 14 insertions, 9 deletions
diff --git a/devel/views.py b/devel/views.py
index 85acda74..7ef33362 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -249,7 +249,8 @@ def report(request, report_name, username=None):
if username:
pkg_ids = set(packages.values_list('id', flat=True))
bad_files = bad_files.filter(pkg__in=pkg_ids)
- bad_files = bad_files.values_list('pkg_id', flat=True).distinct()
+ bad_files = bad_files.values_list(
+ 'pkg_id', flat=True).order_by().distinct()
packages = packages.filter(id__in=set(bad_files))
elif report_name == 'uncompressed-info':
title = 'Packages with uncompressed infopages'
@@ -260,7 +261,8 @@ def report(request, report_name, username=None):
if username:
pkg_ids = set(packages.values_list('id', flat=True))
bad_files = bad_files.filter(pkg__in=pkg_ids)
- bad_files = bad_files.values_list('pkg_id', flat=True).distinct()
+ bad_files = bad_files.values_list(
+ 'pkg_id', flat=True).order_by().distinct()
packages = packages.filter(id__in=set(bad_files))
elif report_name == 'unneeded-orphans':
title = 'Orphan packages required by no other packages'
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'
diff --git a/news/views.py b/news/views.py
index 268f0523..03f3b0ac 100644
--- a/news/views.py
+++ b/news/views.py
@@ -13,7 +13,8 @@ from .models import News
def find_unique_slug(newsitem):
'''Attempt to find a unique slug for this news item.'''
- existing = list(News.objects.values_list('slug', flat=True).distinct())
+ existing = list(News.objects.values_list(
+ 'slug', flat=True).order_by().distinct())
suffixed = slug = slugify(newsitem.title)
suffix = 0
diff --git a/packages/utils.py b/packages/utils.py
index a3c13b17..8d00bd68 100644
--- a/packages/utils.py
+++ b/packages/utils.py
@@ -218,7 +218,8 @@ def attach_maintainers(packages):
packages = list(packages)
pkgbases = set(p.pkgbase for p in packages)
rels = PackageRelation.objects.filter(type=PackageRelation.MAINTAINER,
- pkgbase__in=pkgbases).values_list('pkgbase', 'user_id').distinct()
+ pkgbase__in=pkgbases).values_list(
+ 'pkgbase', 'user_id').order_by().distinct()
# get all the user objects we will need
user_ids = set(rel[1] for rel in rels)
diff --git a/todolists/views.py b/todolists/views.py
index e5cc0823..70209b6d 100644
--- a/todolists/views.py
+++ b/todolists/views.py
@@ -49,8 +49,8 @@ def flag(request, list_id, pkg_id):
@login_required
def view(request, list_id):
todolist = get_object_or_404(Todolist, id=list_id)
- svn_roots = Repo.objects.order_by().values_list(
- 'svn_root', flat=True).distinct()
+ svn_roots = Repo.objects.values_list(
+ 'svn_root', flat=True).order_by().distinct()
# we don't hold onto the result, but the objects are the same here,
# so accessing maintainers in the template is now cheap
attach_maintainers(tp.pkg for tp in todolist.packages)