> > 2) Since this smells of inheritance, I read about class
> > inheritance mapping but couldn't decide if and which method
> > applies here. Help would be greatly appreciated.
>
> I think svil's assumption of joined table inheritance is incorrect
> here, since each table contains "name" and "price". This would be
> concrete table inheritance, described at
> http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mappe
>r_inheritance_concrete .
here the generated setup when inheritance changed to "concrete".
if its about inheritance u need polymorhic_union, and tell the mapper
about it.
else, feeding unions into query - was it
query(clas).from_statement(...) ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
========= generated SA set-up
table_ElProduct = Table( 'ElProduct', meta,
Column( 'price', Integer, ),
Column( 'name', String(length=100, convert_unicode=False, assert_unicode=None), ),
Column( 'voltage', Integer, ),
Column( 'db_id', primary_key= True, type_= Integer, ),
)
table_FoodProduct = Table( 'FoodProduct', meta,
Column( 'price', Integer, ),
Column( 'calories', Integer, ),
Column( 'name', String(length=100, convert_unicode=False, assert_unicode=None), ),
Column( 'db_id', primary_key= True, type_= Integer, ),
)
table_GenProduct = Table( 'GenProduct', meta,
Column( 'price', Integer, ),
Column( 'name', String(length=100, convert_unicode=False, assert_unicode=None), ),
Column( 'db_id', primary_key= True, type_= Integer, ),
)
meta.create_all()
class ElProduct( GenProduct):
props = ['db_id', 'price', 'name', 'voltage']
class FoodProduct( GenProduct):
props = ['db_id', 'price', 'calories', 'name']
class GenProduct( Base):
props = ['db_id', 'price', 'name']
mapper_ElProduct = mapper( ElProduct, table_ElProduct,
concrete= True,
inherits= mapper_GenProduct,
polymorphic_identity= 'ElProduct',
)
mapper_FoodProduct = mapper( FoodProduct, table_FoodProduct,
concrete= True,
inherits= mapper_GenProduct,
polymorphic_identity= 'FoodProduct',
)
pu_genproduct = polymorphic_union( {
'ElProduct': table_ElProduct,
'FoodProduct': table_FoodProduct,
'GenProduct': table_GenProduct,
}, 'atype', 'pu_genproduct', ) #concrete table
mapper_GenProduct = mapper( GenProduct, table_GenProduct,
polymorphic_identity= 'GenProduct',
polymorphic_on= pu_genproduct.c.atype,
select_table= pu_genproduct,
)
mapper_GenProduct1 = mapper( GenProduct, table_GenProduct,
non_primary= True,
)
psub_genproduct = polymorphic_union( {
'ElProduct': table_ElProduct,
'FoodProduct': table_FoodProduct,
}, 'atype', 'psub_genproduct', ) #concrete table
========= eo generated SA set-up