Chris Withers wrote: > Hi Again, > > So here's a test case ready to drop onto the end of test_declarative.py: > > def test_mapper_args_single_table(self): > > class TableNameMixin: > @classproperty > def __tablename__(cls): > return cls.__name__.lower() > > class CommonColumns: > id = Column(Integer, primary_key=True) > > class BaseType(Base, TableNameMixin, CommonColumns): > discriminator = Column('python_type', String(50)) > __mapper_args__= dict(polymorphic_on=discriminator) > value = Column(Integer()) > > class SpecificType1(BaseType): > __mapper_args__ = dict(polymorphic_identity='type1') > > class SpecificType2(BaseType): > __mapper_args__ = dict(polymorphic_identity='type2') > > "between '%s' and '%s'.%s" % (a.description, b.description, hint)) > ArgumentError: Can't find any foreign key relationships between > 'basetype' and 'specifictype1'. > > *sigh* Any ideas? > (I'll be looking further into this, but thought I'd chuck it at the > tlist in case I'm missing anything obvious)
are you wondering....*why* this happens ? its because your mixin is giving all classes a __tablename__. If you want to force SpecificType1/2 to be single-inherited from Base, they'd need their own __tablename__ set to None. Which you can achieve declaratively in each class or via another mixin. > > cheers, > > Chris > > -- > 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.