I am using a single table scheme to store for a set of resource types.

I would like to load a specific class if a mapper is defined and use the 
base class if no
more specific version can be found.   Is there a way to do this?
i.e.
resource  = Table('resource', 
                           Column('resource_type',  String),
                           ...

I also have a set of predefined helper classes
class Resource, Resource_A, Resource_B, 

mapper(Resource, ...
       polymorphic_on = resource.c.resource_type,                           
                                        
       #polymorphic_identity = ''*"  # I think I need something like this
mapper(Resource_A,...
       polymorphic_on = resource.c.resource_type,                           
                                        
       polymorphic_identity = ''A"
mapper(Resource_B,...
       polymorphic_on = resource.c.resource_type,                           
                                        
       polymorphic_identity = ''B"


Now if I have inserted types 
A = Resource_A()
B = Resource_B()
C = Resource()
C.resource_type = "C"
D = Resource()
D.resource_type = "D"
session.add([A,B,C,D])

And then I do 
session.query(Resource)

Is there a way to specify the polymorphic_identity of Resource is default ?

Thanks.

                       

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/CTUpcBdq-IUJ.
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