On Jun 7, 7:05 pm, svilen <[EMAIL PROTECTED]> wrote:
> what is your hierarchy?
> why Boss' mapper inherits from person's one, and not from manager's
> one?

Yes it was a mistake indeed.

Going further with other tests i still notice something that can't be
easily done. Summarizing the setup, classes are::

    class Employee(object): pass
    class Manager(Employee): pass
    class Boss(Manager): pass

while the mapper is::

    person_join = polymorphic_union(
        {
            'person':employees.select(employees.c.type=='person'),
            'engineer':employees.join(engineers),
            'manager':employees.join(managers),
            'boss':employees.join(managers).join(boss),
        }, None, 'pjoin')


    mapper(Boss, boss,
        inherits=manager_mapper,
        polymorphic_identity='boss')

a polymorphic fetch "ses.query(Employee).select()" correctly returns
objects of all the classes, and the query "ses.query(Boss).select()"
works fine as well. But while i expected "ses.query(Manager).select()"
to fetch bosses too, an exception with the following error message is
raised::

    InvalidRequestError: Given column 'boss.person_id', attached to
table 'boss',
    failed to locate a corresponding column from table 'Join object on
employees managers'

I also tried to be explicit about what to join, declaring stuff such::

    j1 = employees.join(managers)
    person_join = polymorphic_union({
        'boss':j1.join(boss),
        ...

    mapper(Boss, boss,
        inherits=manager_mapper,
        polymorphic_identity='boss',
        inherit_condition=boss.c.person_id==j1.c.managers_person_id
    )

but eventually anything fails with the same exception.

What i can see is that employees.join(managers) has fields
'employees_person_id' and 'managers_person_id' while the
FromClause.corresponding_column() method looks for a bare 'person_id'
and i don't know how to map them.

Am i doing something obviously wrong or is this something to work on
about inheritance? (currently using SA 3.7)

Thank you,

-- Daniele


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