Kaydet (Commit) 00203265 authored tarafından Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss

Fixed bug in get_next_by_FOO/get_previous_by_FOO methods that caused a database…

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
üst 9aa12357
......@@ -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]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment