From 00203265209f081baab391213280917cd1f160e6 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 5 Dec 2005 17:40:19 +0000 Subject: [PATCH] Fixed bug in get_next_by_FOO/get_previous_by_FOO methods that caused a database error when using those methods along with joining lookup contraints (i.e. "obj.get_next_by_pub_date(related__id__in=some_list)") git-svn-id: http://code.djangoproject.com/svn/django/trunk@1550 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/meta/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py index 3aaaad576b..df95af37c2 100644 --- a/django/core/meta/__init__.py +++ b/django/core/meta/__init__.py @@ -1245,9 +1245,9 @@ def method_get_order(ordered_obj, self): def method_get_next_or_previous(get_object_func, opts, field, is_next, self, **kwargs): op = is_next and '>' or '<' - kwargs.setdefault('where', []).append('(%s %s %%s OR (%s = %%s AND %s %s %%s))' % \ + kwargs.setdefault('where', []).append('(%s %s %%s OR (%s = %%s AND %s.%s %s %%s))' % \ (db.db.quote_name(field.column), op, db.db.quote_name(field.column), - db.db.quote_name(opts.pk.column), op)) + db.db.quote_name(opts.db_table), db.db.quote_name(opts.pk.column), op)) param = str(getattr(self, field.attname)) kwargs.setdefault('params', []).extend([param, param, getattr(self, opts.pk.attname)]) kwargs['order_by'] = [(not is_next and '-' or '') + field.name, (not is_next and '-' or '') + opts.pk.name]