Why does Django order by column number instead of column name?
I have this Django ORM code:
queryset.filter(filters).annotate(rank=SearchRank(vectors, search_query)).order_by('-rank').distinct()
and Django transforms this code into that sql:
SELECT
DISTINCT "model_1"."id",
...
...
...
ts_rank(
"model_2"."search_vector",
phraseto_tsquery(query)
) AS "rank"
FROM
"model_1"
INNER JOIN "model_2" ON (
"model_1"."id" = "model_2"."case_id"
)
WHERE
(
"model_2"."search_vector" @@ (
phraseto_tsquery(query)
)
)
ORDER BY
41 ASC
I cant understand why Django use 41(its a number of annotated rank column) instead of column name and i cant find any Django docs that describe this logic.
Django version: 5.0.2