VForWaTer / metacatalog

Modular metadata management platform for environmental data.
https://vforwater.github.io/metacatalog
GNU General Public License v3.0
3 stars 1 forks source link

fix nm relation Entry-Keyword #244

Closed mmaelicke closed 1 year ago

mmaelicke commented 1 year ago

closes #236

@AlexDo1 , the relationship is fixed and Entry.keywords actually returns a list of metacatalog.models.Keyword instances. This fix so far also breaks all methods on Entry that access the keywords and possibly also the API functions accessing keywords, as these all operated on the association objects. I will go through the code and fix them one-by-one and hope that I find all references.

mmaelicke commented 1 year ago

@AlexDo1 this is ready for review. I deprecated all these keyword_* functions and implemented one Entry.keyword_list() -> List[str] function, which returns a plain list of full paths for all keywords, except the one associated to the variable. In the future, we prefer to call the to_dict method of the Keyword directly, and not buried in some Entry method.

A sample implementation of that is in Entry.to_dict. With the new association, the keyword dicts can simply be accessed as:

entry: Entry

[kw.to_dict() for kw in entry.keywords]

For me that feels like a much simpler implementation.

mmaelicke commented 1 year ago

Very nice, thanks!

Would we, in theory, need a database revision for that? We didn't really change the content of the database but only the relationships in our SQLAlchemy models, so I guess no? :thinking:

No we don't need a revision for this, as this is only reflected on the Python side. No foreign keys have been changed.