#24880: Error on all db backends if `select_for_update` is run outside of a
transaction
-------------------------------+--------------------------------------
     Reporter:  suligap        |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  1              |      Needs documentation:  1
  Needs tests:  0              |  Patch needs improvement:  1
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by shaib):

 The case I have in mind, mostly, is a project on Sqlite using generic
 code, where the generic code calls `select_for_update()`. Such code,
 whether it uses transactions or not, has been essentially bogus but
 allowed to run anyway, since the time `select_for_update()` was
 introduced. I expect that this things happen in the wild, because I
 suspect that people who actually use Sqlite are more likely to be using
 the default autocommit mode.

 My point of view is, essentially: If we're going for correctness on
 Sqlite, `select_for_update()` there should be an unconditional error. If
 we aren't, then the main value of the suggestion here is, to catch on
 Sqlite something which is only a problem elsewhere (as on Sqlite,
 `select_for_update()` is no safer in a transaction than out of it). Is
 this gain worth breaking code that works (for a lenient enough definition
 of "works"), and compromising the simple model that says "on Sqlite
 `select_for_update()` does nothing"?

 As I hinted above, the original decision to keep `select_for_update()`
 passing silently when run out of transactions on Sqlite was made on the
 django-developers mailing list; I think if we're going to change it,
 that's the place to do that as well.

--
Ticket URL: <https://code.djangoproject.com/ticket/24880#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 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/065.b493fce4ca2995bd34de55fb7f216ee5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to