diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-03 16:36:28 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-03 16:36:28 +0000 |
| commit | d4d528e9b05a2b0e8f6899adaa463a426feb4b91 (patch) | |
| tree | 9a0d06a819db5403608e45c6b0b37482360bcac1 | |
| parent | 22ecacda1b850c75910967e94a393777ea07df13 (diff) | |
queryset-refactor: Simplified updates of related tables, with added bonus of less bugs.
It will be slightly less efficient in rare cases, but who cares? If anybody
needs it to be as efficient as possible they can write the query manually and
this is good enough for the other 98% or so.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7190 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/models/sql/subqueries.py | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index 3c2d87d20f..374109d355 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -1,7 +1,6 @@ """ Query subclasses which provide extra functionality beyond simple data retrieval. """ -from copy import deepcopy from django.contrib.contenttypes import generic from django.core.exceptions import FieldError @@ -159,20 +158,9 @@ class UpdateQuery(Query): # We need to use a sub-select in the where clause to filter on things # from other tables. query = self.clone(klass=Query) - main_alias = query.tables[0] - if count != 1: - query.unref_alias(main_alias) - if query.alias_map[main_alias][ALIAS_REFCOUNT]: - alias = '%s0' % self.alias_prefix - query.change_alias(main_alias, alias) - col = query.model._meta.pk.column - else: - for model in query.model._meta.get_parent_list(): - for alias in query.table_map.get(model._meta.db_table, []): - if query.alias_map[alias][ALIAS_REFCOUNT]: - col = model._meta.pk.column - break - query.add_local_columns([col]) + alias = '%s0' % self.alias_prefix + query.change_alias(query.tables[0], alias) + self.add_local_columns([query.model._meta.pk.column]) # Now we adjust the current query: reset the where clause and get rid # of all the tables we don't need (since they're in the sub-select). |
