#14415: Multiple aliases for one database: testing problems
---------------------------------------------+------------------------------
Reporter: shai | Owner: nobody
Status: new | Milestone: 1.3
Component: Testing framework | Version: 1.2
Resolution: | Keywords: multidb,
multiple databases, multiple aliases
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------+------------------------------
Comment (by shai):
I think Russell's approach is closer to home, but there are still
problems.
For starters, the patch has a "surface" problem of identifying databases
by their (Engine,Name) combination. The current docs about TEST_MIRROR
(http://docs.djangoproject.com/en/dev/topics/testing/#testing-master-
slave-configurations) show an example where this would be invalid (same
name, different hosts). To fix this, it seems, we would need a notion of
equivalence of settings -- `==` between dicts seems close enough for my
taste (if a user defines two !MySql databases, one with `PORT=''` and
another with `PORT='3306'`, I think they deserve the brouhaha they'll
get), but I may be wrong (different OPTIONS'es, for example, for different
transactional behavior, would seem legitimate).
But there is a deeper problem: solving the issue by directing the actual
connections -- not just fixing the creation/destruction issue -- would
cause the test process to have different transaction semantics. Consider:
{{{
def do_stuff(alias1, alias2):
with transaction.commit_manually(using=alias1)
# Make an invalid change in an object
m = MyModel.objects.get(pk=17)
m.fld = 'invalid'
m.save(using=alias1)
# Commit other changes, but not the invalid change
transaction.commit(using=alias2)
# Roll back the invalid change
transaction.rollback(using=alias1)
# Check the outcome
m1 = MyModel.objects.get(pk=17)
assert m1.fld1 != 'invalid'
}}}
This will work in production, but fail in testing under t14415.diff.
--
Ticket URL: <http://code.djangoproject.com/ticket/14415#comment:6>
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.