I'm trying to track changes in many-to-many relationship using SQLAlchemy-Continuum package.
Unfortunately only changes made to simple fields like db.String are present in the changeset.
How to make changes made to relationship fields present in the changeset?
There are some fragments in the docs concerning many-to-many relationships but the documentation lacks examples. https://sqlalchemy-continuum.readthedocs.io/en/latest/api.html#sqlalchemy_continuum.relationship_builder.RelationshipBuilder.build_association_version_tables
Any help and examples will be appreciated.
I got the same issue, and I think I found a solution. What I did was first creating actual classes of the many to many tables:
This way you can actually get the
version_classof the junction table. In my case, if I add/delete an account, a record is added to theuser_versiontable, theuser_accountstable, but not in theaccounts table(which makes sense, because we didn't change an account).For SQLAlchemy Continuum this seems hard to actually join the right tables. I guess it somehow makes sense, because when do you need a version table and when not.
What you can do, is building a query yourself now you can get the version_class of the junction table. Obviously you could write your own query and just perform a SELECT query, but I like to keep using the ORM as much as possible.
A dirty solution: