﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24446	ATOMIC_REQUESTS add extra queries if the view was already in a transaction	Mathieu Pillard	nobody	"`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."	Bug	new	Database layer (models, ORM)	dev	Normal				Accepted	0	0	0	0	0	0
