Thanks for the help! Specifying path as a string relative to the "root" of the query properly defers the columns. Specifying path information with qualified object attributes (your second suggestion) also works. So everything works, I didn't
Is this approach correct for cases where you end up deferring a large number of columns (e.g. 20)? Is there perhaps a more efficient way to bulk defer/undefer columns (whether these are columns of related children or the root) short of specifying that information when initially creating the query (e.g. session.query(A.b, A.c, B.x, ...)). I avoided doing that as I wanted an instance of a root object and the query.one() problem. Thanks, M On Mar 12, 8:56 am, "Michael Bayer" <[email protected]> wrote: > me wrote: > > > 2] Using path to the joined column: > > query = query.option(defer("a.s1_relation.col1"), defer > > ("a.s1_alias_relation.col2"),...) > > > 2 > > Simply doesn't work for me (i.e. the columns i'm deferring are clearly > > in the echoed sql). > > try not putting "a" in there. defer() is based on an older usage of Query > that assumes one entity at the root, i.e. > s.query(SomeClass).options(defer("relation.somecol")). > > > I also tried passing instrumented object attributes to defers like > > this: query = query.option(defer(S1.y), defer(S1Alias.x)) but that > > failed with an exception about e.g. S1 not being found in the mapper. > > I tried adding them to the query like this: query.add_entity(S1) but > > that didn't help. > > needs a path from the "root": defer(SomeClass.foo, FooClass.bar) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
