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
This commit is contained in:
parent
9aa1235779
commit
0020326520
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue