On Dec 30, 2007, at 8:01 PM, Matt wrote:

>
> Yeah, I didn't include the whole Content mapper, here are the
> polymorphic params for that mapper:
>
> polymorphic_on=content_table.c.type, polymorphic_identity='content'
>
> And ContentLeaf:
>
> mapper(ContentLeaf, content_leaf,
>           properties = {
>            '_copyright': content_leaf.c.copyright,'copyright' :
> synonym('_copyright'),
>            '_grid     ': content_leaf.c.grid,'grid' :
> synonym('_grid'),
>            '_gtin'     : content_leaf.c.gtin,'gtin' :
> synonym('_gtin'),
>            '_iswc'     : content_leaf.c.iswc,'iswc' :
> synonym('_iswc'),
>            '_isan'     : content_leaf.c.isan,'isan' :
> synonym('_isan'),
>            '_isrc'     : content_leaf.c.isrc,'isrc' :
> synonym('_isrc'),
>            '_reviewed' : content_leaf.c.reviewed,'reviewed' :
> synonym('_reviewed'),
>            '_flagged'  : content_leaf.c.flagged,'flagged' :
> synonym('_flagged'),
>            '_ingestion_type':
> content_leaf.c.ingestion_type,'ingestion_type' :
> synonym('_ingestion_type'),
>           },
>           inherits             = cm,
>           polymorphic_on       = content_table.c.type,
>           polymorphic_identity ='leaf')
>
> So, loading polymorphically is working for me.
>
> So maybe I can do something like:
>
> q =
> Session
> .query
> (Content
> ).add_entity(Account).select_from(content_table.outerjoin(accounts))
>
> To get the account?
>

heres a random guess at what might make this actually work (its a  
workaround).  Make the regular mappers, with the eagerload to  
'accounts', and select_table.  Then, after you make your mappers, say  
this:

compile_mappers()
class_mapper(Content).get_select_mapper().add_property('accounts',  
Account, lazy=False)

that might be all thats needed here.  basically just sticking the  
property on the "surrogate" mapper, which is the mapper mapped to your  
select_table.

otherwise, same idea is just make a second mapper against the join  
using non_primary=True.





--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to