> On Nov 24, 2014, at 5:16 PM, Michael Bayer <[email protected]> wrote:
>
>>
>> On Nov 24, 2014, at 12:31 PM, Michael Bayer <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>>
>>> On Nov 24, 2014, at 1:00 AM, Victor Reichert <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> I've taken another look at trying to eager load the address.parent. Is it
>>> possible to do that?
>>
>> Unfortuntately not really. It should be in theory but I’m not able to
>> work out an eager load that goes to both Customer and Supplier in terms of
>> AddressAssociation at the same time. I can get the query to render just
>> fine but the eager-targeting logic at the moment doesn’t seem to know how to
>> be told to go to two separate subclasses of a base class at the same time.
>> There’s probably improvements yet to be made in eager loading to support
>> this case better, e.g. this is a bug, but I’ve wrestled with it for about an
>> hour and I’m out of time on it for now, sorry. Even if it works, the
>> query is very unpleasant to look at :) If I get it working later I’ll
>> send it out.
>
> OK here we go, the limitation is that the of_type() modifier is only
> recognized along a particular path once. So to get over this we can use a
> with_polymorphic():
good news, i whacked that limitation in the latest master for 1.0. so when 1.0
is released (in some months), you can do:
eager_addresses = session.query(Address).options(
joinedload(
Address.association.of_type(Customer.assoc_cls)).joinedload(
Customer.assoc_cls.parent),
joinedload(
Address.association.of_type(Supplier.assoc_cls)).joinedload(
Supplier.assoc_cls.parent),
)
this will behind the scenes build up that with_polymorphic() thing for you.
--
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.