So, after hacking away a little bit yesterday, I came to the same conclusion that Anssi did back when the first PR was sent. Namely, that the ExpressionNode <-> SQLEvaluator structure seems overly complex, and makes it difficult to create custom "ExpressionNodes".
To build a custom Expression, one needs to: - Subclass ExpressionNode - Build in SQL into the backend (sometimes) - Modify SQLEvaluator (or create a new one) - Modify sql/query to learn about the different types of ExpressionNodes I think it'd be better if SQLEvaluator was dropped altogether, and ExpressionNode was given the evaluator responsibilities. In this world, creating a custom Expression would look like: - Subclass ExpressionNode - The subclass contains SQL for each supported backend (and has access to the 'connection' instance) - sql/query asks ExpressionNode to evaluate itself Provided that ExpressionNode (or one of its subclasses) had the appropriate methods, it would allow library authors to create their own custom functions. #11305 (Conditional Aggregates) could then be implemented quite easily, without touching the rest of the stack. So this is what I'm going to attempt first. I'll "merge" the functions of SQLEvaluator and ExpressionNode, and see how far along that gets me. If that turns out to simplify the handling of F(), then it should be equally useful when refactoring Aggregate as an ExpressionNode. As a POC, I'll also implement a version of Conditional Aggregates to confirm the API. Now, this is definitely more complex than porting nateb's original changes, but it's probably going to be a more simplified implementation. As such, my hopes for inclusion in 1.7 are probably far-fetched. Will report back when I've got something a little more concrete to talk about. Regards, - 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/b4d333f5-0184-4b2b-9946-73b365144306%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.