Changeset 6867
- Timestamp:
- 12/03/07 15:10:51 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/db/models/sql/query.py
r6866 r6867 9 9 10 10 import copy 11 import operator 11 12 import re 12 13 … … 466 467 for field in ordering: 467 468 if field == '?': 468 result.append(self.connect or.ops.random_function_sql())469 result.append(self.connection.ops.random_function_sql()) 469 470 continue 470 471 if isinstance(field, int): … … 725 726 self.promote_alias(join_list[-1][0]) 726 727 728 if connector == OR: 729 # Some joins may need to be promoted when adding a new filter to a 730 # disjunction. We walk the list of new joins and where it diverges 731 # from any previous joins (ref count is 1 in the table list), we 732 # make the new additions (and any existing ones not used in the new 733 # join list) an outer join. 734 join_it = nested_iter(join_list) 735 table_it = iter(self.tables) 736 join_it.next(), table_it.next() 737 for join in join_it: 738 table = table_it.next() 739 if join == table and self.alias_map[join][ALIAS_REFCOUNT] > 1: 740 continue 741 self.promote_alias(join) 742 if table != join: 743 self.promote_alias(table) 744 break 745 for join in join_it: 746 self.promote_alias(join) 747 for table in table_it: 748 # Some of these will have been promoted from the join_list, but 749 # that's harmless. 750 self.promote_alias(table) 751 727 752 self.where.add([alias, col, field, lookup_type, value], connector) 753 728 754 if negate: 729 755 flag = False … … 1199 1225 yield rows 1200 1226 1227 def nested_iter(nested): 1228 """ 1229 An iterator over a sequence of sequences. Each element is returned in turn. 1230 Only handles one level of nesting, since that's all we need here. 1231 """ 1232 for seq in nested: 1233 for elt in seq: 1234 yield elt 1235 1201 1236 def setup_join_cache(sender): 1202 1237 """ django/branches/queryset-refactor/tests/regressiontests/queries/models.py
r6859 r6867 197 197 >>> Author.objects.filter(Q(name='a3') | Q(item__name='one')) 198 198 [<Author: a1>, <Author: a3>] 199 >>> Author.objects.filter(Q(item__name='three') | Q(report__name='r3')) 200 [<Author: a2>] 199 201 200 202 Bug #6074
