I have two tables having one to many relationship.
I want to find all rows of child where type is "abc"
class Parent(base):
__tablename__ = "parent"
id = Column("id", String, primary_key=True)
parent = relationship("Child", back_populates="child")
class Child(base):
__tablename__ = "child"
id = Column("id", Integer, primary_key=True)
name = Column(String)
tid = Column(String, ForeignKey("parent.id"))
child = relationship(Tenant, back_populates="parent")
type = Column(String)
return self.session.query(Parent.parent).filter_by(Parent.parent.type == "abc").all()
It gives me error as InstrumentedAttribute' object nor 'Comparator' object associated with Parent.parent has an attribute 'type'
And if i do
return self.session.query(Parent).filter(Parent.parent.any(Child.type == type)).all()
It gives me all rows with other types as well