On Jan 11, 2008, at 10:03 AM, Alexandre Conrad wrote:

>
> svilen wrote:
>> On Friday 11 January 2008 16:12:08 Alexandre Conrad wrote:
>>
>>> Channel -> Playlist -> Media
>>> Channel -> CatalogChannel(Catalog) -> Media
>>>
>>> (Media has a fk to Catalog, not CatalogChannel)
>>> The only element I have, is "playlist" (instance of Playlist). At
>>> this point, I need to find out the available Media of the
>>> Playlist's Channel's catalog so I can attach them to the Playlist.
>>>
>>> At first, I tryied out:
>>>
>>> Media.query.join(["catalog",
>>> "channel"]).filter(Channel.c.id==playlist.id_channel).all()
>>>
>>> But then it complains that "channel" is not part of the Catalog
>>> mapper. Catalog ? I want it to be looking at CatalogChannel, this
>>> is the one having the "channel" relation, not Catalog.
>>
>> i see what u want, but formally (computer languages are formal, SA is
>> a language) u are contradicting yourself. u said above that
>> media points to catalog and not to catalogchannel. How u expect it to
>> find a .channel there?
>
> I was expecting that SA would know that from the polymorphic "type"
> flag. I have a "catalog" relation on media. When I do media.catalog,  
> it
> doesn't just return a Catalog object, but really a CatalogChannel  
> object
> (which is the whole point of polymorphic inheritance). And I thought  
> it
> could figure out channel from that. But Mike said no. :) That's why he
> talked about having some extra API query methods:

I dont see where the "type" element youre mentioning is present in  
this query.  if Media points to Catalog, thats the end of the story -  
what is telling it about a "CatalogChannel" ?

look at it this way.  Suppose you have CatalogA(Catalog),  
CatalogB(Catalog), CatalogChannel(Catalog), CatalogQ(Catalog).  all  
four of those classes have an attribute called "channel".  Catalog  
does not.  Media references Catalog; therefore, the "catalog"  
attribute on Media can be any of:  CatalogA, CatalogB, CatalogChannel,  
Catalog, or CatalogQ.

Now I say:

Media.query.join(["catalog", "channel"])

Whats the join is has to produce ?  what table does it join to ?   
catalog_channel, catalog_a, catalog_b, catalog_c, catalog_q ?  or does  
it try to make a UNION out of joins for all of those (clearly we arent  
going to guess that deeply) ?



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to