On Fri, Oct 27, 2017 at 4:57 PM, <char...@konversion.ca> wrote: > My SQLAlchemy version is 1.1.14. > > I'm having difficulty understanding behaviours around a polymorphic > hierarchy. > > I have an AbstractConcreteBase and two subclasses. > > The ACB declares some attributes shared by the two subclasses, and the > subclasses have attributes of their own that are not shared(i.e. they are > not part of the shared identity represented by the ACB). > > class MyBase(AbstractConcreteBase, Base, Mixin): > shared_id = Column(Integer, default=Sequence("database_shared_id_seq", > start=0, increment=1), primary_key=True) > > @declared_attr > def name(self): > return Column(String(100), nullable=False) > > @declared_attr > def foreign_key(self): > return Column(Integer, ForeignKey("MyOtherTable.id")) > > ... > > > class Concrete1(MyBase): > start = Column(Date) > end = Column(Date) > > > class Concrete2(MyBase): > > @property > def start(self): > return self.details.start > > @property > def end(self): > return self.details.end > > details = relationship("Concrete2Detail", uselist=False, viewonly=True) > > > As you can see, "start" and "end" are not declared in the ACB and are > implemented differently between the table. I don't want them to be shared by > the subclasses. > > When I query one of the Concretes, the ACB mapper is updated with the > "start" and "end" attributes, and then the Concretes are expected to > implement the attributes on the mapper level(which is not the case for > Concrete2). > > How can I prevent this from happening? >
Can you provide a full script that demonstrates the problem? Thanks, Simon -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.