Skip to content Skip to sidebar Skip to footer

SQLAlchemy InvalidRequestError When Using Composite Foreign Keys

My table relationships in SQLAlchemy have gotten quite complex, and now I'm stuck at this error no matter how I configure my relationship. I'm a bit new to SQLAlchemy so I'm not su

Solution 1:

After a lot of searching I finally found a really simple answer in this answer to another question.

All I did was add 'inherit_condition': (id == Node.id) to the mapper in the classes that inherit from Node so that it looked like this:

__mapper_args__ = {'polymorphic_identity': 'Information',
                   'inherit_condition': (id == Node.id)}

And it works perfectly.


Post a Comment for "SQLAlchemy InvalidRequestError When Using Composite Foreign Keys"