Ticket #16979: df1.2.diff

File df1.2.diff, 2.2 KB (added by javier@…, 13 years ago)

improved, now it accepts Q(relfield=Q(...))

  • db/models/query_utils.py

    diff -ur venv/lib/python2.6/site-packages/django/db/models/query_utils.py django_off/db/models/query_utils.py
    old new  
    4343    default = AND
    4444
    4545    def __init__(self, *args, **kwargs):
    46         children = list(args)
    47         for k,v in kwargs.items():
    48             if isinstance(v, tree.Node):
    49                 children.append(v._prefix(k+'__'))
    50             else:
    51                 children.append((k,v))
    52         super(Q, self).__init__(children=children)
     46        super(Q, self).__init__(children=list(args) + kwargs.items())
    5347
    5448    def _combine(self, other, conn):
    5549        if not isinstance(other, Q):
  • utils/tree.py

    Binary files venv/lib/python2.6/site-packages/django/db/models/query_utils.pyc and django_off/db/models/query_utils.pyc differ
    Binary files venv/lib/python2.6/site-packages/django/db/models/sql/query.pyc and django_off/db/models/sql/query.pyc differ
    diff -ur venv/lib/python2.6/site-packages/django/utils/tree.py django_off/utils/tree.py
    old new  
    55
    66from django.utils.copycompat import deepcopy
    77
    8 
    9 def _t_prefix (t, pfx):
    10         """adds pfx to the first member of any tuple in the tree."""
    11         import copy
    12 
    13         if isinstance(t, tuple):
    14                 return ((pfx+t[0],)+t[1:])
    15 
    16         elif isinstance(t, list):
    17                 return map(lambda x: _t_prefix(x, pfx), t)
    18 
    19         elif isinstance (t, Node):
    20                 t2 = copy.copy(t)
    21                 t2.children = _t_prefix(t2.children, pfx)
    22                 t2.subtree_parents = _t_prefix(t2.subtree_parents, pfx)
    23                 return t2
    24 
    25 
    268class Node(object):
    279    """
    2810    A single internal node in the tree graph. A Node should be viewed as a
     
    6345        return obj
    6446    _new_instance = classmethod(_new_instance)
    6547
    66     def _prefix(self, pfx):
    67         return _t_prefix(self, pfx)
    68 
    6948    def __str__(self):
    7049        if self.negated:
    7150            return '(NOT (%s: %s))' % (self.connector, ', '.join([str(c) for c
Back to Top