MutableComposite doesn't work on inherited mappers

Issue #2180 resolved
Former user created an issue

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)

  1. Mike Bayer repo owner
    • changed component to orm
    • marked as blocker
    • assigned issue to
    • changed milestone to 0.7.1

    "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 !!

  2. Log in to comment