Querysets using F() expressions with time deltas are not cloned correctly.
|Reported by:||mrmachine||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.6|
|Severity:||Normal||Keywords:||queryset timedelta expression regression|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This appears to be a regression in 1.6. Possibly refs #16759.
Looks like expression nodes are no longer deep copied, so when a query that uses DateModifierNode is cloned, the second clone to be evaluated will generate an exception when the DateModifierNode tries to pop the timedelta off node.children.
Suspected fix is to persist the timedelta as an attribute on DateModifierNode expression in __init__ so we don't need to pop it off node.children when the node is evaluated.