开发者

SQLAlchemy: can a deferred column be eagerly loaded?

开发者 https://www.devze.com 2023-03-06 01:00 出处:网络
I have a declarative SQLAlchem开发者_运维知识库y object with deferred columns, declared like this:

I have a declarative SQLAlchem开发者_运维知识库y 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?


Yep, you can undefer it: http://www.sqlalchemy.org/docs/orm/mapper_config.html?highlight=deferred#sqlalchemy.orm.undefer

0

精彩评论

暂无评论...
验证码 换一张
取 消