Changeset 7031
- Timestamp:
- 01/27/08 05:17:33 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/db/models/sql/query.py
r6967 r7031 78 78 79 79 alias_prefix = 'T' 80 81 def __init__(self, model, connection): 80 query_terms = QUERY_TERMS 81 82 def __init__(self, model, connection, where=WhereNode): 82 83 self.model = model 83 84 self.connection = connection … … 92 93 self.select = [] 93 94 self.tables = [] # Aliases in the order they are created. 94 self.where = WhereNode() 95 self.where = where() 96 self.where_class = where 95 97 self.group_by = [] 96 98 self.having = [] … … 157 159 obj.tables = self.tables[:] 158 160 obj.where = copy.deepcopy(self.where) 161 obj.where_class = self.where_class 159 162 obj.group_by = self.group_by[:] 160 163 obj.having = self.having[:] … … 193 196 obj.select_related = False 194 197 if obj.distinct and len(obj.select) > 1: 195 obj = self.clone(CountQuery, _query=obj, where= WhereNode(),198 obj = self.clone(CountQuery, _query=obj, where=self.where_class(), 196 199 distinct=False) 197 200 obj.select = [] … … 320 323 # rhs has an empty where clause. Make it match everything (see 321 324 # above for reasoning). 322 w = WhereNode()325 w = self.where_class() 323 326 alias = self.join((None, self.model._meta.db_table, None, None)) 324 327 pk = self.model._meta.pk 325 328 w.add(EverythingNode(), AND) 326 329 else: 327 w = WhereNode()330 w = self.where_class() 328 331 self.where.add(w, connector) 329 332 … … 705 708 706 709 # Work out the lookup type and remove it from 'parts', if necessary. 707 if len(parts) == 1 or parts[-1] not in QUERY_TERMS:710 if len(parts) == 1 or parts[-1] not in self.query_terms: 708 711 lookup_type = 'exact' 709 712 else: … … 1110 1113 if not isinstance(related.field, generic.GenericRelation): 1111 1114 for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 1112 where = WhereNode()1115 where = self.where_class() 1113 1116 where.add((None, related.field.m2m_reverse_name(), 1114 1117 related.field, 'in', … … 1118 1121 1119 1122 for f in cls._meta.many_to_many: 1120 w1 = WhereNode()1123 w1 = self.where_class() 1121 1124 if isinstance(f, generic.GenericRelation): 1122 1125 from django.contrib.contenttypes.models import ContentType … … 1125 1128 ContentType.objects.get_for_model(cls).id), AND) 1126 1129 for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 1127 where = WhereNode()1130 where = self.where_class() 1128 1131 where.add((None, f.m2m_column_name(), f, 'in', 1129 1132 pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE]), … … 1142 1145 """ 1143 1146 for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 1144 where = WhereNode()1147 where = self.where_class() 1145 1148 field = self.model._meta.pk 1146 1149 where.add((None, field.column, field, 'in', … … 1186 1189 """ 1187 1190 for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 1188 where = WhereNode()1191 where = self.where_class() 1189 1192 f = self.model._meta.pk 1190 1193 where.add((None, f.column, f, 'in',
