Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[1.1.X] Really this time -- fixed #12721: Ensured objects with generi…

…c relations that use non-integer object ID fields can be deleted on PostgreSQL. Thanks much carljm for patch and Russ for review.

Remainder of r12353 from trunk, previous attempt only picked up the new tests.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 4043521 commit 75146a3d7b85580244ebeda36241396290a0de15 @kmtracey kmtracey committed
Showing with 7 additions and 3 deletions.
  1. +7 −3 django/db/models/sql/
10 django/db/models/sql/
@@ -58,15 +58,19 @@ def delete_batch_related(self, pk_list):
for f in cls._meta.many_to_many:
w1 = self.where_class()
+ db_prep_value = None
if isinstance(f, generic.GenericRelation):
from django.contrib.contenttypes.models import ContentType
- field =
- w1.add((Constraint(None, field.column, field), 'exact',
+ ct_field =
+ w1.add((Constraint(None, ct_field.column, ct_field), 'exact',
ContentType.objects.get_for_model(cls).id), AND)
+ id_field =
+ db_prep_value = id_field.get_db_prep_value
for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE):
where = self.where_class()
where.add((Constraint(None, f.m2m_column_name(), f), 'in',
- pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE]),
+ map(db_prep_value,
+ pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE])),
if w1:
where.add(w1, AND)

0 comments on commit 75146a3

Please sign in to comment.
Something went wrong with that request. Please try again.