[sqlalchemy] Re: Consolidate multiple one-to-one into a list

2020-04-21 Thread Jonathan Vanasco
Assuming you are using declarative, this is okay ( https://docs.sqlalchemy.org/en/14/orm/mapping_api.html?#sqlalchemy.orm.Mapper ) Note this line: A class which was mapped by the sqlalchemy.ext.declarative

[sqlalchemy] Re: Consolidate multiple one-to-one into a list

2020-04-21 Thread Jens Troeger
So, here’s what I’m experimenting with and it seems to work: @property def children(self): children = (getattr(self, r.key) for r in self.__mapper__.relationships if r.target.name == "child") return [c for c in children if c is not None] I’m not sure if this is the