you relation should have argument like
primary_join= engineers.c.hired_by_id==managers.c.employee_id
or similar. i do not know for sure as i've done a layer on top of SA that 
stores most of this knowledge, so i dont bother with it. Have a look at 
dbcook.sf.net. u may use it as ORM to build and use your model, or use is 
just to describe your model then dump the equivalent SA-calls (see 
usage/example/example*), and use that one, dropping the dbcook.
As of joined-inh, SA supports all the 3 single/concrete/joined, but real 
polymorphism does not work for the concrete case. Also, joined inh is done 
via left-outer-join which is simpler/faster than an union - although that is 
also an option.
have fun
svilen

Dave E wrote:
> http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_inheritance_joined
> 
> My question is what if you wanted to add a 'hired' field to say the
> employees table & object (from the example in that link) that
> references a manager object.  In this way I imagine that we are making
> another reference to an employee object and might be an issue when
> trying to figure out the join.  So I'd imagine that the tables look
> like:
> 
> employees = Table('employees', metadata,
>    Column('employee_id', Integer, primary_key=True),
>    Column('name', String(50)),
>    Column('type', String(30), nullable=False)
> )
> engineers = Table('engineers', metadata,
>    Column('employee_id', Integer, ForeignKey('employees.employee_id'),
> primary_key=True),
>    Column('hired_by_id',Integer,ForeignKey('managers.employee_id')),
> #######INTERESTING PART
>    Column('engineer_info', String(50)),
> )
> managers = Table('managers', metadata,
>    Column('employee_id', Integer, ForeignKey('employees.employee_id'),
> primary_key=True),
>    Column('manager_data', String(50)),
> )
> 
> and the mappers look like:
> 
> mapper(Employee, employees, polymorphic_on=employees.c.type,
> polymorphic_identity='employee')
> mapper(Engineer, engineers, inherits=Employee,
> polymorphic_identity='engineer',
>     properties={
>         'hirer':relation(Manager,uselist=False,backref='hired')
>     })
> mapper(Manager, managers, inherits=Employee,
> polymorphic_identity='manager')
> 
> 
> But the error message you'd get if you do this is:
> sqlalchemy.exceptions.ArgumentError: Error determining primary and/or
> secondary join for relationship 'Engineer.hirer (Manager)'. If the
> underlying error cannot be corrected, you should specify the
> 'primaryjoin' (and 'secondaryjoin', if there is an association table
> present) keyword arguments to the relation() function (or for
> backrefs, by specifying the backref using the backref() function with
> keyword arguments) to explicitly specify the join conditions. Nested
> error is "Can't determine join between 'Join object on
> employees(14680464) and engineers(14680880)' and '_FromGrouping
> object'; tables have more than one foreign key constraint relationship
> between them. Please specify the 'onclause' of this join explicitly."
> 
> Might I add that this is an extremely informative error message!
> 
> Basically, my question is how do I satisfy this requirement as
> described by the error message?  I have to make my join more
> specific?  How would I do that?
> 
> And another question, is Joined Table Inheritance a common thing to do
> in SQLAlchemy?
> 
> > 


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