An update. I've had some success with refactoring Aggregates as 
ExpressionNodes. The aggregates test suite is now passing, but I still have 
some failures with aggregates_regress test suite. The refactoring should 
allow behaviour like below possible:

Model.objects.annotate(total_time=Sum( F('timer1') + F('timer2') / 2 ))

An issue that the first patch ran into was deducing the python return types 
since there was no field type to "attach" to. I've introduced some basic 
behaviour that checks that all nested expressions are the same type, and 
then grabs the first column type. If the types are different, an error is 
thrown. To get around this, I introduced a field_type parameter to 
aggregates:

Model.objects.annotate(total_time=Sum( F('timer1') + F('timer2') / 2, 
field_type=FloatField() ))

Feedback appreciated and welcome.

 My plan is:

- Make sure all existing tests pass
- Create a bunch of new tests that stress "complex annotations/aggregations"
- Figure out how to allow F() in annotations. Annotation currently accepts 
arbitrary expressions, but does nothing with them.
- Clean up anything that looks too messy

I think I will be done with the above list inside the next 7 days. I would 
welcome help (or pointers) on testing against GIS once I'm done, as that 
should be all that's left to tackle.

- Josh

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/9c16ccdc-9d0d-4804-91ba-550de6148c1a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to