Re: [Sqlalchemy-tickets] [sqlalchemy] #2723: SQLAlchemy relationships on inherited attributes fail
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-05-07 15:20:12
|
#2723: SQLAlchemy relationships on inherited attributes fail
-------------------------------------+-------------------------------------
Reporter: mitchellrj | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: orm | Severity: no triage selected yet
Resolution: | Keywords: relationship inherited
Progress State: needs questions | inheritance foreign key
answered |
-------------------------------------+-------------------------------------
Changes (by zzzeek):
* status_field: awaiting triage => needs questions answered
Comment:
can you fix up your test please? I'm not sure what "A" is, or "People",
I've created a simple test as below and there's no issue:
{{{
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Person(Base):
__tablename__ = 'people'
id = Column(Integer, primary_key=True)
type = Column(Enum('staff', 'student'))
username = Column(String)
__mapper_args__ = {
'polymorphic_on': type
}
class Staff(Person):
__tablename__ = 'staff'
id = Column(Integer, ForeignKey(Person.id), primary_key=True)
__mapper_args__ = {
'polymorphic_identity': 'staff'
}
class Department(Base):
__tablename__ = 'departments'
id = Column(Integer, primary_key=True)
head_username = Column(String, ForeignKey(Staff.username))
head = relationship(Staff)
configure_mappers()
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2723#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|