svilen wrote: >>Here is the syntax followed by the generated query: >> >> query.filter(Catalog.c.id==CatalogChannel.c.id) >> WHERE catalogs.id = catalogs.id > > why u need such a query? > that's exactly what (inheritance) join does, and automaticaly - > just query( CatalogChannel).all() would give u the above query.
I have hidden the full concept I'm working on and only focused my problem. Here's my full setup the query is involved with: 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. > as of the relations, they are quite automatic BUT magic does not > always work, so u have to explicitly specify some things manualy. So right now, I'm building that awfully long query to explicitly tell it to look at CatalogChannel: Media.query.filter(Media.c.id_catalog==Catalog.c.id).filter(Catalog.c.id==CatalogChannel.c.id).filter(CatalogChannel.c.id_channel==c.playlist.id_channel).all() # Pheeww... But even this doesn't work well. The part where .filter(Catalog.c.id==CatalogChannel.c.id) wrongly generates: "catalogs.id = catalogs.id" So I need to use the table itself: .filter(Catalog.c.id==catalog_channel_table.c.id) correctly generates: "catalogs.id = catalog_channels.id" This works. Regards, -- Alexandre CONRAD - TLV FRANCE Research & Development --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---