Conor wrote: > I'm having trouble with many-to-one relationships to subclasses that use > single table inheritance. I have tried this in 0.5.8 and 0.6beta1.
that's what I get for not trying to answer every single email, a 6 month old bug which I've missed. This is very small and I've created and closed ticket #1731 for this in r5402dd9d21e8 . > > Here is my test case: > > import sqlalchemy as sa > from sqlalchemy import orm > from sqlalchemy.ext.declarative import declarative_base > > Base = declarative_base() > > employee = sa.Table("employee", Base.metadata, > sa.Column("id", sa.Integer, primary_key=True), > sa.Column("type", sa.Integer, nullable=False)) > > class Employee(Base): > __table__ = employee > __mapper_args__ = {"polymorphic_identity": 0, > "polymorphic_on": employee.c.type} > > class Engineer(Employee): > __mapper_args__ = {"polymorphic_identity": 1} > > class Other(Base): > __tablename__ = "other" > > # Fields > id = sa.Column(sa.Integer, primary_key=True) > engineer_id = sa.Column(sa.Integer, > sa.ForeignKey("employee.id")) > > # Relations > engineer = orm.relation("Engineer") > > print Other.engineer.has() > > I get this exception: > > AttributeError: 'ClauseList' object has no attribute 'proxy_set' > > This appears to be the same issue described at > http://groups.google.com/group/sqlalchemy/browse_thread/thread/7fcb0c0c6e1c809f. > Is this a bug? Currently, I am working around the issue by changing > Other.engineer to refer to Employee and using > Other.engineer.of_type(Engineer).has(), but this is less than ideal. > > NOTE: In my real use case, I have compound foreign keys and check > constraints on Other to ensure that its engineer_id only points to > Engineer objects. However that was not necessary to demonstrate the > problem, so it has been omitted here. > > Thanks, > -Conor > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.