#34346: QuerySet ordered by annotation with name used by select_related() field
crashes with AmbiguousColumn.
-------------------------------------+-------------------------------------
Reporter: henribru | Owner: Mohamed
| Nabil Rady
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Release blocker | 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 Mohamed Nabil Rady):
I am not that familiar with the codebase so I can't make any promises, so
I guess it's for the best to leave another person with the bug.
I found out the issue happens because before the regression in
`django.db.models.sql.compiler.SQLCompiler.get_order_by` would return a
`Col` object, but it now it returns `Ref` object which points to the
correct column but its `as_sql` method returns the annotated value name
instead of the unambiguous SQL.
I am not sure to what extent is this information useful or if it's
obvious, but as I said I am not that familiar with the codebase, and I am
not sure what `Ref` objects are responsible for.
--
Ticket URL: <https://code.djangoproject.com/ticket/34346#comment:5>
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/0107018661a4d83f-df112607-b6be-48ac-85f6-a506cdcaddb6-000000%40eu-central-1.amazonses.com.