Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLAlchemy: can a deferred column be eagerly loaded?

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?

like image 722
Ollie Glass Avatar asked Apr 15 '26 19:04

Ollie Glass


1 Answers

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

like image 80
letitbee Avatar answered Apr 18 '26 10:04

letitbee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!