#36398: select_for_update(of=...) ignores "self" when using values_list() when 
not
selecting a column from the model
-------------------------------------+-------------------------------------
     Reporter:  OutOfFocus4          |                    Owner:
                                     |  JakeWalson
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by OutOfFocus4):

 Replying to [comment:8 Sarah Boyce]:
 > This won't be resolved until someone fixes the ticket, so there's no
 need to confirm with each release that this is still open (that the ticket
 is open is enough to confirm that this should still be an open issue)
 >
 > We also wouldn't backport a fix into 5.2 unless this is a bug that was
 introduced by 5.2. If you believe this was introduced in 5.2, you can do a
 git bisect to find the commit that introduces this issue. This would
 increase the priority of the ticket.

 I can replicate this issue with older versions of Django, so I don't
 believe this was introduced in 5.2.

 I believe I may have found (part of) the cause. From
 
https://github.com/django/django/blob/d82f25d3f0f4eb7be721a72d0e79a8d13d394d32/django/db/models/sql/compiler.py#L1432C1-L1443C56:

 {{{#!python
         def _get_first_selected_col_from_model(klass_info):
             """
             Find the first selected column from a model. If it doesn't
 exist,
             don't lock a model.

             select_fields is filled recursively, so it also contains
 fields
             from the parent models.
             """
             concrete_model = klass_info["model"]._meta.concrete_model
             for select_index in klass_info["select_fields"]:
                 if self.select[select_index][0].target.model ==
 concrete_model:
                     return self.select[select_index][0]
 }}}

 If the docstring is to be believed, only tables whose columns are in the
 query's `SELECT` can be locked. I do not know enough about Django's
 internals to know if that is what the function actually does.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36398#comment:9>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070199104dcf47-e404a3c8-59c0-4555-bc4e-e6d7ee511335-000000%40eu-central-1.amazonses.com.

Reply via email to