Ticket #16979: df1.diff

File df1.diff, 1.7 KB (added by javier@…, 13 years ago)
  • tree.py

    old new  
    4545        return obj
    4646    _new_instance = classmethod(_new_instance)
    4747
     48    @staticmethod
     49    def _push (t, pfx):
     50        """adds pfx to the first member of any tuple in the tree."""
     51        import copy
     52        if isinstance(t, tuple):
     53            return ((pfx+t[0],)+t[1:])
     54
     55        elif isinstance(t, list):
     56            return map(lambda x: Node._push(x, pfx), t)
     57
     58        elif isinstance (t, Node):
     59            t2 = copy.copy(t)
     60            t2.children = Node._push(t2.children, pfx)
     61            t2.subtree_parents = Node._push(t2.subtree_parents, pfx)
     62            return t2
     63
     64        else:
     65            return copy.copy(t)
     66
    4867    def __str__(self):
    4968        if self.negated:
    5069            return '(NOT (%s: %s))' % (self.connector, ', '.join([str(c) for c
  • query.py

    old new  
    11671167                    self.where.start_subtree(connector)
    11681168                if isinstance(child, Node):
    11691169                    self.add_q(child, used_aliases, force_having=force_having)
     1170                elif isinstance(child, tuple) and isinstance(child[1], Node):
     1171                    self.add_q(_push(child[1], child_[0]+'__'),
     1172                            used_aliases, force_having=force_having)
    11701173                else:
    11711174                    self.add_filter(child, connector, q_object.negated,
    11721175                            can_reuse=used_aliases, force_having=force_having)
Back to Top