summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-09-13 03:54:47 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-09-13 03:54:47 +0000
commit184a6435cd3e1945823ccb9e7692f3c6e3875411 (patch)
tree6788dcbc84d9b44f60fa78e297e18278296b0f52 /django/db/models/sql
parentbb77006adefae2db3fae0213779fc30254c1b98f (diff)
Fixed deleting via generic relations.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6120 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py5
-rw-r--r--django/db/models/sql/where.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 97b4ee1a47..6302416b41 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -528,7 +528,8 @@ class Query(object):
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 @@ class DeleteQuery(Query):
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:
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 7c27fc92b3..5995f83486 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -87,7 +87,8 @@ class WhereNode(tree.Node):
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.