#31632: Single queries without transaction do not follow AUTOCOMMIT
-------------------------------------+-------------------------------------
     Reporter:  Filipe Pina          |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 > Plus statements like
 ​https://docs.djangoproject.com/en/3.0/topics/db/transactions/#django-s
 -default-transaction-behavior are confusing as it states uses autocommit
 by default but apparently doesn't, because single queries are not
 committed anymore, unless the database (not Django) commits them.

 The documentation should also state that ''Django assumes that the
 database is configured to be in auto-commit mode'' just like it expects
 isolation level to be `REPEATABLE READ`.

 > In that sense Django should execute set autocommit=1 or whatever the
 equivalent is because otherwise further assumptions will not hold true…

 Something that puzzles me is that Django already sets `autocommit=1`
 
[https://github.com/django/django/blob/3259983f569151232d8e3b0c3d0de3a858c2b265/django/db/backends/base/base.py#L201
 on connection initialization] unless `DATABASES_AUTOCOMMIT=False` which
 the reporter explicitly stated they didn't do. Not sure what I'm missing
 here but even if their server is configured to have `autocommit=0` the
 connections created by Django should all be in `autocommit=1` in this
 case.

 Filipe, if you open a Django shell against for your project and input
 `from django.db import connection;print(connection.get_autocommit())` what
 do you get?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31632#comment:4>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.9ccd8dde26791b2de41adb3893b6d76b%40djangoproject.com.

Reply via email to