#24446: ATOMIC_REQUESTS add extra queries if the view was already in a
transaction
----------------------------------------------+--------------------
Reporter: diox | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
`ATOMIC_REQUESTS` documentation says it wraps the view in a transaction,
but since it actually only calls `atomic()`, it will actually use
savepoints if the view was already in a transaction when
`make_view_atomic()` is called.
This matters in tests, because `TestCase` opens a transaction by default.
With the old `TransactionMiddleware`, using a regular `TestCase` and
`assertNumQueries(0)` on views that did not make db queries of their own
worked, with `ATOMIC_REQUESTS` 2 queries are seen, breaking any tests
relying on this behavior.
Not sure whether to consider this a bug in the implementation or in the
documentation only. I certainly didn't expect all my `assertNumQueries()`
tests to fail when switching to `ATOMIC_REQUESTS`.
Attached is a patch demonstrating the issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/24446>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.570d038c7bc29a03f60e99bd4c755b2e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.