On Thu, 2008-05-15 at 12:27 -0400, Michael Bayer wrote:
> 
> On May 15, 2008, at 12:12 PM, J. Cliff Dyer wrote:
> 
> >
> >
> > How can I use this field for polymorphism?  Is it possible?
> 
> 
> polymorphic discriminators are currently table-local scalar columns.   
> So if you had a many-to-one of discriminators, youd currently have to  
> encode the discriminator to the primary key identifier of each  
> discriminotor.  We will eventually allow a python function to be used  
> as a discriminator as well which you can use to add a level of  
> abstraction to this (you'd preload the list of discriminiator objects  
> and again map based on primary key).
> 
> But a straight load of an entity relying upon an inline JOIN to get  
> the polymorphic discriminator in all cases, automatically by SA, is  
> not going to happen - its inefficient and would be very complex to  
> implement.
> 

Thanks.  That makes sense.  I guess if you can pull across a foreign
key, you can pull across any arbitrary query.  

My goal was to have the code self-documenting in this respect, and I've
achieved that by creating a helper function get_type_id(type_name), so
each polymorphic child of Item now has 

{'polymorphic_identity': get_type_id(u'Article')}
{'polymorphic_identity': get_type_id(u'Illustration')}
{'polymorphic_identity': get_type_id(u'Map')}

and so on.  It seems to be working so far.

Thanks,
Cliff



> > 


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