#28944: Queryset cannot handle select_for_update and values/values_list at the 
same
time
-------------------------------------+-------------------------------------
               Reporter:  Thierry    |          Owner:  nobody
  Bastian                            |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 With any of my models, if I do the following:

 {{{
 model.objects.select_for_update(of=('self',)).values_list('pk')

 }}}

 I'm getting the following exception:


 {{{

 Traceback (most recent call last):
   File "<console>", line 2, in <module>
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/query.py", line 272, in __iter__
     self._fetch_all()
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/query.py", line 1179, in _fetch_all
     self._result_cache = list(self._iterable_class(self))
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/query.py", line 139, in __iter__
     return compiler.results_iter(tuple_expected=True,
 chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/sql/compiler.py", line 1014, in results_iter
     results = self.execute_sql(MULTI, chunked_fetch=chunked_fetch,
 chunk_size=chunk_size)
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/sql/compiler.py", line 1050, in execute_sql
     sql, params = self.as_sql()
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/sql/compiler.py", line 507, in as_sql
     of=self.get_select_for_update_of_arguments(),
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/sql/compiler.py", line 961, in
 get_select_for_update_of_arguments
     ', '.join(_get_field_choices()),
   File "/usr/local/filewave/python/lib/python3.6/site-
 packages/django/db/models/sql/compiler.py", line 928, in
 _get_field_choices
     for klass_info in klass_info.get('related_klass_infos', [])
 AttributeError: 'NoneType' object has no attribute 'get'
 }}}

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

Reply via email to