pyeve / eve-sqlalchemy

SQLAlchemy data layer for Eve-powered RESTful APIs
http://eve-sqlalchemy.readthedocs.io
Other
234 stars 70 forks source link

Document versioning does not work #182

Open ktal90 opened 6 years ago

ktal90 commented 6 years ago

Document versioning, as described in Eve, does not work in Eve-SQLAlchemy. I tried this with the "simple" example by setting VERSIONING = true in settings.py. The app starts fine, but when I PUT against an item, I receive an error:

"message": "An exception occurred: 'People_versions'"

I messed around with the models and tables and am able to get the app accepting PUTs and PATCHes. The people_versions table will even populate on these actions. However, the issue that I run into then is that on GET for the updated item, the _version and _latest_version attributes are left unchanged (always "1").

Here is my version of the "simple" app with my hacks at getting this to work: https://github.com/ktal90/eve-sqlalchemy/tree/versioning_debug/eve_sqlalchemy/examples/versioning. Notice the changes compared to "simple" in settings.py and tables.py.

My next step is to compare how Eve versions in its "update" and "replace" methods to how Eve-SQLAlchemy handles this (or doesn't, which is what I suspect). Initial ideas/guidance would be much appreciated!

dkellner commented 6 years ago

Thanks for looking into this!

It seems that we're not currently running Eve's test cases for versioning at all. One first step could be to include them and see where they break.

You're already writing example code, which is great. You then can easily use the models in that example code to write an integration test, too. This would be another way to make sure it will not break again someday.

ktal90 commented 6 years ago

Thanks for the suggestions @dkellner ! I will check this out and update this ticket with my findings.