mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +00:00
Fixed deleting via generic relations.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6120 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bb77006ade
commit
184a6435cd
@ -138,6 +138,11 @@ class GenericRelation(RelatedField, Field):
|
|||||||
def get_internal_type(self):
|
def get_internal_type(self):
|
||||||
return "ManyToManyField"
|
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):
|
class ReverseGenericRelatedObjectsDescriptor(object):
|
||||||
"""
|
"""
|
||||||
This class provides the functionality that makes the related-object
|
This class provides the functionality that makes the related-object
|
||||||
|
@ -528,7 +528,8 @@ class Query(object):
|
|||||||
self.where.add([alias, col, orig_field, lookup_type, value],
|
self.where.add([alias, col, orig_field, lookup_type, value],
|
||||||
connection)
|
connection)
|
||||||
if negate:
|
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()
|
self.where.negate()
|
||||||
|
|
||||||
def add_q(self, q_object):
|
def add_q(self, q_object):
|
||||||
@ -770,7 +771,7 @@ class DeleteQuery(Query):
|
|||||||
ContentType.objects.get_for_model(cls).id), AND)
|
ContentType.objects.get_for_model(cls).id), AND)
|
||||||
for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE):
|
for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE):
|
||||||
where = WhereNode(self)
|
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]),
|
pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE]),
|
||||||
AND)
|
AND)
|
||||||
if w1:
|
if w1:
|
||||||
|
@ -87,7 +87,8 @@ class WhereNode(tree.Node):
|
|||||||
lhs = '%s.%s' % (table_alias, conn.ops.quote_name(name))
|
lhs = '%s.%s' % (table_alias, conn.ops.quote_name(name))
|
||||||
else:
|
else:
|
||||||
lhs = conn.ops.quote_name(name)
|
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):
|
if isinstance(value, datetime.datetime):
|
||||||
# FIXME datetime_cast_sql() should return '%s' by default.
|
# FIXME datetime_cast_sql() should return '%s' by default.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user