#14068: Fixture loading issue with multi database setting ------------------------------------+--------------------------------------- Reporter: linovia | Owner: nobody Status: reopened | Milestone: Component: Serialization | Version: 1.2 Resolution: | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ------------------------------------+--------------------------------------- Changes (by russellm):
* component: Uncategorized => Serialization * stage: Unreviewed => Accepted Comment: Now I understand the error case. The rollback isn't the actual problem. The error here is that there is now a difference between the number of objects in a fixture and the number of objects that are loaded into a given database. If an error is found, it is rolled back because individual fixtures can be interdependent - objects in one fixture can reference objects in another. This means that if one fixture file has an error, the entire fixture setup must be called into question. If a fixture contains no objects, it is an error. This is well established Django behavior that exists because certain serializers don't distinguish between an unparseable fixture file and an empty fixture file. In order to catch the error case, we need to raise an error if a fixture exists, but is "empty". This doesn't cause an error in the test, but it does cause many error messages to be raised to stderr. The problem introduced by multi-db is that if your router has an allow_syncdb definition, it's possible for a fixture to have valid data, but none of those objects will be loaded into the database. However, the object count is only incremented when an object is actually loaded, not when it is parsed, so a fixture is reported as "empty" when no objects are loaded, rather than when no objects actually exist. The fix for this is fairly easy; I should be able to commit a patch shortly. As a side note; this problem can also be avoided using the per-database fixtures I described when I closed the ticket earlier. If a fixture nominates the fixture 'foo', and you provide 'foo.default.json' and 'foo.legacy.json', then only the relevant fixture will be loaded onto a given database. -- Ticket URL: <http://code.djangoproject.com/ticket/14068#comment:7> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.