Code

Changes between Initial Version and Version 2 of Ticket #19512


Ignore:
Timestamp:
12/31/12 11:53:52 (16 months ago)
Author:
aaugustin
Comment:

The ORM isn't intended to be a complete abstraction to SQL; it's just a shortcut for the most common queries. Dropping to raw SQL (or .extra if you really need to) isn't a violation of the ORM concept; it's part of the ORM concept — at least, as understood in Django.

The docs talk about aggregating annotations, but not about re-annotating annotations. I'm not sure it's possible to support it while keeping the code complexity under control.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #19512

    • Property Patch needs improvement unset
    • Property Needs tests unset
    • Property Needs documentation unset
    • Property Type changed from Uncategorized to New feature
    • Property Triage Stage changed from Unreviewed to Design decision needed
  • Ticket #19512 – Description

    initial v2  
     1{{{ 
    12from django.db.models import Count, Sum, F 
    23 
     
    56               .annotate(total=F('a_count')+F('b_count')) \ 
    67               .order_by('total') 
     8}}} 
    79 
    8 This query is going to raise '''AttributeError: 'ExpressionNode' object has no attribute 'split'''' 
     10This query is going to raise `AttributeError: 'ExpressionNode' object has no attribute 'split'` 
    911 
    1012I don't find any method in django ORM to support such kind of operations (in which two fields are involved).