Thanks Mike, But...is there no way to set this behavior directly on the "relationship()"? The whole point there is to be "lazy" ;)
Seth On Saturday, May 10, 2014 7:59:33 PM UTC-7, Michael Bayer wrote: > > > session.query(Parent).options(defaultload(“children”).load_only(“cheap_column")) > > or really if you want to cut out “expensive_column” > > > session.query(Parent).options(defaultload(“children”).defer(“expensive_column”)) > > http://docs.sqlalchemy.org/en/rel_0_9/orm/mapper_config.html#deferred > > > > On May 10, 2014, at 6:39 PM, Seth <[email protected] <javascript:>> > wrote: > > Is there any way to get SQLAlchemy to only load specific columns through a > relationship()? > > For example, with this scenario: > > class Parent(Base): > __tablename__ = 'parent' > id = Column(Integer, primary_key=True) > children = relationship("Child", lazy='joined') > > class Child(Base): > __tablename__ = 'child' > id = Column(Integer, primary_key=True) > parent_id = Column(Integer, ForeignKey('parent.id')) > cheap_column = Column(Unicode(10)) > expensive_column = Column(LargeBinary) > > I'd like Child to get lazily joined when Parent is loaded, but only with > Child's "cheap_column" and not it's "expensive_column". > > Thanks, > Seth > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To post to this group, send email to [email protected]<javascript:> > . > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
