On Jan 15, 2008, at 5:48 AM, Alexandre Conrad wrote:
>
> Okay, my fault. I was editing the wrong code in my test case
> concerning
> the "select_from" alternative.
>
> Let's go back to that new feature from r4060 you've proposed,
> concerning
> joins directly from classes. Attached is my updated test case.
>
> If I wanted to join only from classes, I'd suppose we'd have the
> following syntax:
>
> Media.query.join([Media.catalog, CatalogChannel.id,
> CatalogChannel
> .channel
> ]).filter(CatalogChannel.c.id_channel==playlist.id_channel).all()
>
> This would mean join Media on Catalog, join CatalogChannel on Catalog,
> join CatalogChannel on Channel; WHERE
> CatalogChannel.c.id_channel==foo.
>
> This is just an idea, but here the join with "CatalogChannel.id" would
> mean that is need to figure out that PK is also FK to Catalog.
>
from my understanding , you dont really want to join to CatalogChannel
at all as a Query-level join, you just want to filter on the
"id_channel" column as it occurs under the arrangement of Media's
"catalog" items. Query.join is meant only for entity-to-entity
joins. In this case, Media->catalog is the only entity level join you
need.
on my workstation here I have it working like such:
select_table = catalog_table.outerjoin(catalog_channel_table)
catalog_mapper = mapper(Catalog, catalog_table,
select_table=select_table, polymorphic_on=catalog_table.c.type,
polymorphic_identity="catalog",
properties={
"medias":relation(Media,
backref="catalog",
cascade="all, delete-orphan",
),
},
)
print
Media
.query
.join
('catalog').filter(CatalogChannel.id_channel==playlist.id_channel).all()
the commit still needs some cleanup. and I think it will also work in
trunk if you use an aliased select for that select_table right now.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---