SQLAlchemy: Hybrid expression with relationship

主宰稳场 提交于 2019-11-30 10:52:07
Eevee

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!