#17168 closed Cleanup/optimization (fixed)
Transaction middleware only creates transaction for default database
Reported by: | Owned by: | David Winterbottom | |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The current implementation of django.middleware.TransactionMiddleware does not create a transaction for each database defined in the DATABASES setting, only the one defined by DEFAULT_DB_ALIAS. You can see this quite clearly by reading the source of: -
https://code.djangoproject.com/browser/django/trunk/django/db/utils.py.
Shouldn't the middleware manage a transaction for each database defined in the DATABASES setting?
Happy to provide tests and patch if this makes sense - I just wanted to check this wasn't a design decision first. I did email the mailing list with this question but no responses received:
Attachments (1)
Change History (12)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Component: | Database layer (models, ORM) → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Since we can't enforce transactional behavior across databases, it's more reasonable for the transaction middleware to manage only the default database. Otherwise, we'd risk creating unreasonable expectations.
Therefore, and in order to avoid a backwards incompatible change, I propose to document the current behavior (in topics/db/transactions.txt).
follow-up: 4 comment:3 by , 13 years ago
That seems like the right solution to me. Would you like me to make the appropriate edits to the docs and send a patch? Or is there a different process for documentation writing?
comment:4 by , 13 years ago
Replying to codeinthehole:
Would you like me to make the appropriate edits to the docs and send a patch?
Yes, that's the next step.
You can assign the ticket to yourself when you start working on it.
comment:5 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 13 years ago
Needs documentation: | set |
---|
comment:7 by , 13 years ago
Has patch: | set |
---|---|
Needs documentation: | unset |
Resolution: | → fixed |
Status: | assigned → closed |
comment:8 by , 13 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
It's not fixed until a code or doc change has been checked into the repo.
comment:9 by , 13 years ago
Should the docs also clarify whether this transaction applies to the test database?
comment:10 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Source link should be https://code.djangoproject.com/browser/django/trunk/django/middleware/transaction.py