Changeset 6866
- Timestamp:
- 12/03/07 15:10:41 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/db/models/sql/query.py
r6860 r6866 258 258 return ' '.join(result), tuple(params) 259 259 260 def combine(self, rhs, connect ion):260 def combine(self, rhs, connector): 261 261 """ 262 262 Merge the 'rhs' query into the current one (with any 'rhs' effects … … 264 264 current query. 'rhs' is not modified during a call to this function. 265 265 266 The 'connect ion' parameter describes how to connect filters from the266 The 'connector' parameter describes how to connect filters from the 267 267 'rhs' query. 268 268 """ … … 277 277 change_map = {} 278 278 used = {} 279 conjunction = (connect ion== AND)279 conjunction = (connector == AND) 280 280 first = True 281 281 for alias in rhs.tables: … … 322 322 else: 323 323 w = WhereNode() 324 self.where.add(w, connect ion)324 self.where.add(w, connector) 325 325 326 326 # Selection columns and extra extensions are those provided by 'rhs'. … … 466 466 for field in ordering: 467 467 if field == '?': 468 result.append(self.connect ion.ops.random_function_sql())468 result.append(self.connector.ops.random_function_sql()) 469 469 continue 470 470 if isinstance(field, int): … … 665 665 used) 666 666 667 def add_filter(self, filter_expr, connect ion=AND, negate=False):667 def add_filter(self, filter_expr, connector=AND, negate=False): 668 668 """ 669 669 Add a single filter to the query. … … 695 695 try: 696 696 field, target, unused, join_list, nullable = self.setup_joins(parts, 697 opts, alias, (connect ion== AND))697 opts, alias, (connector == AND)) 698 698 except TypeError, e: 699 699 if len(parts) != 1 or parts[0] not in self.extra_select: … … 701 701 # Filtering on some alias from extra(select=...) 702 702 self.where.add([None, parts[0], None, lookup_type, value], 703 connect ion)703 connector) 704 704 return 705 705 col = target.column … … 725 725 self.promote_alias(join_list[-1][0]) 726 726 727 self.where.add([alias, col, field, lookup_type, value], connect ion)727 self.where.add([alias, col, field, lookup_type, value], connector) 728 728 if negate: 729 729 flag = False … … 751 751 for child in q_object.children: 752 752 if isinstance(child, Node): 753 self.where.start_subtree(q_object.connect ion)753 self.where.start_subtree(q_object.connector) 754 754 self.add_q(child) 755 755 self.where.end_subtree() 756 756 else: 757 self.add_filter(child, q_object.connect ion, q_object.negated)757 self.add_filter(child, q_object.connector, q_object.negated) 758 758 759 759 def setup_joins(self, names, opts, alias, dupe_multis): django/branches/queryset-refactor/django/db/models/sql/where.py
r6762 r6866 58 58 format = '%s' 59 59 except EmptyResultSet: 60 if self.connect ion== AND and not node.negated:60 if self.connector == AND and not node.negated: 61 61 # We can bail out early in this particular case (only). 62 62 raise … … 65 65 result.append(format % sql) 66 66 result_params.extend(params) 67 conn = ' %s ' % node.connect ion67 conn = ' %s ' % node.connector 68 68 return conn.join(result), result_params 69 69 django/branches/queryset-refactor/django/utils/tree.py
r6493 r6866 12 12 Node instances. 13 13 """ 14 # Standard connect iontype. Clients usually won't use this at all and14 # Standard connector type. Clients usually won't use this at all and 15 15 # subclasses will usually override the value. 16 16 default = 'DEFAULT' 17 17 18 def __init__(self, children=None, connect ion=None):18 def __init__(self, children=None, connector=None): 19 19 self.children = children and children[:] or [] 20 self.connect ion = connectionor self.default20 self.connector = connector or self.default 21 21 self.subtree_parents = [] 22 22 self.negated = False 23 23 24 24 def __str__(self): 25 return '(%s: %s)' % (self.connect ion, ', '.join([str(c) for c in25 return '(%s: %s)' % (self.connector, ', '.join([str(c) for c in 26 26 self.children])) 27 27 … … 30 30 Utility method used by copy.deepcopy(). 31 31 """ 32 obj = self.__class__(connect ion=self.connection)32 obj = self.__class__(connector=self.connector) 33 33 obj.children = copy.deepcopy(self.children, memodict) 34 34 obj.subtree_parents = copy.deepcopy(self.subtree_parents, memodict) … … 57 57 """ 58 58 Adds a new node to the tree. If the conn_type is the same as the root's 59 current connect iontype, the node is added to the first level.59 current connector type, the node is added to the first level. 60 60 Otherwise, the whole tree is pushed down one level and a new root 61 connect ionis created, connecting the existing tree and the new node.61 connector is created, connecting the existing tree and the new node. 62 62 """ 63 63 if len(self.children) < 2: 64 self.connect ion= conn_type65 if self.connect ion== conn_type:66 if isinstance(node, Node) and (node.connect ion== conn_type64 self.connector = conn_type 65 if self.connector == conn_type: 66 if isinstance(node, Node) and (node.connector == conn_type 67 67 or len(node) == 1): 68 68 self.children.extend(node.children) … … 70 70 self.children.append(node) 71 71 else: 72 obj = Node(self.children, self.connect ion)73 self.connect ion= conn_type72 obj = Node(self.children, self.connector) 73 self.connector = conn_type 74 74 self.children = [obj, node] 75 75 76 76 def negate(self): 77 77 """ 78 Negate the sense of the root connect ion.78 Negate the sense of the root connector. 79 79 80 80 Interpreting the meaning of this negate is up to client code. This 81 81 method is useful for implementing "not" arrangements. 82 82 """ 83 self.children = [NegatedNode(self.children, self.connect ion,83 self.children = [NegatedNode(self.children, self.connector, 84 84 old_state=self.negated)] 85 self.connect ion= self.default85 self.connector = self.default 86 86 87 87 def start_subtree(self, conn_type): … … 92 92 """ 93 93 if len(self.children) == 1: 94 self.connect ion= conn_type95 elif self.connect ion!= conn_type:96 self.children = [Node(self.children, self.connect ion)]97 self.connect ion= conn_type94 self.connector = conn_type 95 elif self.connector != conn_type: 96 self.children = [Node(self.children, self.connector)] 97 self.connector = conn_type 98 98 99 self.subtree_parents.append(Node(self.children, self.connect ion))100 self.connect ion= self.default99 self.subtree_parents.append(Node(self.children, self.connector)) 100 self.connector = self.default 101 101 self.children = [] 102 102 … … 109 109 """ 110 110 obj = self.subtree_parents.pop() 111 node = Node(self.children, self.connect ion)112 self.connect ion = obj.connection111 node = Node(self.children, self.connector) 112 self.connector = obj.connector 113 113 self.children = obj.children 114 114 self.children.append(node) … … 116 116 class NegatedNode(Node): 117 117 """ 118 A class that indicates the connect iontype should be negated (whatever that118 A class that indicates the connector type should be negated (whatever that 119 119 means -- it's up to the client) when used by the client code. 120 120 """ 121 def __init__(self, children=None, connect ion=None, old_state=True):122 super(NegatedNode, self).__init__(children, connect ion)121 def __init__(self, children=None, connector=None, old_state=True): 122 super(NegatedNode, self).__init__(children, connector) 123 123 self.negated = not old_state 124 124
