Using Flask-SQLAlchemy, I would like to delete rows in table Questions based on the values of another table which is linked to table Topic which then is linked to table Subject with foreign keys. I tried this query:
db.session.query(Questions).join(Topic)join(Subject).filter(Subject.account_id==current_user.id).delete()
However, I receive an error:
InvalidRequestError: Can't call Query.update() or Query.delete() when join(), outerjoin(), select_from(), or from_self() has been called
So from this I suppose I cannot use .delete() with .join()
Is there a workaround for this issue? Thanks.