-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Versioning of one-to-many relationships #217
Comments
I have a similar behavior with a many to many relationship. The documentation seems to imply that relationships are supported and will produce a version of the parent object if you modify the list of associated objects, but I get the same behavior as @malikolivier. My parent object does not get a new version if I change the list of associated objects. However, a _version table is created for my secondary table that is used to associate both models of the many to many relationship. I am still trying to figure out if and how I can use this. @kvesteri, I think a bit of insight from you would help us a lot. |
Someone wrote RelatedVersioningPlugin that works pretty well, and creates new parent versions if child objects are updated. Maybe this helps for your case: The issue where I originally found this solution is /#35 |
I recently ran into this problem as well. For the simple case with Article and Category the plugin from @grakic did work quite well with some small modifications. So thanks for sharing that! |
Hello, I am trying to version a table with several one-to-many relationships. I am wondering if
sqlalchemy-continuum
is appropriate for this use case. Please let me know if I am wrong.Checking the doc
I started reading the documentation there: https://sqlalchemy-continuum.readthedocs.io/en/latest/version_objects.html#version-relationships
Here are the models used as examples in the doc:
An instance of
Article
has a one-to-many relationship to several instances ofCategory
. That seems to be a simple example of my use case.However, the doc uses the
category
keyword, so the example code crashes withTypeError: 'category' is an invalid keyword argument for Article
. The backref is a pluralcategories
.Writing a test program
In any case, I assumed this was a typo in the doc, and wrote the test program below. You can run the test program as long as you fire up a postgres server (e.g. with docker:
docker run -p 5432:5432 postgres:9.3-alpine
).I assume the last assertion to be verified.
However,
article.versions.count()
evaluates to1
. It seems that the relationship of the parent to the children is not versioned.Is the failure of this assertion expected behaviour?
Thank you very much for the feedback. I can contribute patches (at least to the doc once we confirmed what is expected behaviour) if necessary.
The text was updated successfully, but these errors were encountered: