Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 00203265209f081baab391213280917cd1f160e6 1 parent 9aa1235
@jacobian jacobian authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 django/core/meta/__init__.py
View
4 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]
Please sign in to comment.
Something went wrong with that request. Please try again.