Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-15 Thread Jonathan Vanasco
Michael- Quick question for clarity... I have a table with a few deferred columns. If I want to eagerly load them during a query, I should pass in the undefer option right ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from

Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-15 Thread Michael Bayer
yeah there's some bad history with the API here, in that you can't easily pass them all at once, but right now it's q.options(undefer('*')) for everything or q.options(undefer('x'), undefer('y'), ...). or undefer_group() if you've applied a group to them. On May 15, 2014, at 1:42 PM,

Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-15 Thread Jonathan Vanasco
that's not too bad. at least for me; i only defer a few HSTORE columns. On Thursday, May 15, 2014 2:24:51 PM UTC-4, Michael Bayer wrote: yeah there’s some bad history with the API here, in that you can’t easily pass them all at once, but right now it’s q.options(undefer(‘*’)) for

Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-14 Thread Seth
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

Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-14 Thread Michael Bayer
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

Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-14 Thread Seth
Ok, thanks so much for your help. On Wednesday, May 14, 2014 2:35:27 PM UTC-7, Michael Bayer wrote: 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

[sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-10 Thread Seth
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):

Re: [sqlalchemy] How do you limit/specify the columns that are loaded via a relationship()?

2014-05-10 Thread Michael Bayer
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,