﻿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
31632	Single queries without transaction do not follow AUTOCOMMIT	Filipe Pina	nobody	"The change in this PR https://github.com/django/django/pull/10448 removed the transaction from single queries in `Model.save_base`.

This broke an application we tried to upgrade from Django 2.1 to 2.2 last year as some operations were not persisted across DB connections.
We ended up rolling back but now, taking a better look, we pinned the change to this PR and the fact that our MySQL instance has the global `autocommit` set to 0.

As Django <2.2 always used transactions, this was never an issue. With this PR introduced, I believe this raises confusion:

* if Django AUTOCOMMIT defaults to True, we'd expect it to behave the same as DB autocommit global, even if it's not exactly the same.

As we need global autocommit to 0 to avoid careless manual operations on the DB (that involve related queries), we'll be working around it by using `OPTIONS init_command` with `set autocommit=1`.

If this is accepted as an issue, I'd like to leave some suggestions as well (and I won't mind doing the PR after one is chosen):

* MySQL global autocommit setting detected as database `feature`
* If said feature is `False` and `OPTIONS AUTOCOMMIT` is True, init connection with `set autocommit=1`

Or

* Always init connection with `set autocommit=OPTIONS[AUTOCOMMIT]`

Or, the most agnostic one, I suppose

* In `Model.save_base`, if AUTOCOMMIT=True, wrap single queries with transaction as well."	Bug	new	Database layer (models, ORM)	dev	Normal			Florian Apolloner Simon Charette Adam Johnson	Accepted	0	0	0	0	0	0
