#32693: case sensitive issue on subquery aliases generated
-------------------------------------+-------------------------------------
Reporter: ecogels | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: subquery | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
It's not an issue in practice because SQLite, MySQL, and PostgreSQL all
fold ambiguous aliases to lower case, try the following in their
respective shell
SQlite and Postgres
{{{#!sql
SELECT "subquery"."col" FROM (SELECT 1 AS Col) subquery;
}}}
MySQL
{{{#!sql
SELECT `subquery`.`col` FROM (SELECT 1 AS Col) subquery;
}}}
Oracle folds uppercase (as per the SQL standard) though but the
[https://github.com/django/django/blob/187118203197801c6cb72dc8b06b714b23b6dd3d/django/db/models/sql/compiler.py#L651-L655
quoted usage] happens to
[https://github.com/django/django/blob/187118203197801c6cb72dc8b06b714b23b6dd3d/django/db/backends/oracle/operations.py#L331-L342
uppercase the identifier] which transforms the query to
Oracle
{{{#!sql
SELECT "SUBQUERY"."COL" FROM (SELECT 1 AS Col) subquery;
}}}
Which also works.
I think we should still perform a cleanup here for the sake of consistency
with two adjustments:
1. Always generate `col` alias in lowercase
2. Make sure to always call `connection.ops.quote_name` on the generated
alias
Both of these changes should be made to
[https://github.com/django/django/blob/187118203197801c6cb72dc8b06b714b23b6dd3d/django/db/models/sql/compiler.py#L557
the first instance you pointed at]. Do you feel comfortable submitting a
Github PR that does that?
--
Ticket URL: <https://code.djangoproject.com/ticket/32693#comment:1>
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/065.7fd0df20627fd8cef74de87fdbf000e0%40djangoproject.com.