mixin columns blown away by the mapped columns on joined inh

Issue #2226 resolved
Michael Bayer
repo owner created an issue
from sqlalchemy import Column, String, ForeignKeyConstraint, Integer
from sqlalchemy.ext.declarative import declarative_base, declared_attr


class TableName(object):
   @declared_attr
   def __tablename__(cls):
       return cls.__name__


Base=declarative_base(cls=TableName)


class TMixin(object):

   @declared_attr
   def user(cls):
       return Column(String, primary_key=True)

   @declared_attr
   def timestamp(cls):
       return Column(Integer, autoincrement=False, primary_key=True)


class Timeline(TMixin, Base):

   snaptype = Column(Integer, primary_key=True, autoincrement=False)

   __mapper_args__ = {'polymorphic_on': snaptype}


class CMixin(TMixin):

   @declared_attr
   def __table_args__(cls):
       return (ForeignKeyConstraint(
                   ['timestamp']('user',),
                   ['Timeline.timestamp']('Timeline.user',)),)

   @declared_attr
   def __mapper_args__(cls):
       return {'polymorphic_identity': CMixin.__subclasses__().index(cls)}


class C(CMixin, Timeline):

   pass

Comments (2)

  1. Log in to comment