Ticket #10515: added-__rand__-and-__ror__-support-to-QuerySet.patch

File added-__rand__-and-__ror__-support-to-QuerySet.patch, 1.9 KB (added by Sebastian Noack, 16 years ago)
  • django/django/db/models/query.py

    diff --git a/django/django/db/models/query.py b/django/django/db/models/query.py
    index 5b9f504..4d42a75 100644
    a b class QuerySet(object):  
    240240            raise IndexError, e.args
    241241
    242242    def __and__(self, other):
     243        if hasattr(other, '__rand__'):
     244            return other.__rand__(self)
    243245        self._merge_sanity_check(other)
    244246        if isinstance(other, EmptyQuerySet):
    245247            return other._clone()
    class QuerySet(object):  
    248250        return combined
    249251
    250252    def __or__(self, other):
     253        if hasattr(other, '__ror__'):
     254             return other.__ror__(self)
    251255        self._merge_sanity_check(other)
    252256        combined = self._clone()
    253257        if isinstance(other, EmptyQuerySet):
  • res/patches/django/added-__rand__-and-__ror__-support-to-QuerySet.patch

    diff --git a/res/patches/django/added-__rand__-and-__ror__-support-to-QuerySet.patch b/res/patches/django/added-__rand__-and-__ror__-support-to-QuerySet.patch
    index 765fd46..e69de29 100644
    a b  
    1 diff --git a/django/db/models/query.py b/django/db/models/query.py
    2 index 6b341ba..f2638cd 100644
    3 --- a/django/db/models/query.py
    4 +++ b/django/db/models/query.py
    5 @@ -131,12 +131,18 @@ class QuerySet(object):
    6              raise IndexError, e.args
    7  
    8      def __and__(self, other):
    9 +        if hasattr(other, '__rand__'):
    10 +            return other.__rand__(self)
    11 +
    12          self._merge_sanity_check(other)
    13          combined = self._clone()
    14          combined.query.combine(other.query, sql.AND)
    15          return combined
    16  
    17      def __or__(self, other):
    18 +        if hasattr(other, '__ror__'):
    19 +            return other.__ror__(self)
    20 +
    21          self._merge_sanity_check(other)
    22          combined = self._clone()
    23          combined.query.combine(other.query, sql.OR)
Back to Top