#35025: Crash when attempting to order by array index from annotated ArrayAgg
-------------------------------+--------------------------------------
Reporter: Ben Nace | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.0
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 Ben Nace):
Full traceback:
{{{
Traceback (most recent call last):
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/contrib/postgres/fields/array.py", line 44, in model
return self.__dict__["model"]
~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'model'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/query.py", line 374, in __repr__
data = list(self[: REPR_OUTPUT_SIZE + 1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/query.py", line 398, in __iter__
self._fetch_all()
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/query.py", line 1926, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/query.py", line 208, in __iter__
for row in compiler.results_iter(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 1513, in results_iter
results = self.execute_sql(
^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 1549, in execute_sql
sql, params = self.as_sql()
^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 736, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup(
^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 85, in pre_sql_setup
order_by = self.get_order_by()
^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 459, in get_order_by
for expr, is_ref in self._order_by_pairs():
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 442, in _order_by_pairs
yield from self.find_ordering_name(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 1086, in
find_ordering_name
return [
^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/compiler.py", line 1087, in <listcomp>
(OrderBy(transform_function(t, alias), descending=descending), False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/query.py", line 1876, in transform
wrapped = previous(field, alias)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/sql/query.py", line 1847, in final_transformer
return field.get_col(alias)
^^^^^^^^^^^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/db/models/fields/__init__.py", line 542, in get_col
if alias == self.model._meta.db_table and (
^^^^^^^^^^
File "/home/bnace/python-envs/pmcs-50/lib/python3.11/site-
packages/django/contrib/postgres/fields/array.py", line 46, in model
raise AttributeError(
AttributeError: 'ArrayField' object has no attribute 'model'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35025#comment:2>
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/0107018c45d744c9-5c668a72-48b7-490a-9318-a8b9d5a8b5d0-000000%40eu-central-1.amazonses.com.