Not sure what the correct title should be for this question. I have the following diagram:
- Questions have a one-to-many relationship with WorkItems.
- WorkItems have one, one (or one) relation to LineItems.
I am trying to create the following relationship between questions and work items
Matter.unbilled_work_items = orm.relation(WorkItem,
primaryjoin = (Matter.id == WorkItem.matter_id) and (WorkItem.line_item_id == None),
foreign_keys = [WorkItem.matter_id, WorkItem.line_item_id],
viewonly=True
)
It throws:
AttributeError: '_Null' object has no attribute 'table'
It seems that the second sentence in primaryjoin returns an object of type _Null, but it seems to be expecting something with the "table" attribute.
It seems like it should be pretty simple for me, will I miss something obvious?
Update
The answer was to change the line primaryjointo:
primaryjoin = "and_(Matter.id == WorkItem.matter_id, WorkItem.line_item_id == None)"