#35643: Regression in Queryset sequence of value, annotate, order, value
-------------------------------------+-------------------------------------
Reporter: Gert Van Gool | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* owner: (none) => Simon Charette
* severity: Normal => Release blocker
* status: new => assigned
Comment:
{{{#!python
======================================================================
ERROR: test_values_count_value
(queries.tests.Queries1Tests.test_values_count_value)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/charettes/Workspace/django/django/db/models/sql/query.py",
line 1889, in transform
return self.try_transform(wrapped, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/charettes/Workspace/django/django/db/models/sql/query.py",
line 1426, in try_transform
raise FieldError(
django.core.exceptions.FieldError: Unsupported lookup 'count' for
AutoField or join on the field not permitted, perhaps you meant contains?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/charettes/Workspace/django/tests/queries/tests.py", line
1389, in test_values_count_value
self.assertSequenceEqual(
File
"/usr/local/Cellar/pyt...@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/unittest/case.py",
line 1003, in assertSequenceEqual
len1 = len(seq1)
^^^^^^^^^
File "/Users/charettes/Workspace/django/django/db/models/query.py", line
363, in __len__
self._fetch_all()
File "/Users/charettes/Workspace/django/django/db/models/query.py", line
1909, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/charettes/Workspace/django/django/db/models/query.py", line
268, in __iter__
for row in compiler.results_iter(
^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
1531, in results_iter
results = self.execute_sql(
^^^^^^^^^^^^^^^^^
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
1567, in execute_sql
sql, params = self.as_sql()
^^^^^^^^^^^^^
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
756, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup(
^^^^^^^^^^^^^^^^^^^
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
85, in pre_sql_setup
order_by = self.get_order_by()
^^^^^^^^^^^^^^^^^^^
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
480, in get_order_by
for expr, is_ref in self._order_by_pairs():
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
463, in _order_by_pairs
yield from self.find_ordering_name(
^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/charettes/Workspace/django/django/db/models/sql/compiler.py", line
1109, in find_ordering_name
(OrderBy(transform_function(t, alias), descending=descending), False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/charettes/Workspace/django/django/db/models/sql/query.py",
line 1893, in transform
raise last_field_exception
File "/Users/charettes/Workspace/django/django/db/models/sql/query.py",
line 1866, in setup_joins
path, final_field, targets, rest = self.names_to_path(
^^^^^^^^^^^^^^^^^^^
File "/Users/charettes/Workspace/django/django/db/models/sql/query.py",
line 1771, in names_to_path
raise FieldError(
django.core.exceptions.FieldError: Cannot resolve keyword 'count' into
field. Choices are: dumbcategory_ptr, dumbcategory_ptr_id, id, name, tag
}}}
Bisected to b0ad41198b3e333f57351e3fce5a1fb47f23f376.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35643#comment:1>