Move contains_aggregate from ExpressionNode to F
|Reported by:||jorgecarleitao||Owned by:||jorgecarleitao|
|Component:||Database layer (models, ORM)||Version:||1.6|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, ExpressionNode.contains_aggregate is calling self.name, which would raise an AttributeError
if it would be called by an instance of type ExpressionNode.
One way is to move it to F since it is the only subclass of ExpressionNode with an attribute name (and thus the intended class to be used).
This is not part of the Public API, but cleans ExpressionNode interface.
There is also a call of the form
in django/models/db/sql/query.py which could be simplified by this.
PR follows as comment.