SQLAlchemy: can a deferred column be eagerly loaded?
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
精彩评论