- changed status to invalid
mixin columns blown away by the mapped columns on joined inh
Issue #2226
resolved
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)
-
reporter -
reporter - removed milestone
Removing milestone: 0.6.9 (automated comment)
- Log in to comment
c1295ce57ba7d906821b3ddd5b97aa9659700d52 / ba40767d23e4ad488d1e6a2ad3c366036a50ee18 include tests in declarative illustrating why the above mapping is not valid. "name" and "timestamp" are owned by
Timeline
and should not be "copied" out toC
due to the mro. Also added an informative error message regarding the Fk.