Author: mtredinnick
Date: 2007-09-12 22:54:47 -0500 (Wed, 12 Sep 2007)
New Revision: 6120

Modified:
   django/branches/queryset-refactor/django/contrib/contenttypes/generic.py
   django/branches/queryset-refactor/django/db/models/sql/query.py
   django/branches/queryset-refactor/django/db/models/sql/where.py
Log:
Fixed deleting via generic relations.


Modified: 
django/branches/queryset-refactor/django/contrib/contenttypes/generic.py
===================================================================
--- django/branches/queryset-refactor/django/contrib/contenttypes/generic.py    
2007-09-13 03:17:46 UTC (rev 6119)
+++ django/branches/queryset-refactor/django/contrib/contenttypes/generic.py    
2007-09-13 03:54:47 UTC (rev 6120)
@@ -137,6 +137,11 @@
 
     def get_internal_type(self):
         return "ManyToManyField"
+
+    def db_type(self):
+        # Since we're simulating a ManyToManyField, in effect, best return the
+        # same db_type as well.
+        return None
         
 class ReverseGenericRelatedObjectsDescriptor(object):
     """

Modified: django/branches/queryset-refactor/django/db/models/sql/query.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/sql/query.py     
2007-09-13 03:17:46 UTC (rev 6119)
+++ django/branches/queryset-refactor/django/db/models/sql/query.py     
2007-09-13 03:54:47 UTC (rev 6120)
@@ -528,7 +528,8 @@
         self.where.add([alias, col, orig_field, lookup_type, value],
                 connection)
         if negate:
-            self.alias_map[last[0]][ALIAS_JOIN][JOIN_TYPE] = self.LOUTER
+            if last:
+                self.alias_map[last[0]][ALIAS_JOIN][JOIN_TYPE] = self.LOUTER
             self.where.negate()
 
     def add_q(self, q_object):
@@ -770,7 +771,7 @@
                         ContentType.objects.get_for_model(cls).id), AND)
             for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE):
                 where = WhereNode(self)
-                where.add((None, f.m2m_column_name(), None, 'in',
+                where.add((None, f.m2m_column_name(), f, 'in',
                         pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE]),
                         AND)
                 if w1:

Modified: django/branches/queryset-refactor/django/db/models/sql/where.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/sql/where.py     
2007-09-13 03:17:46 UTC (rev 6119)
+++ django/branches/queryset-refactor/django/db/models/sql/where.py     
2007-09-13 03:54:47 UTC (rev 6120)
@@ -87,7 +87,8 @@
             lhs = '%s.%s' % (table_alias, conn.ops.quote_name(name))
         else:
             lhs = conn.ops.quote_name(name)
-        field_sql = conn.ops.field_cast_sql(field.db_type()) % lhs
+        db_type = field and field.db_type() or None
+        field_sql = conn.ops.field_cast_sql(db_type) % lhs
 
         if isinstance(value, datetime.datetime):
             # FIXME datetime_cast_sql() should return '%s' by default.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to