I have a User model that resembles the following:
class User(db.Model):id = db.Column(db.BigInteger, primary_key=True)account_id = db.Column(db.BigInteger, db.ForeignKey('account.id'))account = db.relationship('Account',backref=db.backref('ref_users', cascade='delete'))...def after_user_write(mapper, connection, target):target.account.invalidate_cache()event.listen(User, 'after_insert', after_user_write)
event.listen(User, 'after_update', after_user_write)
event.listen(User, 'after_delete', after_user_write)
Upon insert after_user_write
is being called, but target.account
is None
(which causes an error) when I expect it to be an Account model. target.account_id
is set correctly, it just seems like the relationship reference isn't working as I'd expect.
Any ideas on what's causing this?