Thanks, Tim.
Unfortunately I can't move past Django 1.7 yet -- dependencies. I've been marching my way up one revision at a time hopefully up to 1.9 as a way to keep the scope of what breaks under control as I move through each major revision and stabilize my project. Then I attack replacing dependencies.
I really think I've found a bug here ... which I hope to suggest a patch for and submit, hence the post to the developers channel, but I can go back to the users group for now... My recent experience with that list doesn't bode well, however, and I don't have high hopes with anyone there able to respond at the internals level I may need to track down the issue. I've almost rewritten my tests to just load raw sql, but if there is a bug here I'd like to help find it rather than work around/ignore it.
As I step through the code, it really looks like the _save_table() method in Model is trying to insert a row even though the object has already been restored/inserted. At the moment, I'm reproducing it with the auth.User Model.
I'm getting closer to seeing what is happening ....
I have a user, rich, which expects to be pk=1 per the fixture.
> /opt/perfcat/virtualenv-2.7.11/lib/python2.7/site-packages/django/db/models/base.py(686)_save_table()uest_by_build_workflow_fail ________
685 import ipdb; ipdb.set_trace()
--> 686 if not updated:
687 if meta.order_with_respect_to:
1
ipdb> self.__class__.objects.all()
[<User: rich>]
ipdb> self.__class__.objects.all()[0].id
5
ipdb> self.username
u'rich'
ipdb>
But In this particular run I'm currently tracing, rich is already in the db (as the only entry) as pk=5 (via fixture loading process). For one, this tells me the sequence generators aren't always resetting between fixture loads/tests.
So I think the code is trying to reassign it to pk=1.
We did drop into the update code,
ipdb> pk_set and not force_insert
True
But updated is False
So now it tries to drop into an insert, but it is going to get an Integrity error because username has to be unique.
Not sure what this means, yet, but my current step through looks like this:
ipdb>
IntegrityError: Integrit...sts.\n',)
> /opt/perfcat/virtualenv-2.7.11/lib/python2.7/site-packages/django/db/models/base.py(700)_save_table()
699 update_pk = bool(meta.has_auto_field and not pk_set)
--> 700 result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
701 if update_pk:
ipdb> update_pk
False
ipdb> meta.has_auto_field
True
ipdb> pk_set
True
ipdb>
...if we don't need to update the pk, and it is set .. why are we inserting it?
Walking through a second time with this knowledge ... and stepping into _do_update(),
I end up with filtered = base_qs.filter(pk=pk_val) being equal to [] because the entry in the db has a pk=5, and it is filtering for pk=1
So when return filtered._update(values) > 0 returns, it returns false because nothing was updated because the pk's didn't match.
Where I am stuck at now is not understanding how fixture loading manages the pks...
Rich