Sorry I missed that. The definition for Engineer also matches Chemical
Engineers. I assumed the error was in my inheritance code, but of
course it turned out to be something much simpler.
Otherwise, is the approach correct? Should the Chemical Engineer mapper
inherit from the Engineer mapper or from the Employee mapper? Is using
the concrete approach with select objects optimal? Is there a better
way to approach this?
I'm still trying to get a grip on SA inheritance. The examples are
pretty clear, but as I think of other cases, it's not yet always clear
how they should be done, which means I don't understand SA inheritance
well enough yet.
Thanks.
Randall
Michael Bayer wrote:
> if you change your "echo" to 'debug', or just select straight from your
> p_union selectable, youll see these rows:
>
> (5, u'cengineer1', u'cengineer1', u'cengineer1', None,
> u'chemical_engineer')
> (6, u'cengineer2', u'cengineer2', u'cengineer2', None,
> u'chemical_engineer')
> (1, u'manager1', None, None, u'manager1', u'manager')
> (2, u'manager2', None, None, u'manager2', u'manager')
> (3, u'engineer1', u'engineer1', None, None, u'engineer')
> (4, u'engineer2', u'engineer2', None, None, u'engineer')
> (5, u'cengineer1', u'cengineer1', u'cengineer1', None, u'engineer')
> (6, u'cengineer2', u'cengineer2', u'cengineer2', None, u'engineer')
>
> Where you can see that the chemical engineers are coming out twice with
> inconsistent types. the query has to be tuned to be more specific:
>
> managers = select([employees, column("'manager'").label('type')],
> employees.c.manager_data !=
> None).alias('managers')
> engineers = select([employees, column("'engineer'").label('type')],
> and_(employees.c.engineer_info !=
> None,
> employees.c.cheme_info==None)).alias('engineers')
> chemical_engineers = select([employees,
> column("'chemical_engineer'").label('type')],
> and_(employees.c.engineer_info != None,
> employees.c.cheme_info !=
> None)).alias(
> 'chemical_engineers')
>
>
> p_union = polymorphic_union(
> {
> 'engineer': engineers,
> 'manager': managers,
> 'chemical_engineer': chemical_engineers
> },
> None,
> )
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---