モデルは次のようになります(SQLAlchemyで):
Class Cell(Base):
__tablename__ = "cell"
id = Column(Integer)
name = Column(String)
Class Sample(Base):
__tablename__ = "cell"
id = Column(Integer)
factor_id = Column(Integer, ForeignKey("cell.id"))
cell = relationship(Cell, backref = 'sample', order_by = "Cell.id")
次のようにクエリを実行すると:
DBSession.query(Sample).filter(Sample.cell.name == "a_string")
次のような例外をスローします。
File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/attributes.py", line 139, in __getattr__
key)
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute 'name'
classのcell
フィールドにSample
というフィールドがないようname
です。次に、フィールドを使用Cell.name
してSample
クラスでクエリを実行するにはどうすればよいですか? cell
誰かがこれについてアイデアを持っていますか?
ありがとう!