#33309: DISTINCT ON fails with mixed-case field aliases
-------------------------------------+-------------------------------------
Reporter: Christophe Thiery | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | 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 Mariusz Felisiak):
This should be quite easy to fix:
{{{
diff --git a/django/db/models/sql/compiler.py
b/django/db/models/sql/compiler.py
index 73cf2c5f62..69a2d9298f 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -754,7 +754,7 @@ class SQLCompiler:
targets, alias, _ = self.query.trim_joins(targets, joins,
path)
for target in targets:
if name in self.query.annotation_select:
- result.append(name)
+ result.append(self.connection.ops.quote_name(name))
else:
r, p = self.compile(transform_function(target,
alias))
result.append(r)
}}}
Would you like to prepare a patch? (a regression test in
`tests/distinct_on_fields/tests.py` is required).
--
Ticket URL: <https://code.djangoproject.com/ticket/33309#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/078.bb720b907d9037c5c0a22a7c6d6c5c46%40djangoproject.com.