SQLAlchemy:可以急切加载延迟列吗?
我有一个带有延迟列的声明性 SQLAlchemy 对象,声明如下:
class Review(Base):
__tablename__ = 'review'
id = Column(Integer, primary_key=True)
name = Column(String(255))
large_field = deferred(Column(Text))
有时我希望查询急切地加载这些列,或“取消延迟”它们。我已经尝试过了,但是查看 SQL 输出表明它没有执行任何操作。
reviews = session.query(Review).options(eagerload('large_field')).all():
选择性急切加载可能吗?
I have a declarative SQLAlchemy object with deferred columns, declared like this:
class Review(Base):
__tablename__ = 'review'
id = Column(Integer, primary_key=True)
name = Column(String(255))
large_field = deferred(Column(Text))
Sometimes I'd like queries to eagerly load these columns, or "undefer" them. I've tried this, but looking at the SQL output shows it isn't doing anything.
reviews = session.query(Review).options(eagerload('large_field')).all():
Is selective eager loading possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以
取消
它:http://www.sqlalchemy.org/docs /orm/mapper_config.html?highlight=deferred#sqlalchemy.orm.undefer
Yep, you can
undefer
it:http://www.sqlalchemy.org/docs/orm/mapper_config.html?highlight=deferred#sqlalchemy.orm.undefer