Fixed #9804 -- Corrected the introspection of sequence names. This was causing problems when flushing tables that had many-to-many relations through an inherited table. Thanks to jdimov for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10552 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0fec0a5d70
commit
fd3ee7d786
|
@ -193,9 +193,9 @@ class ReverseGenericRelatedObjectsDescriptor(object):
|
|||
rel_model = self.field.rel.to
|
||||
superclass = rel_model._default_manager.__class__
|
||||
RelatedManager = create_generic_related_manager(superclass)
|
||||
|
||||
|
||||
qn = connection.ops.quote_name
|
||||
|
||||
|
||||
manager = RelatedManager(
|
||||
model = rel_model,
|
||||
instance = instance,
|
||||
|
@ -285,6 +285,7 @@ class GenericRel(ManyToManyRel):
|
|||
self.limit_choices_to = limit_choices_to or {}
|
||||
self.symmetrical = symmetrical
|
||||
self.multiple = True
|
||||
self.through = None
|
||||
|
||||
class BaseGenericInlineFormSet(BaseModelFormSet):
|
||||
"""
|
||||
|
|
|
@ -530,7 +530,10 @@ class BaseDatabaseIntrospection(object):
|
|||
break # Only one AutoField is allowed per model, so don't bother continuing.
|
||||
|
||||
for f in model._meta.local_many_to_many:
|
||||
sequence_list.append({'table': f.m2m_db_table(), 'column': None})
|
||||
# If this is an m2m using an intermediate table,
|
||||
# we don't need to reset the sequence.
|
||||
if f.rel.through is None:
|
||||
sequence_list.append({'table': f.m2m_db_table(), 'column': None})
|
||||
|
||||
return sequence_list
|
||||
|
||||
|
|
|
@ -35,6 +35,22 @@ class Group(models.Model):
|
|||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
# A set of models that use an non-abstract inherited model as the 'through' model.
|
||||
class A(models.Model):
|
||||
a_text = models.CharField(max_length=20)
|
||||
|
||||
class ThroughBase(models.Model):
|
||||
a = models.ForeignKey(A)
|
||||
b = models.ForeignKey('B')
|
||||
|
||||
class Through(ThroughBase):
|
||||
extra = models.CharField(max_length=20)
|
||||
|
||||
class B(models.Model):
|
||||
b_text = models.CharField(max_length=20)
|
||||
a_list = models.ManyToManyField(A, through=Through)
|
||||
|
||||
|
||||
__test__ = {'API_TESTS':"""
|
||||
# Create some dummy data
|
||||
>>> bob = Person.objects.create(name='Bob')
|
||||
|
@ -176,4 +192,8 @@ doing a join.
|
|||
>>> bob.group_set.filter(membership__price=50)
|
||||
[<Group: Roll>]
|
||||
|
||||
## Regression test for #9804
|
||||
# Flush the database, just to make sure we can.
|
||||
>>> management.call_command('flush', verbosity=0, interactive=False)
|
||||
|
||||
"""}
|
||||
|
|
Loading…
Reference in New Issue