-
Notifications
You must be signed in to change notification settings - Fork 66
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
api: addition of class model support #201
Conversation
a6c42f3
to
640b9b8
Compare
@jma nice! I didn't check in details the changes yet, but I see that I guess this is a major breaking change and all modules need to updated at the same time. Did you think about this too? (ping @lnielsen @egabancho @slint ) |
@ntarocco it should not change anything in other packages, it will just allow to create a new class with an other table name if someone want to do it. |
@jma I think the main problem comes when other modules use this model directly for something, i.e. invenio-records-files, in this cases if you try and use a different table for your records I am not sure the foreign keys will work (perhaps I am missing something here) |
I agree with you, but before going ahead with this solution and merge and release, I would try to think how we resolve the references for ForeignKeys/queries of other modules, because we might have to go a little bit further with the implementation. I am thinking that if I want to use this code to have another table for records, I am still stuck with files references for example. @egabancho already commented a similar thing, ping @lnielsen and @slint if they have other comments. |
@ntarocco form my point of view, it is very important to find a solution to split records in different tables for several reasons:
I tried several approaches as describe in the documentation, but I don't find any solution by derivating the I understand you point about |
@jma All your points are valid and have been discussed in a similar fashion IRL in the past. It is indeed important to address these issues, we have encountered them in Zenodo and even had operational issues that were made worse by the fact that We can merge this PR since indeed it keeps things nice and tidy in terms of backward and cross-module compatibility (i.e. nothing will break even if we merge and release a new version). I guess our main concern is about eventual next steps (in this module and friends) and how to plan them out to avoid shooting ourselves in the foot and end up in situations similar to this one, where a somewhat "simple" decision to create a single JSON-blob We're all willing/expecting to do this anyways in one way or another for the sake of new and better features, but it's easier to accept and embrace if we are all aligned with it and understand the complications and potential solutions. |
invenio_records/api.py
Outdated
@@ -137,6 +137,8 @@ def dumps(self, **kwargs): | |||
class Record(RecordBase): | |||
"""Define API for metadata creation and manipulation.""" | |||
|
|||
class_model = RecordMetadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that critical, though naming-wise I'm a bit conflicted about class_model
... One would say it's "the model of the class" (thus class_model
sounds good), though I feel that something like model_class
/model_cls
would better express the "internal"/"programmatic" nature and use of the field (cc @inveniosoftware/architects).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for model_cls
It would be nice to include a docstring and add a section to docs when to use it.
d269b49
to
e442626
Compare
@ntarocco We need a v1.1 release before merging so this should go into a v1.2 |
@jma https://travis-ci.org/inveniosoftware/invenio-records/jobs/514564803#L1060 is failing probably because of werkzeug update. Could you please check it? Otherwise the PR is ready to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice generalisation 👍
Q: Is there a way to add a table to ignore list in invenio-db
?
* closes: inveniosoftware#191 Signed-off-by: Johnny Mariéthoz <johnny.mariethoz@rero.ch>
Signed-off-by: Johnny Mariéthoz johnny.mariethoz@rero.ch