On Friday 11 January 2008 17:03:06 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 hey, polymorphic means ANY subtype, u could have 5 other CatalogRivers that have no .channel in them... how to guess which one? Find the one that has .channel? the root-most one or some of its children-klasses?
> (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: > > Media.query.join_to_subclass(CatalogChannel).join("channel").filter >(Channel.c.id==playlist.id_channel).all() > > We could even join classes only directly (isn't this ORM after > all?): > > Media.query.join([CatalogChannel, Channel]) this is completely different beast. it might be useful... although the whole idea of the join(list) is list of attribute-names and not klasses/tables - to have a.b.c.d.e.f, i.e. be specific and avoid thinking in diagram ways (klasA referencing klasB means nothing if it happens via 5 diff.attributes) when i needed similar thing, a) i moved the .channel into the root or b) changed media to reference CatChannel and not the base one. ciao svilen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---