the Document class starts out as unmapped. then when you call prepare() (or whatever it's called for ACB), it calls the polymorphic_union() function and them maps Document to that. This union has just columns in it, e.g. _name in this case. There's no attempt to reconcile column labels used on descendant classes to the superclass. You could have another class ActualDocument2 that has a column "name_" but a different attribute name.
On Sep 5, 2014, at 7:53 PM, Alex Grönholm <alex.gronh...@nextday.fi> wrote: > Sorry to be asking more questions, but the docs on inheritance don't get into > much details on how the properties are supposed to work. > The following code produces unexpected results: > > from sqlalchemy import * > from sqlalchemy.orm import * > from sqlalchemy.ext.declarative import AbstractConcreteBase, declarative_base > > Base = declarative_base() > > > class Document(Base, AbstractConcreteBase): > doctype = Column('doc_type', Unicode, nullable=False) > > > class ActualDocument(Document): > __tablename__ = 'actual_documents' > __mapper_args__ = {'concrete': True, 'polymorphic_identity': 'actual'} > > id = Column(Integer, primary_key=True) > name = Column('name_', Unicode) > > configure_mappers() > > for prop in class_mapper(Document).column_attrs: > print('%s (%s)' % (prop, prop.__class__.__name__)) > > for prop in class_mapper(ActualDocument).column_attrs: > print('%s (%s)' % (prop, prop.__class__.__name__)) > > Which gives me: > > Document.doc_type (ColumnProperty) > Document.id (ColumnProperty) > Document.name_ (ColumnProperty) > Document.type (ColumnProperty) > ActualDocument.doctype (ColumnProperty) > ActualDocument.name (ColumnProperty) > ActualDocument.id (ColumnProperty) > > I can understand Document.id (which comes from ActualDocument) and > Document.type (which I assume is the polymorphic identity) but doc_type seems > wrong to me. Why are doc_type and name_ not named doctype and name > respectively, like they are on ActualDocument? Is this a bug? Am I right in > guessing that the polymorphic union simply lacks the proper labels where the > column name differs from the attribute name? > > > -- > 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 http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- 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 http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.