I have two Flask-SQLAlchemy models with a simple one-to-many relationship, like the minimal example below:
class School(db.Model):
id = db.Column(db.Inte
A much simpler approach for a simple case like this is an association proxy:
class Teacher(db.Model):
school_name = associationproxy('school', 'name')
This supports querying (at least with ==
) automatically.
I'm curious how the hybrid select()
example didn't work for you, since that's the easiest way to fix this within a hybrid. And for the sake of completion, you could also use a transformer to amend the query directly rather than subquerying.