Author: mtredinnick
Date: 2008-03-03 10:36:28 -0600 (Mon, 03 Mar 2008)
New Revision: 7190
Modified:
django/branches/queryset-refactor/django/db/models/sql/subqueries.py
Log:
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.
Modified: django/branches/queryset-refactor/django/db/models/sql/subqueries.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/sql/subqueries.py
2008-03-02 10:50:36 UTC (rev 7189)
+++ django/branches/queryset-refactor/django/db/models/sql/subqueries.py
2008-03-03 16:36:28 UTC (rev 7190)
@@ -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 @@
# 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).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---