- attached composites.py
MutableComposite doesn't work on inherited mappers
Context: A composite attribute is defined on a base mapper, and the class uses MutableComposite
for change tracking. An inheriting mapper also exists.
Problem: Modifying the composite on an instance of the inherited class doesn't trigger the appropriate change events.
As far as I can tell, this is caused in part because the various InstanceEvent
listeners at ext.mutable:MutableBase._listen_on_attribute
don't set propagate to True.
That problem is compounded by the fact that the InstanceEvents
in CompositeProperty:_setup_event_handlers
also don't set propagate to True. So even if MutableBase
caught the load event on the inherited mapper, the composite class wouldn't have been loaded into _sa_instance_state.
The easy fix seems to be to just allow these event listeners to propagate. I've attached a test case for the problem.
Comments (4)
-
Account Deleted -
repo owner "propagate"! (slaps forehead). yes that is absolutely correct and I'm totally psyched the system is clear enough that you could see this. I just need to add tests to the patch and we're good to go, thanks for finding this !!
-
repo owner - changed status to resolved
thanks for the patch ! added an extra check so that we don't create dupe events either. 5cac2468b6ef9e7ab4c0f3400477b697cd2d4ec6
-
repo owner - removed milestone
Removing milestone: 0.7.1 (automated comment)
- Log in to comment
Test case