#35093: Handling Special Characters in ORM Annotate Aliases
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  segalzeyalz                        |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  3.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  ORM, annotations
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Encountered a limitation in Django ORM when using annotations with column
 aliases containing special characters like apostrophes or spaces. For
 example:

 Model.objects.annotate(**{"VALUE_WITH_APOSTROPHE'-2":
 Count('attribute_name')})

 This generates a ValueError: Column aliases cannot contain whitespace
 characters. While SQL syntax allows such aliases, Django ORM does not,
 leading to a lack of flexibility and unexpected errors in ORM
 interactions.

 Impact:
 - Causes flow errors during higher-level ORM interactions.
 - Limits application of ORM to real-world naming use cases.
 - Decreases reliability and user experience when special characters are
 present.

 Proposed Solution:
 Enhance the ORM's handling of annotate aliases to allow common special
 characters, aligning with real-world naming scenarios. Options could
 include:
 - Automatically transforming aliases before passing to SQL.
 - Configurable rules for "safe" special characters at the ORM level.

 Interested in community and maintainers' perspectives on potential
 solutions to provide ORM-level flexibility for end-user applications.
 Looking forward to contributing to the discussion and development of this
 feature.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35093>
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/0107018ce4ae2dba-f0ccc811-1616-4622-bdf1-785725424d27-000000%40eu-central-1.amazonses.com.

Reply via email to