From 619576002d538094dde7293d970bc4698ecdbef5 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 11 Mar 2008 05:21:50 +0000 Subject: queyrset-refactor: Added error reporting if somebody tries to order by a multi-valued field. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7220 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'django/db/models/sql/query.py') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ef3f5220fb..7d24701438 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -509,8 +509,10 @@ class Query(object): pieces = name.split(LOOKUP_SEP) if not alias: alias = self.get_initial_alias() - field, target, opts, joins = self.setup_joins(pieces, opts, alias, - False) + result = self.setup_joins(pieces, opts, alias, False, False) + if isinstance(result, int): + raise FieldError("Cannot order by many-valued field: '%s'" % name) + field, target, opts, joins = result alias = joins[-1][-1] col = target.column -- cgit v1.3