#32693: case sensitive issue on subquery aliases generated
-------------------------------------+-------------------------------------
Reporter: ecogels | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords: subquery
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
When generating aliases for subqueries, django uses 2 different cases:
'Col%d'
https://github.com/django/django/blob/187118203197801c6cb72dc8b06b714b23b6dd3d/django/db/models/sql/compiler.py#L557
and 'col%d'
https://github.com/django/django/blob/187118203197801c6cb72dc8b06b714b23b6dd3d/django/db/models/sql/compiler.py#L651
Here is a concrete example, using --v 2 --debug-sql
queries.tests.Queries6Tests.test_distinct_ordered_sliced_subquery_aggregation.
SELECT COUNT(*) FROM (SELECT "subquery".**"col1"**, "subquery"."col2",
"subquery"."col3", "subquery"."col4" FROM (SELECT DISTINCT
"queries_tag"."id" AS **Col1**, "queries_tag"."name" AS Col2,
"queries_tag"."parent_id" AS Col3, "queries_tag"."category_id" AS Col4,
"queries_namedcategory"."name" AS Col5 FROM "queries_tag" LEFT OUTER JOIN
"queries_namedcategory" ON ("queries_tag"."category_id" =
"queries_namedcategory"."dumbcategory_ptr_id") ORDER BY
"queries_namedcategory"."name" ASC LIMIT 3) subquery) subquery;
This would fail on a database with case sensitive column names.
It will be trivial to fix if deemed necessary.
--
Ticket URL: <https://code.djangoproject.com/ticket/32693>
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/050.29fc9b8c867060fc0031e1a231a73211%40djangoproject.com.