there are deferred() columns that you can set on a mapper but there's not a 
mechanism right now to set deferred target attributes when the object is loaded 
only from a specific relationship without the specific call within the query(). 
   So unless you maybe ran those options into every Query unconditionally, or 
something.  I'd look to see how big a deal it is to just be explicit on this 
one.



On May 14, 2014, at 1:39 PM, Seth <seedifferen...@gmail.com> wrote:

> 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 <seediff...@gmail.com> 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 sqlalchemy+...@googlegroups.com.
>> To post to this group, send email to sqlal...@googlegroups.com.
>> 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 tosqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to