Reputation: 5721
I have three classes: PurchaseOrder, PurchaseOrderLine, Item
PurchaseOrder children are PurchaseOrderLine which is related to Item.
pos = DBSession.query(m_po.PO).filter(or_(
m_po.PO.number == query,
m_po.POLine.item.code == query
)).join(m_po.POLine).join(m_im.Item)
Gives me ...
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute 'code'
Upvotes: 0
Views: 316
Reputation: 76992
Assuming:
m_po = PurchaseOrder
m_pol = PurchaseOrderLine
m_it = Item
and that the relationships are defined between those, you should be able to achieve this as following (not tested):
pos = (DBSession.query(m_po.PO).
join(m_pol, m_po.POLine).
join(m_it, m_pol.Items).
filter(or_(
m_po.PO.number == query,
m_it.code == query,
))
Note: i am somewhat confused what m_im
in your code stands for.
Upvotes: 1