I’m trying to get my head around the “Discriminator on association” example shipped with SQLAlchemy, which defines HasAddresses mixin so each model subclassing HasAddresses magically gets an addresses attribute, which is a collection to which Address objects can be added. The linking is performed through an intermediate table so at the first glance the relationship looks like many-to-many, I hoped to be able to have multiple Addresses linked to a Customer, AND also multiple Customers and Suppliers linked to an Address.
The Address model, however, is set up in such a way that it has a single parent attribute which can only reference a single object. So, in the example, an Address can only be linked to a single Customer or Supplier.
How do I modify that example so Address is able to back-reference multiple parent objects?
we can modify sqlalchemy/examples/generic_associations/table_per_association.py to add a named backref to Address, then a @property which rolls up all backrefs created.